PHP uses SCWS to implement the MySQL full-text search function method,
In this paper, the method of using SCWS to realize MySQL full-text search function is described. Share to everyone for your reference. Here's how:
Scws Such a good Chinese word-breaker, a simple study, it includes a number of proprietary names, names, place names, digital age and other rules set, you can directly separate the statements according to these rules into a keyword, accuracy rate between 90%-95%, Follow the installation instructions to put the SCWS extension into the php extension directory, download the rules and dictionary files, and reference them in the PHP configuration file, you can use SCWS to do participle.
1) Modify PHP extension code to support PHP 5.4.x
2) fixed an issue where the limit parameter of scws_get_tops in PHP extension does not allow less than 10
3) LIBSCWS add scws_fork () to generate branches from existing SCWS instances and share dictionary/rule sets, primarily for multithreaded development.
4) Added partial version of Win32 DLL extension
The PHP instance code is as follows:
Copy the Code code as follows: <?php
Instantiation of the word breaker core class
$so = Scws_new ();
To set the encoding used for word breakers
$so->set_charset (' utf-8 ');
Set up a dictionary for word breakers (use UTF8 dictionary here)
$so->set_dict ('/path/dict.utf8.xdb ');
Set rules for word breakers
$so->set_rule ('/path/rules.utf8.ini ');
Remove punctuation before participle
$so->set_ignore (TRUE);
Whether the duplex division, such as "Chinese" returned "Chinese + people + Chinese" three words.
$so->set_multi (TRUE);
Set text to be automatically aggregated by Word segmentation
$so->set_duality (TRUE);
The statement to be participle
$so->send_text ("Welcome to the Mars era IT development");
Get Word segmentation results, if extracting high frequency words with Get_tops method
while ($tmp = $so->get_result ())
{
Print_r ($TMP);
}
$so->close ();
?>
Note: as the above example, the input text, dictionaries, rules file the character set must be unified, in addition to MySQL 4.XX some do not support Chinese full-text search, can be stored in the keyword corresponding to the location code to facilitate full-text search .
Version List
Version type platform performance other
scws-1.1.x C Code *unix*/*php* Accurate: 95%, recall: 91%, Speed: 1.2mb/sec
PHP Extended word breaker speed: 250kb/sec [download] [documentation] [Installation instructions]
Php_scws.dll (1) PHP extension library windows/php 4.4.x accurate: 95%, recall: 91%,
Php_scws.dll (2) PHP extension library windows/php 5.2.x accurate: 95%, recall: 91%,
Php_scws.dll (3) PHP extension library windows/php 5.3.x accurate: 95%, recall: 91%,
Php_scws.dll (4) PHP extension library windows/php 5.4.x accurate: 95%, recall: 91%,
PSCWS23 PHP Source code Unlimited (not supported UTF-8) accurate: 93%, recall: 89%,
PSCWS4 PHP Source code Unlimited Accurate: 95%, recall: 91%,
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/932474.html www.bkjia.com true http://www.bkjia.com/PHPjc/932474.html techarticle PHP uses SCWS to realize the MySQL full-text search function method, this article explains the PHP use Scws realizes the MySQL full-text search function method. Share to everyone for your reference. The specific method is as follows: ...