gpt4 book ai didi

python - chaquopy 中的语言检查工具

转载 作者:行者123 更新时间:2023-12-05 00:03:06 29 4
gpt4 key购买 nike

我正在使用这个文件来检查 Android 应用程序中文档的语法,但它在语言工具中给了我错误消息。我正在使用 tool = language_check.LanguageTool('en-US')检查语法的工具。下面给出的错误消息图像

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)

Language tool error

最佳答案

来自 https://github.com/chaquo/chaquopy/issues/397 :

language_check works by running the LanguageTool JAR in a separate Java process and communicating with it over a pipe. Unfortunately Android devices don't come with a Java executable or any other way of executing a JAR, so there's no way language_check can work on Android without significant changes.

An alternative solution might be to download the LanguageTool JAR to your project's libs directory, so it'll be compiled into your app along with the rest of your Java code. Then you can call it directly from Java, or from Python using the Chaquopy Python API.

See the language_check source code and the LanguageTool documentation for more details.

关于python - chaquopy 中的语言检查工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67413444/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com