In this section, you’ll continue to build the rest of the spell corrector. Till now, you’ve seen how to build the functions edits_ one(),edits_ two(), known(), possible_ corrections() and prob(). Let’s understand all these functions in more depth by taking a look at their outputs.
Now, we’re almost done building the spell corrector. You just need to put all the pieces of the code together and wrap them up in a new function that uses all the functions created till now. In the following video, Krishna creates the final function that you’ll use for spelling correction.
There you go! You have successfully created a pretty good spelling corrector. You can now use it to correct the spelling of any given text corpus such as the spam dataset where there were a lot of misspellings.
To use the spell corrector that you just finished building, you could import the spell corrector using the following command:
from spell_corrector import rectify
correct = rectify("laern")
print(correct)
But make sure that you place the following file in your working directory to make sure that you don’t get an error while importing the function.
In the next section, you’ll learn about a metric called the pointwise mutual information (PMI) which will help you tokenise terms that comprise of more than a word.