Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * Zend Framework
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to version 1.0 of the Zend Framework
8
 * license, that is bundled with this package in the file LICENSE, and
9
 * is available through the world-wide-web at the following URL:
10
 * http://www.zend.com/license/framework/1_0.txt. If you did not receive
11
 * a copy of the Zend Framework license and are unable to obtain it
12
 * through the world-wide-web, please send a note to license@zend.com
13
 * so we can mail you a copy immediately.
14
 *
15
 * @package    Zend_Search_Lucene
16
 * @subpackage Search
17
 * @copyright  Copyright (c) 2005-2006 Zend Technologies USA Inc. (http://www.zend.com)
18
 * @license    http://www.zend.com/license/framework/1_0.txt Zend Framework License version 1.0
19
 */
20
 
21
 
22
/**
23
 * @package    Zend_Search_Lucene
24
 * @subpackage Search
25
 * @copyright  Copyright (c) 2005-2006 Zend Technologies USA Inc. (http://www.zend.com)
26
 * @license    http://www.zend.com/license/framework/1_0.txt Zend Framework License version 1.0
27
 */
28
class Zend_Search_Lucene_Search_Similarity_Default extends Zend_Search_Lucene_Search_Similarity
29
{
30
 
31
    /**
32
     * Implemented as '1/sqrt(numTerms)'.
33
     *
34
     * @param string $fieldName
35
     * @param integer numTerms
36
     * @return float
37
     */
38
    public function lengthNorm($fieldName, $numTerms)
39
    {
40
        return 1.0/sqrt($numTerms);
41
    }
42
 
43
    /**
44
     * Implemented as '1/sqrt(sumOfSquaredWeights)'.
45
     *
46
     * @param float $sumOfSquaredWeights
47
     * @return float
48
     */
49
    public function queryNorm($sumOfSquaredWeights)
50
    {
51
        return 1.0/sqrt($sumOfSquaredWeights);
52
    }
53
 
54
    /**
55
     * Implemented as 'sqrt(freq)'.
56
     *
57
     * @param float $freq
58
     * @return float
59
     */
60
    public function tf($freq)
61
    {
62
        return sqrt($freq);
63
    }
64
 
65
    /**
66
     * Implemented as '1/(distance + 1)'.
67
     *
68
     * @param integer $distance
69
     * @return float
70
     */
71
    public function sloppyFreq($distance)
72
    {
73
        return 1.0/($distance + 1);
74
    }
75
 
76
    /**
77
     * Implemented as 'log(numDocs/(docFreq+1)) + 1'.
78
     *
79
     * @param integer $docFreq
80
     * @param integer $numDocs
81
     * @return float
82
     */
83
    public function idfFreq($docFreq, $numDocs)
84
    {
85
        return log($numDocs/(float)($docFreq+1)) + 1.0;
86
    }
87
 
88
    /**
89
     * Implemented as 'overlap/maxOverlap'.
90
     *
91
     * @param integer $overlap
92
     * @param integer $maxOverlap
93
     * @return float
94
     */
95
    public function coord($overlap, $maxOverlap)
96
    {
97
        return $overlap/(float)$maxOverlap;
98
    }
99
}