Php uses scws to implement mysql full-text search

Source: Internet
Author: User
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%,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.