How do I approximate “Did you mean?” without using Google?

后端 未结 7 2289
甜味超标
甜味超标 2021-01-31 10:13

I am aware of the duplicates of this question:

  • How does the Google “Did you mean?” Algorithm work?
  • How do you implement a “Did you mean”?
  • ... and
7条回答
  •  天命终不由人
    2021-01-31 10:37

    @Legend - Consider using one of the variations of the Soundex algorithm. It has some known flaws, but it works decently well in most applications that need to approximate misspelled words.


    Edit (2011-03-16):

    I suddenly remembered another Soundex-like algorithm that I had run across a couple of years ago. In this Dr. Dobb's article, Lawrence Philips discusses improvements to his Metaphone algorithm, dubbed Double Metaphone.

    You can find a Python implementation of this algorithm here, and more implementations on the same site here.

    Again, these algorithms won't be the same as what Google uses, but for English language words they should get you very close. You can also check out the wikipedia page for Phonetic Algorithms for a list of other similar algorithms.

提交回复
热议问题