I am using this file to check the grammar of the document in an Android application but it gives me error message in the language tool. I am using tool = language_check.LanguageTool('en-US')
tool to check the grammar. The error message image in given below
import language_check
from nltk.tokenize import sent_tokenize
matches=list()
def main(location):
# matches.clear()
mistake=0
path=location
uploaded_sentence=open(path).read()
#uploaded_sentence=path
tool = language_check.LanguageTool('en-US')
sent_text = sent_tokenize(uploaded_sentence)
for sent in sent_text:
#first letter of the sentence is capital
doc=sent.capitalize()
matches=(tool.check(doc))
# print(len(matches))
print(sent ,"\n"," mistakes that are in this sentence = ",len(matches),'\n')
print("type of the mistake that is done","\n ",matches,'\n')
# one of the method for the count grammar mistakes here
# if the mistakes are more than one or one it add only 1
# if len(matches)!=0:
# mistake=mistake+1
# the other method for the grammar mistake count
# here if the mistakes are more than one or one it will add the number of the mistakes
if (len(matches))>0:
mistake=mistake+(len(matches))
print("total number of the mistakes that are done =",mistake)
return(mistake)
From https://github.com/chaquo/chaquopy/issues/397: