首页 > Web开发 > 详细

php 去除常見中文停用詞(過濾敏感詞)

时间:2018-12-03 17:47:04      阅读:181      评论:0      收藏:0      [点我收藏+]

在用sphinx通過文章標題匹配相關文章時,去除停用詞後調出的文章相關性更好。

<?php
header("Content-type:text/html;charset=utf-8"); 
$str = file_get_contents(‘stop.txt‘);//將常見中文停用詞表內容讀入到一個字串中
$badword = explode("\r\n", $str);//轉換成陣列//print_r($arr);
$badword1 =array_combine($badword,array_fill(0,count($badword),‘*‘)); //過濾敏感詞時替換成*
$bb = ‘確定安裝的PowerShell版本https://www.itread01.com/‘;
$str = strtr($bb,$badword1);
echo $str;
?>

 

来源:https://www.itread01.com/content/1543829108.html

php 去除常見中文停用詞(過濾敏感詞)

原文:https://www.cnblogs.com/codenong/p/10059738.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!