PHP简单实现“相关文章推荐”功能的方法
通常在做内容网站的时候,需要在每一篇文章中出现与该文章相关的文章列表。对于内容比较复杂的网站,确定关键列表词显然会比较麻烦。本文介绍了与以往方法不同的similar_text函数来方便的达到我们的预期要求。按照这个思路,我们建立如下的函数,这个函数的功能是把$arr_title数组按照同$title相似的的顺序重新排列数组。程序运行结果:有些需要关于similar_text速度,有人做过这个一个测试,结果是:The speed issues for similar_text seem to be only an issue for long sections of text .I found a huge performance improvement in my application by just testing if the string to be tested was less than 20000 chars before calling similar_text.20000+ took 3-5 secs to process, anything else took a fraction of a second. Fortunately for me, there was only a handful of instances with >20000 chars which I couldn't get a comparison % for.据说这个函数用于英文的效果不太好。