如何在PHP/SQL搜索脚本中添加拼写建议 [英] How to add spelling suggestions to PHP/SQL search script

查看:67
本文介绍了如何在PHP/SQL搜索脚本中添加拼写建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用php/sql在我的网站上创建搜索功能,这非常简单-只需在数据库上使用LIKE子句使用SELECT ALL查询,然后在页面上回显结果即可.我的问题是,如果用户输入了错误的搜索查询,我该如何添加拼写建议.除非搜索词与数据库内容完全匹配,否则MySQL不会返回任何内容,例如"Dofs"将不返回"Dogs".那么如何添加拼写建议呢?

Creating a search function on my site using php/sql, simple enough - just using a SELECT ALL query on the database using the LIKE clause and echoing the result on the page. My question is, how can I add spelling suggestions in case the user mistyped their search query. Mysql doesn't return anything unless the search term matches exactly with the database content, e.g. "Dofs" will not return "Dogs". So how can spelling suggestions be added?

谢谢.

推荐答案

接下来,您会发现Peter Norvig撰写了一篇有关如何编写拼写检查器的出色文章:

Following you will find an excellent article by Peter Norvig on how to write a spell checker:

http://www.norvig.com/spell-correct.html

以及以下两个链接是本文中找到的代码的PHP实现:

and the following two links are implementations in PHP of the code found in the article:

http://www.phpclasses.org/browse/package/4859.html http://soundofemotion.com/spellcorrect.txt

希望这会有所帮助.

这篇关于如何在PHP/SQL搜索脚本中添加拼写建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆