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 document
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
 *
24
 * @package    Zend_Search_Lucene
25
 * @subpackage Analysis
26
 * @copyright  Copyright (c) 2005-2006 Zend Technologies USA Inc. (http://www.zend.com)
27
 * @license    http://www.zend.com/license/framework/1_0.txt Zend Framework License version 1.0
28
 */
29
class Zend_Search_Lucene_Analysis_Token
30
{
31
    /**
32
     * The text of the term.
33
     *
34
     * @var string
35
     */
36
    private $_termText;
37
 
38
    /**
39
     * Start in source text.
40
     *
41
     * @var integer
42
     */
43
    private $_startOffset;
44
 
45
    /**
46
     * End in source text
47
     *
48
     * @var integer
49
     */
50
    private $_endOffset;
51
 
52
    /**
53
     * Lexical type.
54
     *
55
     * @var string
56
     */
57
    private $_type;
58
 
59
    /**
60
     * The position of this token relative to the previous Token.
61
     *
62
     * The default value is one.
63
     *
64
     * Some common uses for this are:
65
     * Set it to zero to put multiple terms in the same position.  This is
66
     * useful if, e.g., a word has multiple stems.  Searches for phrases
67
     * including either stem will match.  In this case, all but the first stem's
68
     * increment should be set to zero: the increment of the first instance
69
     * should be one.  Repeating a token with an increment of zero can also be
70
     * used to boost the scores of matches on that token.
71
     *
72
     * Set it to values greater than one to inhibit exact phrase matches.
73
     * If, for example, one does not want phrases to match across removed stop
74
     * words, then one could build a stop word filter that removes stop words and
75
     * also sets the increment to the number of stop words removed before each
76
     * non-stop word.  Then exact phrase queries will only match when the terms
77
     * occur with no intervening stop words.
78
     *
79
     * @var integer
80
     */
81
    private $_positionIncrement;
82
 
83
 
84
    /**
85
     * Object constructor
86
     *
87
     * @param string  $text
88
     * @param integer $start
89
     * @param integer $end
90
     * @param string  $type
91
     */
92
    public function __construct($text, $start, $end, $type = 'word' )
93
    {
94
        $this->_termText    = $text;
95
        $this->_startOffset = $start;
96
        $this->_endOffset   = $end;
97
        $this->_type        = $type;
98
 
99
        $this->_positionIncrement = 1;
100
    }
101
 
102
 
103
    /**
104
     * positionIncrement setter
105
     *
106
     * @param integer $positionIncrement
107
     */
108
    public function setPositionIncrement($positionIncrement)
109
    {
110
        $this->_positionIncrement = $positionIncrement;
111
    }
112
 
113
    /**
114
     * Returns the position increment of this Token.
115
     *
116
     * @return integer
117
     */
118
    public function getPositionIncrement()
119
    {
120
        return $this->_positionIncrement;
121
    }
122
 
123
    /**
124
     * Returns the Token's term text.
125
     *
126
     * @return string
127
     */
128
    public function getTermText()
129
    {
130
        return $this->_termText;
131
    }
132
 
133
    /**
134
     * Returns this Token's starting offset, the position of the first character
135
     * corresponding to this token in the source text.
136
     *
137
     * Note:
138
     * The difference between getEndOffset() and getStartOffset() may not be equal
139
     * to strlen(Zend_Search_Lucene_Analysis_Token::getTermText()), as the term text may have been altered
140
     * by a stemmer or some other filter.
141
     *
142
     * @return integer
143
     */
144
    public function getStartOffset()
145
    {
146
        return $this->_startOffset;
147
    }
148
 
149
    /**
150
     * Returns this Token's ending offset, one greater than the position of the
151
     * last character corresponding to this token in the source text.
152
     *
153
     * @return integer
154
     */
155
    public function getEndOffset()
156
    {
157
        return $this->_endOffset;
158
    }
159
 
160
    /**
161
     * Returns this Token's lexical type.  Defaults to 'word'.
162
     *
163
     * @return string
164
     */
165
    public function getType()
166
    {
167
        return $this->_type;
168
    }
169
}
170