Īutomatically apply suggestions to the text: > tool. Print a Match object: > print ( matches ) Line 1, column 51, Rule ID : TOT_HE Message : Did you mean 'to the' ? Suggestion : to the. replacements # ('EN_A_VS_AN', ) ( 'EN_A_VS_AN', ) > matches. close () # Call `close()` to shut off the server when you're done.Ĭheck out some Match object attributes: > matches. LanguageTool ( 'en-US' ) > text = 'A sentence with a error in the Hitchhiker’s Guide tot he Galaxy' > matches = tool. correct ( s, matches ) 'Department of medicine Colombia University closed on August 1 Melinda Sam Example usageįrom the interpreter: > import language_tool_python > tool = language_tool_python. check ( s ) > matches = > language_tool_python. LanguageTool ( 'en-US' ) > matches = tool. isupper () > import language_tool_python > tool = language_tool_python. message = 'Possible spelling mistake found.' and len ( rule. In this case, spell-checking suggestions for uppercase words are ignored: > s = "Department of medicine Colombia University closed on August 1 Milinda Samuelli" > is_bad_rule = lambda rule : rule. Here is an example of generating, filtering, and applying a list of matches. If you want to decide which Match objects to apply to your text, use tool.check (to generate the list of matches) in conjunction with language_tool_ (to apply the list of matches to text). LanguageTool ( 'ca-ES', remote_server = '' ) # use a remote server API, language Catalan Apply a custom list of matches with rrect LanguageToolPublicAPI ( 'es' ) # use the public API, language Spanish Using language_tool_python with the another remote serverįinally, you're able to pass in your own remote server as an argument to the LanguageTool class: import language_tool_python tool = language_tool_python. Initialize it like this: import language_tool_python tool = language_tool_python. There is also a built-in class for querying LanguageTool's public servers. LanguageTool ( 'en-US' ) # use a local server (automatically set up), language English Using language_tool_python with the public LanguageTool remote server To use this, just initialize a LanguageTool object: import language_tool_python tool = language_tool_python. (Running locally won't have the same restrictions.) Using language_tool_python locally Follow the link for rate limiting details. However, LanguageTool also offers a Public HTTP Proofreading API that is supported as well. jar and run that in the background to detect grammar errors locally. Local and Remote Serversīy default, language_tool_python will download a LanguageTool server. This library allows you to make to detect grammar errors and spelling mistakes through a Python script or through a command-line interface. LanguageTool is open-source grammar tool, also known as the spellchecker for OpenOffice. This is a Python wrapper for LanguageTool. Language_tool_python: a grammar checker for Python □
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |