Build your own Grammarly in Python | by Satyam Kumar | Towards Data Science

Usage of good grammar and correctly spelled words helps you to write and communicate clearly and get what you want. Whether you are working on an article, essay, or email, presenting your ideas with clear and correct language makes a good impression on your readers. Often while typing emails, essays, articles, etc one makes a lot of grammatical and spelling mistakes.
Grammarly is an American-based technology company that provides an AI and NLP-based digital writing assessment tool. It comes up with a lot of free and paid tools including grammar checkers, spell checkers, writing assistance, etc. In this article, we will use an open-sourced package gingerit to implement a model that can correct spellings and grammatical mistakes in the text.
GingerIt is an open-sourced Python package that is a wrapper around gingersoftware.com API. Ginger is AI-powered writing assistance that can correct spelling and grammatical mistakes in your text based on the context of the complete sentence.
Used this package you can:
Eliminate Grammatical Mistakes
Fix spelling mistakes
Correct punctuation errors
Enhance your writing
This package is not exactly a clone of Grammarly but can be considered as a basic version of it, as it provides some common features. For now, gingerit works only with the English language.
Spell checkers run various algorithms to correct the typos. This algorithm follows:
First, it scans the text to token out individual or pair of words.
It comes to the tokens/words with a list of words in the dictionary.
If the words don’t match with any words, then it runs an edit distance algorithm to suggest the closest words or list of words.
Similar to spell-checking algorithms, a grammar checker algorithm also extract a sentence from the text and checks each word against the sentence, looking at information such as parts of speech according to placement within the sentence. Also relying on several rules the algorithm detects an error in tense agreement, number, word order, and so on.
Gingerit can be installed from PyPl using the following command:
pip install gingerit
After installing and importing the gingerit package, it can be used to correct the grammatical and spelling mistakes of the given input text.
Pass the text to parse() function from gingerit package, it returns a dictionary of outputs with keys as: ‘corrections’, ‘text’, ‘result’.
Value of the corresponding keys:Corrections: List of mistakes in dictionary format as starting index, mistaken text, corrected text, the definition of the corrected text.Text: Original TextResult: Corrected text free from grammatical and spelling mistakes
From the above code snippet, it is observed that an incorrect statement is corrected using the gingerit package.
In this article, we have implemented a basic version of grammar and spell checker using open-sourced Python package. The results of the gingerit package are not up to the mark, as it works correcting spelling mistakes and correcting minor grammatical mistakes. Gingerit is a wrapper around gingersoftware.com API, which is a paid version, that may give good results in correcting grammatical mistakes.
language_tool is another open-sourced packages that work very similar to the gingerit package.
Thank You for Reading