有各种各样的Web服务提供自动校对和语法检查。有些有一个Python库来简化查询。
据我所知,大多数工具(当然是在截止日期和语言工具之后)都是基于规则的。将选中的文本与描述常见错误的大量规则进行比较。如果规则匹配,软件将其称为错误。如果规则不匹配,则软件不执行任何操作(它无法检测没有规则的错误)。import ATD
ATD.setDefaultKey("your API key")
errors = ATD.checkDocument("Looking too the water. Fixing your writing typoss.")
for error in errors:
print "%s error for: %s **%s**" % (error.type, error.precontext, error.string)
print "some suggestions: %s" % (", ".join(error.suggestions),)
预期产量:grammar error for: Looking **too the**
some suggestions: to the
spelling error for: writing **typoss**
some suggestions: typos
可以在自己的计算机上运行服务器应用程序,建议使用4 GB RAM。>>> import language_check
>>> tool = language_check.LanguageTool('en-US')
>>> text = 'A sentence with a error in the Hitchhiker’s Guide tot he Galaxy'
>>> matches = tool.check(text)
>>> matches[0].fromy, matches[0].fromx
(0, 16)
>>> matches[0].ruleId, matches[0].replacements
('EN_A_VS_AN', ['an'])
>>> matches[1].fromy, matches[1].fromx
(0, 50)
>>> matches[1].ruleId, matches[1].replacements
('TOT_HE', ['to the'])
>>> print(matches[1])
Line 1, column 51, Rule ID: TOT_HE[1]
Message: Did you mean 'to the'?
Suggestion: to the
...
>>> language_check.correct(text, matches)
'A sentence with an error in the Hitchhiker’s Guide to the Galaxy'
也可以私下运行服务器端。
另外,this是Ginger的一个黑库(screen scraping),可以说是最完善的免费语法检查选项之一。
Microsoft Word
应该可以编写Microsoft Word脚本并使用其语法检查功能。
更多