【发布时间】:2016-05-06 15:51:21
【问题描述】:
我正在尝试使用类似于 Google 的“您的意思是:”的系统使用 PHP 对用户查询应用拼写检查。
有没有办法通过插件或 API 做到这一点?如果没有,您有什么建议?
可能的简化代码?
API
<?php
function checkSpelling($query) {
//Boolean where false value means a word is spelt wrong in string
return file_get_contents("http://foo.com/?q=$query");
}
function getSuggestions($query) {
//data with suggestions for word
return file_get_contents("http://foo.com/?q=$query");
}
if (!checkSpelling(foo)) {
echo getSuggestions(foo);
}
?>
插件
<?php
require("plugin.php");
//plugin functions similar to the functions above are defined already
if (!checkSpelling(foo)) {
echo getSuggestions(foo);
}
?>
注意:Pspell 不是一个选项,因为我有 PHP 5.X.X 并且无法在服务器上安装它。
注意:PHP Spell Check 没有 disired 接口。
【问题讨论】:
-
这是一个非常好的问题,但我认为这个数据/API 不会是免费的,因为数据挖掘这些信息需要大量时间 + 使用最快的算法来提取它。即使您收集了数据,也很难像 Google 的响应一样快速(甚至缓存)。
标签: php google-search spell-checking