I want to add a low-level keyword function for a php applet, just like the word segmentation effect when the php applet is easy to collect. for example, the title is: I have never seen Altman's automatic word segmentation result: I have never | ever | AO | OT | man I tried php's segmentation function myself, however, the split is a very painful array. if you are depressed, please give me some advice! I did not have a basic php, but I just read a little introduction! I thought like this $ title. I never saw the php split title and saved it to the code in a field.
I want to add a low-level keyword function for a php applet, just like the word segmentation effect when it is easy to collect. for example, the title is: I have never seen Altman.
The result of automatic word segmentation is: I have never | never seen | ever | Aote | man
I tried the segmentation function of php myself, but it is a painful array after the segmentation. I'm depressed. please give me some advice!
I did not have a basic php, but I just read a little introduction!
I think so.
$ Title = I have never met Altman
$ Keyword = str_split ($ title, 1 );
However, the split is an array, and the split seems to be changed to: me | from | not | see | past | Austria | Te | man
How can we generate results like automatic keyword generation for easy collection!
------ Solution --------------------
First. Note that it is UTF-8 encoded.
PHP code
$ Title = 'I have never seen Altman'; $ len = mb_strlen ($ title, 'utf-8'); $ l = 0; while ($ l <$ len-1) {$ arr [] = mb_substr ($ title, $ l, 2, 'utf-8'); $ l ++;} echo join ('|', $ arr );
------ Solution --------------------
You can install SCWS Chinese word segmentation system, which is available in Windows and linux and can be used as an extension of php. After the installation, use phpinfo to check whether scws is successful.
Example:
$ Sh = scws_open ();
Scws_set_charset ($ sh, 'gbk ');
Scws_set_multi ($ sh, SCWS_MULTI_SHORT | SCWS_MULTI_DUALITY | SCWS_MULTI_ZMAIN | SCWS_MULTI_ZALL );
$ Text = "I have never met Altman ";
Scws_send_text ($ sh, $ text );
$ Top = scws_get_tops ($ sh, 10 );
Print_r ($ top );