1
1
<?php
2
-
3
2
/**
4
- * This class represents a text sample to be parsed.
3
+ * Part of Text_LanguageDetect
4
+ *
5
+ * PHP version 5
5
6
*
6
7
* @category Text
7
8
* @package Text_LanguageDetect
8
- * @author Nicholas Pisarro
9
- * @copyright 2006
10
- * @license BSD
11
- * @version CVS: $Id$
9
+ * @author Nicholas Pisarro <[email protected] >
10
+ * @copyright 2006 Nicholas Pisarro
11
+ * @license BSD http://www.opensource.org/licenses/bsd-license.php
12
12
* @link http://pear.php.net/package/Text_LanguageDetect/
13
- * @link http://langdetect.blogspot.com/
14
13
*/
15
14
16
15
/**
25
24
*
26
25
* @category Text
27
26
* @package Text_LanguageDetect
28
- * @author Nicholas Pisarro
29
- * @copyright 2006
30
- * @license BSD
31
- * @version release: @package_version@
27
+ * @author Nicholas Pisarro <[email protected] >
28
+ * @copyright 2006 Nicholas Pisarro
29
+ * @license BSD http://www.opensource.org/licenses/bsd-license.php
30
+ * @version Release: @package_version@
31
+ * @link http://pear.php.net/package/Text_LanguageDetect/
32
32
*/
33
33
class Text_LanguageDetect_Parser extends Text_LanguageDetect
34
34
{
35
35
/**
36
- * the piece of text being parsed
36
+ * The piece of text being parsed
37
37
*
38
38
* @access private
39
39
* @var string
40
40
*/
41
41
var $ _string ;
42
42
43
43
/**
44
- * stores the trigram frequencies of the sample
44
+ * Stores the trigram frequencies of the sample
45
45
*
46
46
* @access private
47
47
* @var string
48
48
*/
49
49
var $ _trigrams = array ();
50
50
51
51
/**
52
- * stores the trigram ranks of the sample
52
+ * Stores the trigram ranks of the sample
53
53
*
54
54
* @access private
55
55
* @var array
56
56
*/
57
57
var $ _trigram_ranks = array ();
58
58
59
59
/**
60
- * stores the unicode blocks of the sample
60
+ * Stores the unicode blocks of the sample
61
61
*
62
62
* @access private
63
63
* @var array
@@ -99,8 +99,9 @@ class Text_LanguageDetect_Parser extends Text_LanguageDetect
99
99
/**
100
100
* Constructor
101
101
*
102
+ * @param string $string string to be parsed
103
+ *
102
104
* @access private
103
- * @param string $string string to be parsed
104
105
*/
105
106
function __construct ($ string )
106
107
{
@@ -110,8 +111,10 @@ function __construct($string)
110
111
/**
111
112
* PHP 4 constructor for backwards compatibility.
112
113
*
114
+ * @param string $string string to be parsed
115
+ *
116
+ * @return void
113
117
* @access private
114
- * @param string $string string to be parsed
115
118
*/
116
119
function Text_LanguageDetect_Parser ($ string )
117
120
{
@@ -121,8 +124,9 @@ function Text_LanguageDetect_Parser($string)
121
124
/**
122
125
* Returns true if a string is suitable for parsing
123
126
*
124
- * @param string $str input string to test
125
- * @return bool true if acceptable, false if not
127
+ * @param string $str input string to test
128
+ *
129
+ * @return bool true if acceptable, false if not
126
130
*/
127
131
public static function validateString ($ str )
128
132
{
@@ -134,80 +138,81 @@ public static function validateString($str)
134
138
}
135
139
136
140
/**
137
- * turn on/off trigram counting
141
+ * Turn on/off trigram counting
142
+ *
143
+ * @param bool $bool true for on, false for off
138
144
*
139
- * @access public
140
- * @param bool $bool true for on, false for off
145
+ * @return void
141
146
*/
142
- function prepareTrigram ($ bool = true )
147
+ public function prepareTrigram ($ bool = true )
143
148
{
144
149
$ this ->_compile_trigram = $ bool ;
145
150
}
146
151
147
152
/**
148
- * turn on/off unicode block counting
153
+ * Turn on/off unicode block counting
154
+ *
155
+ * @param bool $bool true for on, false for off
149
156
*
150
- * @access public
151
- * @param bool $bool true for on, false for off
157
+ * @return void
152
158
*/
153
- function prepareUnicode ($ bool = true )
159
+ public function prepareUnicode ($ bool = true )
154
160
{
155
161
$ this ->_compile_unicode = $ bool ;
156
162
}
157
163
158
164
/**
159
- * turn on/off padding the beginning of the sample string
165
+ * Turn on/off padding the beginning of the sample string
160
166
*
161
- * @access public
162
- * @param bool $bool true for on, false for off
167
+ * @param bool $bool true for on, false for off
168
+ *
169
+ * @return void
163
170
*/
164
- function setPadStart ($ bool = true )
171
+ public function setPadStart ($ bool = true )
165
172
{
166
173
$ this ->_trigram_pad_start = $ bool ;
167
174
}
168
175
169
176
/**
170
177
* Should the unicode block counter skip non-alphabetical ascii chars?
171
178
*
172
- * @access public
173
- * @param bool $bool true for on, false for off
179
+ * @param bool $bool true for on, false for off
180
+ *
181
+ * @return void
174
182
*/
175
- function setUnicodeSkipSymbols ($ bool = true )
183
+ public function setUnicodeSkipSymbols ($ bool = true )
176
184
{
177
185
$ this ->_unicode_skip_symbols = $ bool ;
178
186
}
179
187
180
188
/**
181
189
* Returns the trigram ranks for the text sample
182
190
*
183
- * @access public
184
- * @return array trigram ranks in the text sample
191
+ * @return array Trigram ranks in the text sample
185
192
*/
186
- function getTrigramRanks ()
193
+ public function getTrigramRanks ()
187
194
{
188
195
return $ this ->_trigram_ranks ;
189
196
}
190
197
191
198
/**
192
199
* Return the trigram freqency table
193
200
*
194
- * only used in testing to make sure the parser is working
201
+ * Only used in testing to make sure the parser is working
195
202
*
196
- * @access public
197
- * @return array trigram freqencies in the text sample
203
+ * @return array Trigram freqencies in the text sample
198
204
*/
199
- function getTrigramFreqs ()
205
+ public function getTrigramFreqs ()
200
206
{
201
207
return $ this ->_trigram ;
202
208
}
203
209
204
210
/**
205
- * returns the array of unicode blocks
211
+ * Returns the array of unicode blocks
206
212
*
207
- * @access public
208
- * @return array unicode blocks in the text sample
213
+ * @return array Unicode blocks in the text sample
209
214
*/
210
- function getUnicodeBlocks ()
215
+ public function getUnicodeBlocks ()
211
216
{
212
217
return $ this ->_unicode_blocks ;
213
218
}
@@ -221,9 +226,9 @@ function getUnicodeBlocks()
221
226
* Afterwards the get*() functions can be used to access the compiled
222
227
* information.
223
228
*
224
- * @access public
229
+ * @return void
225
230
*/
226
- function analyze ()
231
+ public function analyze ()
227
232
{
228
233
$ len = strlen ($ this ->_string );
229
234
$ byte_counter = 0 ;
0 commit comments