Natural Language Processing

Spelling Recommender With NLTK

We provide examples of Spelling Recommendations based on two different methods

George Pipis
3 min readOct 20, 2020

--

Image by Predictive Hacks

Spelling Recommender

We showed how you can build an autocorrect based on Jaccard distance by returning also the probability of each word. We will create three different spelling recommenders, that each takes a list of misspelled words and recommends a correctly spelled word for every word in the list. For every misspelled word, the recommender should find the word in correct_spellings that has the shortest distance and starts with the same letter as the misspelled word, and return that word as a recommendation.

As a dictionary of correct words, we will consider the `words` from NTLK

Note: Each of the two different recommenders will use a different distance measure.

For our example, we will consider the following misspelled words:

  • spleling
  • mispelling
  • reccomender

Jaccard distance on the 2 Q-Grams of the two words

The Jaccard distance, which measures dissimilarity between sample sets, is complementary to the Jaccard…

--

--

George Pipis

Sr. Director, Data Scientist @ Persado | Co-founder of the Data Science blog: https://predictivehacks.com/