Python chaquopy中的语言检查工具
我正在用这个文件检查Android应用程序中文档的语法,但它在语言工具中给了我错误消息。我正在使用Python chaquopy中的语言检查工具,python,android,chaquopy,languagetool,Python,Android,Chaquopy,Languagetool,我正在用这个文件检查Android应用程序中文档的语法,但它在语言工具中给了我错误消息。我正在使用tool=language\u check.LanguageTool('en-US')tool检查语法。下面给出了错误消息图像 import language_check from nltk.tokenize import sent_tokenize matches=list() def main(location): # matches.clear() mistake=0
tool=language\u check.LanguageTool('en-US')
tool检查语法。下面给出了错误消息图像
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)
来自:
语言检查通过在单独的Java进程中运行LanguageTool JAR并通过管道与之通信来工作。不幸的是,Android设备没有Java可执行文件或任何其他执行JAR的方式,因此如果没有重大更改,语言检查无法在Android上工作
另一种解决方案可能是将LanguageTool JAR下载到项目的libs目录,这样它将与其余Java代码一起编译到应用程序中。然后您可以直接从Java调用它,或者使用
有关更多详细信息,请参阅和