Discussion on automatic construction of high correlation internal chain method

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

The importance of the inner chain I don't need to tell you all about it. The correlation of inner chain (same as outside chain) is an important index. Taking the Discuz program as an example, this paper discusses how to use Coreseek Full-text search system to construct high correlation inner chain.

I. Status QUO

Now the automatic production chain generally has two methods: one is by inserting the same tag in the chain, the second is to specify the keyword, in the article encountered the corresponding key words are automatically inserted inside the chain of methods to do the chain.

However, the two methods have shortcomings, the former method if the automatic generation of tag, often with a large number of the generation of tag, correlation can not be guaranteed, if the manual set tag is a long-term very cumbersome work; the latter method to manually preset keywords, one tedious, Secondly, the key without a preset will not automatically generate the inner chain, typos this method

In general, it is necessary to encounter the corresponding keywords to generate the same internal chain correlation is not necessarily high.

Disuz's own related post functions are also divided into two kinds. One is the implementation of the tag, there are the shortcomings mentioned above; another for the vertical and horizontal search belt, but pit dad is this related posts are implemented with JavaScript, for SEO basic useless.

Second, how to automatically generate a high degree of correlation within the chain?

First of all to solve the problem of how to determine the degree of correlation. We can use the title of the target article to the database with the existence of the article title or the full text of similar levenshtein algorithms to compare, find the correlation of the first or several to do the chain, rather than simply capture a specific keyword or tag.

As far as I know Coreseek Full-text search system based on phrase similarity and statistics (BM25) Composite ranking method, can easily and efficiently realize such a function, we can easily use, have the ability to write their own program to achieve.

Three, the following take Discuz as an example to illustrate how to achieve.

Ideas are as follows: Whenever the post is accessed automatically take the title of the posts to Coreseek search, to find a high degree of matching articles. Then add the link to the post that you found.

1, first of all, the correct installation of Coreseek, installation methods can refer to the official website or my web site Four Seasons Clothing network WWW#4JI#CN find << set up discuz under the Coreseek full-text Search server and the construction of personalized word library >> this person post. Installation looks very complicated, in fact, installation is not difficult, follow the tutorial step by step.

2, write a discuz plug-in to achieve the above mentioned functions:

Do not know how to program the first sweat, Plug-ins have been written, the following will give a download link.

Here only about the working principle of plug-ins is: discuz template inside put a lot of hook hooks, here we use Viewthread_postbottom, open the post, Viewthread_postbottom trigger the corresponding method in the plug-in, This method takes the title of the post to Coreseek search, to find the article with high matching degree.

Then add the link to the post that you found.

Iv. Main Source code

Due to limited capacity, procedures may not be perfect, please correct me.

&lt;?php





/**


* A class of related aspires for discuz! X2 &amp; X2.5


* @author D2002


* Copyright @ http://www.4ji.cn


*/








class Plugin_dean_related_article {


function Plugin_dean_related_article () {


Global $_g;


$this-&gt;display_qty = $_g[' cache ' [' plugin '] [' dean_related_article '] [' display_qty '];


$this-&gt;weight = $_g[' cache '] [' plugin '] [' dean_related_article '] [' weight '];


$this-&gt;index = $_g[' cache ' [' plugin '] [' dean_related_article '] [' index '];


}








}








class Plugin_dean_related_article_forum extends Plugin_dean_related_article {


Public Function Viewthread_postbottom_output () {


Global $_g;


require_once libfile (' Class/sphinx ');


$s = new sphinxclient ();


$s-&gt;setserver ($_g[' setting '] [' sphinxhost '], intval ($_g[' setting '] [' sphinxport ']);


$s-&gt;setmaxquerytime (intval ($_g[' setting '] [' sphinxmaxquerytime ']);


$s-&gt;setrankingmode ($_g[' setting '] [' Sphinxrank ']);


$s-&gt;setlimits (0, $this-&gt;display_qty, $this-&gt;display_qty);


$s-&gt;setmatchmode (sph_match_any);





$subject = mb_convert_encoding ($_g[' forum_thread '] [' subject '], ' UTF-8 ', ' GBK ');


$ori _tid = $_g[' forum_thread ' [' tid '];


if ($this-&gt;index==1) $result = $s-&gt;query ($subject, $_g[' setting '] [' sphinxsubindex ']);


else $result = $s-&gt;query ($subject, "*");


$tids = Array ();


if ($result) {


if (Is_array ($result [' matches ']) {


foreach ($result [' matches '] as $value) {


if ($value [' attrs '] [' tid ']&amp;&amp; $value [' attrs '] [' tid ']!= $ori _tid&amp;&amp; $value [' Weight ']&gt;= $this- &gt;weight) {


$tids [$value [' attrs '] [' tid ']] = $value [' attrs '] [' tid '];


}


}


}


}





//return $tids;


$out = "&lt;div id= ' relate_subject ' &gt;&lt;div class= ' rs_main ' &gt;&lt;div class= ' rs_head ' &gt;&lt;h3 class=" Has_ Adv ' &gt; Related posts &lt;/h3&gt;&lt;/div&gt;;


$out. = "&lt;ul id= ' rel_list ' &gt;";


if (!empty ($tids)) {


$ids = Implode (",", $tids);


$query = db::query (select Tid,subject from). Db::table (' Forum_thread '). " WHERE tid in ($ids) and displayorder&gt;= ' 0 ' ORDER by tid DESC ");


while ($thread = Db::fetch ($query)) {





$threadlist [$thread [' Tid ']]= $thread;


}


$flag = 1;


foreach ($threadlist as $th) {


if ($flag ==1) {


$out. = "&lt;li class= ' Right_item ' &gt;";


$flag = 0;


}else{


$out. = "&lt;li class= ' Left_item ' &gt;";


$flag = 1;


}


$out. = "&lt;a href= ' thread-$th [tid]-1.html ' &gt; $th [subject]&lt;/a&gt;&lt;/li&gt;";


}


}else{


return Array ();


}





$out. = "&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;";


Return Array ($out);





}





}


?&gt;

Five

This article is just a construction of the idea of the chain, spread out, this method can easily be used in a variety of programs, and even can be used across stations. I hope I can help you.

Six

Because the plug-in without rigorous testing, and need to install Coreseek as a prerequisite, so not in the Discuz application website. If you need to be available to my website Four Seasons clothing network http://www#4ji#cn/thread-9326-1.html free download Full installation package

This article by the Four Seasons clothing net original, reprint please retain the copyright

Related Article

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.