Recently, a project was implemented to automatically generate labels and found discuz! 3.0X has realized this function, want to ask Discuz how to realize participle and produce label. For example: http://www.playsc.com/forum/forum.php?mod=viewthread&tid=359314&extra=page%3D1 above link address tagged with: SPL, Hero, Samsung , these tags are automatically generated in the playoffs. How is this feature implemented? discuz! Where do you implement this feature?
The main is how to achieve the participle? Where is the algorithm? In particular, how is PHP implemented?
(I put discuz! Down, but only found the tag.php class inside the UpdateData ($appid, $data) function, there is no previous step word function)
Reply content:
Recently, a project was implemented to automatically generate labels and found discuz! 3.0X has realized this function, want to ask Discuz how to realize participle and produce label. For example: http://www.playsc.com/forum/forum.php?mod=viewthread&tid=359314&extra=page%3D1 above link address tagged with: SPL, Hero, Samsung , these tags are automatically generated in the playoffs. How is this feature implemented? discuz! Where do you implement this feature?
The main is how to achieve the participle? Where is the algorithm? In particular, how is PHP implemented?
(I put discuz! Down, but only found the tag.php class inside the UpdateData ($appid, $data) function, there is no previous step word function)
DZ Series has an online word breaker, the specific URI address is: "Http://keyword.discuz.com/related_kw.html?title= $subjectenc &content= $messageenc &ics=$sc[charset]&ocs=$Sc[charset] "
Take this title as an example discuz! How is the 2.5x 3.0x automatic tag system implemented? , the following is the generated URI address: http://keyword.discuz.com/related_kw.html?title=discuz!%202.5x%203.0x%E7%9A%84%E8%87%AA%E5%8A% a8tag%e7%b3%bb%e7%bb%9f%e6%98%af%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e7%9a%84%ef%bc%9f&content=discuz!% 202.5x%203.0x%e7%9a%84%e8%87%aa%e5%8a%a8tag%e7%b3%bb%e7%bb%9f%e6%98%af%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e7% The contents of the XML format are returned after the 9A%84%EF%BC%9F&ICS=UTF-8&OCS=UTF-8 request:
36000
4
0
1291287160
0
的
是
discuz
如何
The specific calling code for PHP is:
function Get_dz_tag ($subject, $message) {global $_sc; $subjectenc = Rawurlencode (Strip_tags ($subject)); $messageenc = Rawurlencode (Strip_tags (Preg_replace ("/\[.+?\]/u", ", $message))); $data = @implode ("', File (" http://keyword.discuz.com/related_kw.html?title= $subjectenc &content= $messageenc &ics=$_sc[charset]&ocs=$_sc[charset]); if ($data) {$parser = Xml_parser_create (); Xml_parser_set_option ($parser, xml_option_case_folding, 0); Xml_parser_set_option ($parser, Xml_option_skip_white, 1); Xml_parse_into_struct ($parser, $data, $values, $index); Xml_parser_free ($parser); $KWS = Array (); foreach ($values as $valuearray) {if ($valuearray [' tag '] = = ' kw ' | | $valuearray [' tag '] = = ' ekw ') { if (Php_version > ' 5 ' && $_sc[' charset ']! = ' Utf-8 ') {$KWS [] = Siconv (Trim ($va luearray[' value ']), $_sc[' CharSet '], ' utf-8 ');//??????? } else {$kws [] = Trim ($valuearray [' value ']); }}} $return = '; if ($KWS) {foreach ($kws as $kw) {$kw = Shtmlspecialchars ($kw); $return. = $kw. ' '; } $return = Trim ($return); } return $return; } }
Of course, this is just an online word breaker, of course, you can also use PHP extension to operate: such as SCWS.
SCWS has an online API and an extended version of two ways:
The API code is:
function Scws($string){ $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_URL, "http://www.ftphp.com/scws/api.php"); curl_setopt($ch, CURLOPT_POSTFIELDS, "data={$string}&respond=json"); ob_start(); curl_exec($ch); $content = ob_get_contents(); curl_close($ch); ob_clean(); $content = json_decode($content ,true); return $content; }
For specific extensions, refer to the SCWS documentation: SCWS