Skip to content

Commit e6a43e6

Browse files
committed
Fix most CS errors
1 parent f6bd5d0 commit e6a43e6

File tree

4 files changed

+96
-72
lines changed

4 files changed

+96
-72
lines changed

Text/LanguageDetect.php

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
<?php
2-
32
/**
4-
* Detects the language of a given piece of text.
5-
*
6-
* Attempts to detect the language of a sample of text by correlating ranked
7-
* 3-gram frequencies to a table of 3-gram frequencies of known languages.
8-
*
9-
* Implements a version of a technique originally proposed by Cavnar & Trenkle
10-
* (1994): "N-Gram-Based Text Categorization"
3+
* Part of Text_LanguageDetect
114
*
125
* PHP version 5
136
*
147
* @category Text
158
* @package Text_LanguageDetect
169
* @author Nicholas Pisarro <[email protected]>
1710
* @copyright 2005-2006 Nicholas Pisarro
18-
* @license http://www.debian.org/misc/bsd.license BSD
19-
* @version SVN: $Id$
11+
* @license BSD http://www.opensource.org/licenses/bsd-license.php
2012
* @link http://pear.php.net/package/Text_LanguageDetect/
21-
* @link http://langdetect.blogspot.com/
2213
*/
2314

2415
require_once 'Text/LanguageDetect/Exception.php';
2516
require_once 'Text/LanguageDetect/Parser.php';
2617
require_once 'Text/LanguageDetect/ISO639.php';
2718

2819
/**
29-
* Language detection class
20+
* Detects the language of a given piece of text.
21+
*
22+
* Attempts to detect the language of a sample of text by correlating ranked
23+
* 3-gram frequencies to a table of 3-gram frequencies of known languages.
24+
*
25+
* Implements a version of a technique originally proposed by Cavnar & Trenkle
26+
* (1994): "N-Gram-Based Text Categorization"
3027
*
31-
* Requires the langauge model database (lang.dat) that should have
28+
* Requires the language model database (lang.dat) that should have
3229
* accompanied this class definition in order to be instantiated.
3330
*
3431
* Example usage:
@@ -60,10 +57,9 @@
6057
* @package Text_LanguageDetect
6158
* @author Nicholas Pisarro <[email protected]>
6259
* @copyright 2005 Nicholas Pisarro
63-
* @license http://www.debian.org/misc/bsd.license BSD
60+
* @license BSD http://www.opensource.org/licenses/bsd-license.php
6461
* @version Release: @package_version@
6562
* @link http://pear.php.net/package/Text_LanguageDetect/
66-
* @todo allow users to generate their own language models
6763
*/
6864
class Text_LanguageDetect
6965
{
@@ -110,7 +106,7 @@ class Text_LanguageDetect
110106
var $_lang_db = array();
111107

112108
/**
113-
* stores the map of the trigram data to unicode characters
109+
* Stores the map of the trigram data to unicode characters
114110
*
115111
* @access private
116112
* @var array
@@ -126,9 +122,9 @@ class Text_LanguageDetect
126122
var $_threshold = 300;
127123

128124
/**
129-
* the maximum possible score.
125+
* The maximum possible score.
130126
*
131-
* needed for score normalization. Different depending on the
127+
* Needed for score normalization. Different depending on the
132128
* perl compatibility setting
133129
*
134130
* @access private
@@ -155,7 +151,7 @@ class Text_LanguageDetect
155151
var $_use_unicode_narrowing = true;
156152

157153
/**
158-
* stores the result of the clustering operation
154+
* Stores the result of the clustering operation
159155
*
160156
* @access private
161157
* @var array
@@ -518,7 +514,7 @@ function _arr_rank($arr)
518514
/**
519515
* Sorts an array by value breaking ties alphabetically
520516
*
521-
* @param array &$arr the array to sort
517+
* @param array $arr the array to sort
522518
*
523519
* @return void
524520
* @access private
@@ -1465,7 +1461,7 @@ public function clusteredSearch($str)
14651461
}
14661462

14671463
/**
1468-
* ut8-safe strlen()
1464+
* UTF8-safe strlen()
14691465
*
14701466
* Returns the numbers of characters (not bytes) in a utf8 string
14711467
*
@@ -1529,14 +1525,14 @@ function _utf8char2unicode($char)
15291525
}
15301526

15311527
/**
1532-
* utf8-safe fast character iterator
1528+
* UTF8-safe fast character iterator
15331529
*
15341530
* Will get the next character starting from $counter, which will then be
15351531
* incremented. If a multi-byte char the bytes will be concatenated and
15361532
* $counter will be incremeted by the number of bytes in the char.
15371533
*
15381534
* @param string $str the string being iterated over
1539-
* @param int &$counter the iterator, will increment by reference
1535+
* @param int $counter the iterator, will increment by reference
15401536
* @param bool $special_convert whether to do special conversions
15411537
*
15421538
* @return char the next (possibly multi-byte) char from $counter

Text/LanguageDetect/Exception.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
<?php
2+
/**
3+
* Part of Text_LanguageDetect
4+
*
5+
* PHP version 5
6+
*
7+
* @category Text
8+
* @package Text_LanguageDetect
9+
* @author Nicholas Pisarro <[email protected]>
10+
* @license BSD http://www.opensource.org/licenses/bsd-license.php
11+
* @link http://pear.php.net/package/Text_LanguageDetect/
12+
*/
13+
14+
/**
15+
* Part of the PEAR language detection package
16+
*
17+
* PHP version 5
18+
*
19+
* @category Text
20+
* @package Text_LanguageDetect
21+
* @author Nicholas Pisarro <[email protected]>
22+
* @license BSD http://www.opensource.org/licenses/bsd-license.php
23+
* @link http://pear.php.net/package/Text_LanguageDetect/
24+
* @link http://langdetect.blogspot.com/
25+
*/
226
class Text_LanguageDetect_Exception extends Exception
327
{
428
/**

Text/LanguageDetect/ISO639.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* @author Christian Weiske <[email protected]>
1010
* @copyright 2011 Christian Weiske <[email protected]>
1111
* @license http://www.debian.org/misc/bsd.license BSD
12-
* @version SVN: $Id$
1312
* @link http://pear.php.net/package/Text_LanguageDetect/
1413
*/
1514

@@ -23,7 +22,7 @@
2322
* @package Text_LanguageDetect
2423
* @author Christian Weiske <[email protected]>
2524
* @copyright 2011 Christian Weiske <[email protected]>
26-
* @license http://www.debian.org/misc/bsd.license BSD
25+
* @license BSD http://www.opensource.org/licenses/bsd-license.php
2726
* @link http://www.loc.gov/standards/iso639-2/php/code_list.php
2827
*/
2928
class Text_LanguageDetect_ISO639

Text/LanguageDetect/Parser.php

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
<?php
2-
32
/**
4-
* This class represents a text sample to be parsed.
3+
* Part of Text_LanguageDetect
4+
*
5+
* PHP version 5
56
*
67
* @category Text
78
* @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
1212
* @link http://pear.php.net/package/Text_LanguageDetect/
13-
* @link http://langdetect.blogspot.com/
1413
*/
1514

1615
/**
@@ -25,39 +24,40 @@
2524
*
2625
* @category Text
2726
* @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/
3232
*/
3333
class Text_LanguageDetect_Parser extends Text_LanguageDetect
3434
{
3535
/**
36-
* the piece of text being parsed
36+
* The piece of text being parsed
3737
*
3838
* @access private
3939
* @var string
4040
*/
4141
var $_string;
4242

4343
/**
44-
* stores the trigram frequencies of the sample
44+
* Stores the trigram frequencies of the sample
4545
*
4646
* @access private
4747
* @var string
4848
*/
4949
var $_trigrams = array();
5050

5151
/**
52-
* stores the trigram ranks of the sample
52+
* Stores the trigram ranks of the sample
5353
*
5454
* @access private
5555
* @var array
5656
*/
5757
var $_trigram_ranks = array();
5858

5959
/**
60-
* stores the unicode blocks of the sample
60+
* Stores the unicode blocks of the sample
6161
*
6262
* @access private
6363
* @var array
@@ -99,8 +99,9 @@ class Text_LanguageDetect_Parser extends Text_LanguageDetect
9999
/**
100100
* Constructor
101101
*
102+
* @param string $string string to be parsed
103+
*
102104
* @access private
103-
* @param string $string string to be parsed
104105
*/
105106
function __construct($string)
106107
{
@@ -110,8 +111,10 @@ function __construct($string)
110111
/**
111112
* PHP 4 constructor for backwards compatibility.
112113
*
114+
* @param string $string string to be parsed
115+
*
116+
* @return void
113117
* @access private
114-
* @param string $string string to be parsed
115118
*/
116119
function Text_LanguageDetect_Parser($string)
117120
{
@@ -121,8 +124,9 @@ function Text_LanguageDetect_Parser($string)
121124
/**
122125
* Returns true if a string is suitable for parsing
123126
*
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
126130
*/
127131
public static function validateString($str)
128132
{
@@ -134,80 +138,81 @@ public static function validateString($str)
134138
}
135139

136140
/**
137-
* turn on/off trigram counting
141+
* Turn on/off trigram counting
142+
*
143+
* @param bool $bool true for on, false for off
138144
*
139-
* @access public
140-
* @param bool $bool true for on, false for off
145+
* @return void
141146
*/
142-
function prepareTrigram($bool = true)
147+
public function prepareTrigram($bool = true)
143148
{
144149
$this->_compile_trigram = $bool;
145150
}
146151

147152
/**
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
149156
*
150-
* @access public
151-
* @param bool $bool true for on, false for off
157+
* @return void
152158
*/
153-
function prepareUnicode($bool = true)
159+
public function prepareUnicode($bool = true)
154160
{
155161
$this->_compile_unicode = $bool;
156162
}
157163

158164
/**
159-
* turn on/off padding the beginning of the sample string
165+
* Turn on/off padding the beginning of the sample string
160166
*
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
163170
*/
164-
function setPadStart($bool = true)
171+
public function setPadStart($bool = true)
165172
{
166173
$this->_trigram_pad_start = $bool;
167174
}
168175

169176
/**
170177
* Should the unicode block counter skip non-alphabetical ascii chars?
171178
*
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
174182
*/
175-
function setUnicodeSkipSymbols($bool = true)
183+
public function setUnicodeSkipSymbols($bool = true)
176184
{
177185
$this->_unicode_skip_symbols = $bool;
178186
}
179187

180188
/**
181189
* Returns the trigram ranks for the text sample
182190
*
183-
* @access public
184-
* @return array trigram ranks in the text sample
191+
* @return array Trigram ranks in the text sample
185192
*/
186-
function getTrigramRanks()
193+
public function getTrigramRanks()
187194
{
188195
return $this->_trigram_ranks;
189196
}
190197

191198
/**
192199
* Return the trigram freqency table
193200
*
194-
* only used in testing to make sure the parser is working
201+
* Only used in testing to make sure the parser is working
195202
*
196-
* @access public
197-
* @return array trigram freqencies in the text sample
203+
* @return array Trigram freqencies in the text sample
198204
*/
199-
function getTrigramFreqs()
205+
public function getTrigramFreqs()
200206
{
201207
return $this->_trigram;
202208
}
203209

204210
/**
205-
* returns the array of unicode blocks
211+
* Returns the array of unicode blocks
206212
*
207-
* @access public
208-
* @return array unicode blocks in the text sample
213+
* @return array Unicode blocks in the text sample
209214
*/
210-
function getUnicodeBlocks()
215+
public function getUnicodeBlocks()
211216
{
212217
return $this->_unicode_blocks;
213218
}
@@ -221,9 +226,9 @@ function getUnicodeBlocks()
221226
* Afterwards the get*() functions can be used to access the compiled
222227
* information.
223228
*
224-
* @access public
229+
* @return void
225230
*/
226-
function analyze()
231+
public function analyze()
227232
{
228233
$len = strlen($this->_string);
229234
$byte_counter = 0;

0 commit comments

Comments
 (0)