问题描述
寻求一种方法:
在字符串中取空格分隔的标记;返回建议词
即:
Google 搜索可以采用fonetic wrd nterpreter",
并在结果页面的顶部显示您的意思是:音标解释器"
首选使用任何 C* 语言或 Java 的解决方案.
是否有任何现有的开放图书馆可以执行此类功能?
或者有没有办法利用 Google API 来请求建议词?
在他的文章 How to Write aSpelling Corrector,Peter Norvig 讨论了如何实现类似 Google 的拼写检查器.本文包含一个用 Python 编写的 20 行实现,以及指向多个用 C、C++、C# 和 Java 重新实现的链接.摘录如下:
一个完整的细节工业强度拼写校正器像谷歌的会更混乱比启发,但我认为在回家的飞机上,在不到一页代码,我可以写一个玩具拼写校正器达到 80 或90% 的准确率,处理速度为每秒至少 10 个单词.
使用 Norvig 的代码和本文 作为训练集,我得到以下结果:
>>>导入拼写>>>[spellch.correct(w) for w in 'fonetic wrd nterpreter'.split()]['语音','单词','翻译']Seeking a method to:
Take whitespace separated tokens in a String; return a suggested Word
ie:
Google Search can take "fonetic wrd nterpreterr",
and atop of the result page it shows "Did you mean: phonetic word interpreter"
A solution in any of the C* languages or Java would be preferred.
Are there any existing Open Libraries which perform such functionality?
Or is there a way to Utilise a Google API to request a suggested word?
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:
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 搜索样式“您的意思是:"建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!