- Before making data available to wider audience its always better to add a check for the key columns to ensure that the spelling is correct.
- In case if any word is wrongly spelled, then there should be one option to get the correct spelling for the same.
Mandatory library needed for this operation:
- It is important to check the spelling while text processing and analysis. The python package pyspellchecker provides us this feature to find the words that may have been mis-spelled and also suggest the possible corrections.
First we need to install pyspellchecker using following command.
%sh pip install pyspellchecker
and then run the following code in next cell.
from spellchecker import SpellChecker spell = SpellChecker()
Now, pass the words like
misspelled = spell.unknown(['something', 'is', 'hapenning', 'here'])
To find the correction for the mis-spelled word :
for word in misspelled: # Get the one `most likely` answer print(spell.correction(word))
To find the most likely or suggested word for the mis-spelled word :
# Get a list of `likely` options print("Likely word for",word ,"is ",spell.candidates(word))