PHP/Python/C/C++库/应用程序来匹配/纠正/提供输入建议
我想要一个简单的 & PHP/Python/C/C++ 中的轻量级库/应用程序用于匹配/纠正/提供输入建议。输入/输出示例:
- 输入:Webdevelopment ==>输出:Web 开发
- 输入:Web 开发 ==>输出:Web 开发
- 输入:Web 开发 ==>输出:Web 开发
鉴于有正确单词和短语的数据库,我只需要该库来匹配/猜测短语。有知道的请推荐一下。
I'd like to have a simple & lightweight library/application in PHP/Python/C/C++ library/application to match/correct/give suggestions to input. Example in/out:
- Input: Webdevelopment ==> Output: Web Development
- Input: Web developmen ==> Output: Web Development
- Input: Web develop ==> Output: Web Development
Given there is database of correct words and phrases, I just need the library to match/guess phrases. Please suggest if you know any.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Google 研究总监 Peter Norvik 的如何编写拼写校正器包含 21 行拼写校正器Python 的,完整的解释。
您必须自己将其转换为模块,但这应该很容易。当然,您还需要一个语料库(即单词),但他也提供了这些资源。
How to Write a Spelling Corrector from Google's Director of Resarch Peter Norvik contains a spelling corrector in 21 lines of Python, complete with explanations.
You will have to convert this into a module yourself, but that should be easy. Of course, you will also need a corpus (i.e. words), but he gives sources for these as well.
我想你想要做的是计算字符串(输入、输出对)之间的编辑距离。
其中一个比较简单的名称(我用它来从 3 个字母的短名称中找出团队的全名 - 这是一个很长的故事..)是 Levenshtein 距离。页面上的最后一个外部链接有一堆不同的实现(事实证明它是 PHP 4.0.1+ 上的标准)。
I guess what you want to do is compute the edit distance between strings (an input, output pair).
One of the simpler ones (that I've used for figuring out a team's full name from it's 3 letter short one - it's a long story..) is the Levenshtein distance. The last external link on the page has a bunch of different implementations of it (turns out it's standard on PHP 4.0.1+).