Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Grammar Checker in Python using Language-check

  • Last Updated : 10 May, 2020

Python is an open-source programming language. It offers a vast variety of libraries that provide greater functionalities. The one such library is language_check. The language_check library doesn’t come bundled with Python 3. Instead, you have to manually download it from the command line or download it from the and then install it manually.


To install via pip:

$ pip install --upgrade language-check

If you are using Python 2, you’ll need to install 3to2 beforehand:

$ pip install --upgrade 3to2


  • Python v3.3+ (or 2.7)
  • Java v6.0 or higher.

The language_check specifies the mistakes along with Rule Id, Message, Suggestion, and line number in the document. Also using this we can directly correct the mistakes in the file only. It points out the mistakes accurately but it doesn’t guarantee 100% success in finding mistakes. Sometimes it may happen that it misses out some important mistake. So relying on it completely is not advisable.

Below python code demonstrates the use of language_check on Text Document.

import language_check
# Mention the language keyword
tool = language_check.LanguageTool('en-US')
i = 0
# Path of file which needs to be checked
with open(r'transcript1.txt', 'r') as fin:  
    for line in fin:
        matches = tool.check(line)
        i = i + len(matches)     
# prints total mistakes which are found 
# from the document
print("No. of mistakes found in document is ", i)
# prints mistake one by one 
for mistake in matches:

Output :

No. of mistakes found in document is 3

Message: This sentence does not start with an uppercase letter
Suggestion: So
so as you can see buying a new car doesn’t…

Line 1, column 102, Rule ID: ENGLISH_WORD_REPEAT_RULE
Message: Possible typo: you repeated a word
Suggestion: research
…ing if you’ll follow three simple steps research research research read and find out everything y…

Line 1, column 1025, Rule ID: MORFOLOGIK_RULE_EN_US
Message: Possible spelling mistake found
Suggestion: speech; spec; specs; speck; spec h
…unny way to start the speech and in the spech and now use the listener knew that I’m …

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!