A StringToken Parser which gives Google Search style “Did you mean:” Suggestions

后端 未结 8 1026
-上瘾入骨i
-上瘾入骨i 2020-12-28 11:17

Seeking a method to:

Take whitespace separated tokens in a String; return a suggested Word


ie:
Google Search can take \"fon

相关标签:
8条回答
  • 2020-12-28 11:43

    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:

    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.

    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']
    
    0 讨论(0)
  • 2020-12-28 11:48

    You can use the yahoo web service here: http://developer.yahoo.com/search/web/V1/spellingSuggestion.html

    However it's only a web service... (i.e. there are no APIs for other language etc..) but it outputs JSON or XML, so... pretty easy to adapt to any language...

    0 讨论(0)
提交回复
热议问题