Php automatically obtains the keyword. Php Automatic Keyword Retrieval Method this article describes how php automatically retrieves keywords. Share it with you for your reference. The specific implementation method is as follows: Code: $ mincipin5; php automatically obtains the keyword
This example describes how php automatically obtains keywords. Share it with you for your reference.
The specific implementation method is as follows:
The code is as follows: $ mincipin = 5; // minimum word frequency
$ Minlen = 4; // minimum length of a keyword
Tiqukeyword ($ tiqustr, $ minlen, $ mincipin );
Function tiqukeyword ($ tiqustr, $ minlen, $ mincipin)
{$ Strlong = strlen ($ tiqustr );
$ Arr = array ();
$ K =-1;
For ($ I = 0; $ I <($ strlong-$ mincipin * $ minlen); $ I ++ ){
$ End = ceil ($ strlong-$ I)/$ mincipin + $ I );
For ($ j = $ minlen; $ j <$ end; $ j ++) {$ num = 0;
If ($ guanjianzi = substr ($ tiqustr, $ I, $ j ))! = False ){
$ Wz = $ I + $ j;
$ Num ++ ;}
Else {break ;}
While ($ wz <$ strlong) {if ($ wz = strpos ($ tiqustr, $ guanjianzi, $ wz ))! = False)
{$ Num ++;
$ Wz = $ wz + strlen ($ guanjianzi );}
Else break;
}
If ($ j = $ minlen ){
If ($ num >=$ mincipin) {$ maxnum = $ num; $ k ++; $ str = substr ($ tiqustr, $ I, $ j );
$ Arr [$ k] = array ($ I, $ j, $ str, $ num, 0 );
}
Else {break ;}
}
Else {
If ($ num> = $ maxnum ){
$ Maxnum = $ num;
$ Str = substr ($ tiqustr, $ I, $ j );
$ Arr [$ k] = array ($ I, $ j, $ str, $ num, 0 );
}
Else break;
}
}
}
Echo 'Preliminarily obtained array :';
Print_r ($ arr );
// Echo'
';
$ Arrlong = count ($ arr );
For ($ I = 0; $ I <$ arrlong; $ I ++ ){
$ Bjarr = $ arr [$ I];
$ Nowid = $ I;
If ($ bjarr [4] = 1) continue;
For ($ j = $ I + 1; $ j <$ arrlong; $ j ++ ){
If ($ arr [$ j] [4] = 1) continue;
$ Qujianks = $ bjarr [0];
$ Qujianjs = $ bjarr [1] + $ bjarr [0]-1;
$ A = $ arr [$ j] [0];
$ B = $ arr [$ j] [1] + $ arr [$ j] [0]-1;
If ($ bjarr [2] = $ arr [$ j] [2]) & ($ bjarr [3]> $ arr [$ j] [3]) $ arr [$ j] [4] = 1;
If ($ a <= $ qujianks & $ qujianks <= $ B & $ a <= $ qujianjs & $ qujianjs <= $ B)
{If ($ bjarr [3] <= $ arr [$ j] [3]) {
$ Arr [$ nowid] [4] = 1; $ nowid = $ j; $ bjarr = $ arr [$ j];
}
}
Elseif ($ qujianks <= $ a & $ a <= $ qujianjs & $ qujianks <= $ B & $ B <= $ qujianjs ){
$ Arr [$ j] [4] = 1;
}
}
}
Echo'
Relay the tagged array :';
Print_r ($ arr );
$ Jieguoarr = array ();
For ($ I = 0; $ I <$ arrlong; $ I ++)
{If ($ arr [$ I] [4] = 0) $ jieguoarr [] = $ arr [$ I];
}
Echo'
';
Echo 'final array :';
Print_r ($ jieguoarr );
}
I hope this article will help you with php programming.
Examples in this article describes how php automatically obtains keywords. Share it with you for your reference. The specific implementation method is as follows: Code: $ mincipin = 5; // the most...