免费开源语法和拼写检查器。

grammarbot的Python项目详细描述


格莱马特PY

语法机器人提供拼写和语法检查。在注册API密钥 https://www.grammarbot.io/用于增加使用限制。api仍然有效 没有密钥,但每日使用限制较低。

安装

pip install grammarbot

用法

请参见下面的示例

# import the client libraryfromgrammarbotimportGrammarBotClient# Creating the client# ===================client=GrammarBotClient()# or, signup for an API Key to get higher usage limits here: https://www.grammarbot.io/client=GrammarBotClient(api_key='my_api_key_here')# GrammarBotClient(api_key=my_api_key_here)# you can even set the base URI to a different serverclient=GrammarBotClient(base_uri='http://backup.grammarbot.io:80')# Analyzing the text# ==================# There is only one method to perform the analysis, viz. GrammarBotClient.check# method.text='I cant remember how to go their'# check the text, returns GrammarBotApiResponse objectres=client.check(text)# GrammarBotApiResponse(matches=[GrammarBotMatch(offset=2, length=4, rule={'CANT'}, category={'TYPOS'}), GrammarBotMatch(offset=26, length=5, rule={'CONFUSION_RULE'}, category={'TYPOS'})])# Inspecting the GrammarBotApiResponse object# ===========================================# check detected languageres.detected_language# "en-US"# check if the result is incompleteres.result_is_incomplete# False# see the suggestions / corrections suggested by the GrammarBot API# returns a list of GrammarBotMatch objects describing each replacementres.matches# [GrammarBotMatch(offset=2, length=4, rule={'CANT'}, category={'TYPOS'}), GrammarBotMatch(offset=26, length=5, rule={'CONFUSION_RULE'}, category={'TYPOS'})]# Inspecting the GrammarBotMatch object# =====================================match0=match[0]# GrammarBotMatch(offset=2, length=4, rule={'CANT'}, category={'TYPOS'})# get replacement informationmatch0.replacement_offset# 2match0.replacement_length# 4# get suggested replacementsmatch0.replacements# ["can't", 'cannot']# get list of possible correct sentences after applying the replacementsmatch0.corrections# ["I can't remember how to go their", 'I cannot remember how to go their']# get the rules, type and category information of the matchmatch0.rule# 'CANT'match0.category# 'TYPOS'match0.type# 'Other'# getting a friendly message regarding the replacement suggestionmatch0.message# 'Did you mean "can\'t" or "cannot"?'# Getting even more information# =============================# if the information provided by the class properties is not enough, you can# always access the complete original JSON response from GrammarBotApiResponse# objectres.raw_json

API文档

您可以在这里看到api文档:https://grammarbot-py.readthedocs.io/en/latest/

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Spring Hibernate NoClassDefFoundError CurrentSessionContext   Java中的While循环不会对文档的最后一行执行操作   java如何禁用javafx窗口   java有哪种方法的功能与retain all相反?   统计Java基于箱线图生成随机数   Java:PropertyResourceBundle   java编译/捕获异常   日志记录如何使用java log4j将日志文件保存在monthwise文件夹中?   气泡排序Java气泡排序   java无法使用无服务器本地调用AWS Lambda   java在更新JLabel文本时遇到问题;与Netbeans 6.9的GUI生成器相关   java自动设置一个类中的所有字段(private)   java将列表<BuffereImage>转换为图像