一个StringToken解析器,它赋予Google搜索样式“您是不是要:";意见建议 [英] A StringToken Parser which gives Google Search style "Did you mean:" Suggestions
问题描述
即:
Google搜索可以使用"fonetic wrd nterpreterr" ,
结果页顶部显示您的意思是:语音单词解释器"
ie:
Google Search can take "fonetic wrd nterpreterr",
and atop of the result page it shows "Did you mean: phonetic word interpreter"
首选使用任何C *语言或Java的解决方案.
是否存在执行此类功能的现有开放库?
或者是否有一种利用Google API来请求建议单词的方法?
推荐答案
在他的文章如何编写拼写校正器,彼得·诺维格(Peter Norvig)讨论了如何实现类似Google的拼写检查器.本文包含Python的20行实现以及指向C,C ++,C#和Java的几种重新实现的链接.这是摘录:
In his article How to Write a Spelling Corrector, Peter Norvig discusses how a Google-like spellchecker could be implemented. The article contains a 20-line implementation in Python, as well as links to several reimplementations in C, C++, C# and Java. Here is an excerpt:
工业强度拼写校正器 像Google那样会更令人困惑 比启发,但我认为 在飞机上飞回家中,不到 一页代码,我可以写一个玩具 达到80或更高的拼写校正器 90%的精度,处理速度为 至少每秒10个字.
The full details of an industrial-strength spell corrector like Google's would be more confusing than enlightening, but I figured that on the plane flight home, in less than a page of code, I could write a toy spelling corrector that achieves 80 or 90% accuracy at a processing speed of at least 10 words per second.
使用Norvig的代码和此文本作为训练集,我得到以下结果:
Using Norvig's code and this text as training set, i get the following results:
>>> import spellch
>>> [spellch.correct(w) for w in 'fonetic wrd nterpreterr'.split()]
['phonetic', 'word', 'interpreters']
这篇关于一个StringToken解析器,它赋予Google搜索样式“您是不是要:";意见建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!