Php uses scws to implement mysql full-text search ,. Php uses scws to implement mysql full-text search. This article describes how php uses scws to implement mysql full-text search. Share it with you for your reference. The specific method is as follows: php uses scws to implement mysql full-text search,
This example describes how php uses scws to implement full-text mysql search. Share it with you for your reference. The specific method is as follows:
The Chinese word segmentation plug-in such as scws is quite good. I simply learned about it. it contains a set of rules such as proprietary names, names, place names, and digit ages, you can directly split the statements into keywords based on these rules. The accuracy is between 90% and 95%. according to the installation instructions, place the scws extension in the php extension directory and download the rule file and dictionary file, and reference them in the php configuration file, 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 PHP instance code is as follows:
The code is as follows:
<? 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:For example, in the preceding example, the character sets of the input text, dictionary, and rule file must be unified. In addition, mysql 4. XX some do not support full-text search in Chinese. you can store the location code corresponding to the keyword 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%,
I hope this article will help you with php programming.
Examples: This article describes how php uses scws to implement full-text mysql search. Share it with you for your reference. The specific method is as follows :...