This article mainly introduces how php uses scws to implement mysql full-text search. It is a very practical technique to implement MySQL full-text search through extension of scws word segmentation plug-in, for more information about how php uses scws to implement mysql full-text search, you can use scws extension to implement MySQL full-text search, it is a very practical technique. For more information, see
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:
Set_charset ('utf-8'); // sets the dictionary used for word segmentation (utf8 dictionary is used here) $ so-> set_dict ('/path/dict. utf8.xdb '); // sets the rule for word segmentation $ so-> set_rule ('/path/rules. utf8.ini '); // remove the punctuation mark $ so-> set_ignore (true) before word segmentation; // whether to perform multiple segmentation, for example, "Chinese" returns the word "China + People + Chinese. $ So-> set_multi (true); // set to automatically aggregate text by two-word segmentation $ so-> set_duality (true ); // statement $ so-> send_text ("Welcome to IT development in the fire age"); // obtain the word segmentation result, if you use the get_tops method to extract frequently used words 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%,