The Chinese word segmentation plug-in such as scws is quite good. I just learned it. It contains a set of rules such as proprietary names, names, place names, and digit ages. statements can be directly divided into keywords based on these rules, with an accuracy of between 90% and 95%. Follow the installation instructions to add scws extensions to the php extension directory, download the rule files and dictionary files, and reference them in the php configuration file. Then you can use scws for word segmentation.
1) Modify php extension code to support php 5.4.x
2) fixed the issue where the limit parameter of scws_get_tops in php Extensions cannot be less than 10.
3) libscws adds scws_fork () to generate branches from existing scws instances and share dictionary/rule sets. It is mainly used for multithreading development.
4) added some win32 dll extensions.
| The Code is as follows: |
Copy code |
|
<? Php
// Instantiate the core class of the Word Segmentation plug-in
$ So = scws_new ();
// Sets the encoding used for word segmentation.
$ So-> set_charset ('utf-8 ');
// Set the dictionary used for word segmentation (utf8 dictionary is used here)
$ So-> set_dict ('/path/dict. utf8.xdb ');
// Set rules for Word Segmentation
$ So-> set_rule ('/path/rules. utf8.ini ');
// Remove punctuation before word splitting
$ So-> set_ignore (true );
// Whether to perform duplex segmentation. For example, if "Chinese" is returned, the word "China + People + Chinese" is returned.
$ So-> set_multi (true );
// Set to automatically combine text with two-word segmentation
$ So-> set_duality (true );
// Statement to be segmented
$ So-> send_text ("Welcome to IT development in the fire age ");
// Obtain the word splitting result. If the frequently used word is extracted, use the get_tops method.
While ($ tmp = $ so-> get_result ())
{
Print_r ($ tmp );
}
$ So-> close ();
?>
|
Note: In the preceding example, the character sets of the input text, dictionary, and rule file must be unified. In addition, mysql 4. some XX keywords do not support full-text search. You can store the corresponding location code to facilitate full-text search.
Version list
Version platform performance others
SCWS-1.1.x C code * Unix */* PHP * accuracy: 95%, recall: 91%, speed: 1.2 MB/sec
PHP extension word splitting speed: 250KB/sec [Download] [documentation] [installation instructions]
Php_scws.dll (1) PHP extension library Windows/PHP 4.4.x accuracy: 95%, recall: 91%,
Php_scws.dll (2) PHP extension library Windows/PHP 5.2.x accuracy: 95%, recall: 91%,
Php_scws.dll (3) PHP extension library Windows/PHP 5.3.x accuracy: 95%, recall: 91%,
Php_scws.dll (4) PHP extension library Windows/PHP 5.4.x accuracy: 95%, recall: 91%,
PSCWS23 PHP source code unlimited (UTF-8 not supported) accurate: 93%, recall: 89%,
PSCWS4 PHP source code is not limited to accuracy: 95%, recall: 91%,