pythonnlpgrammar

ModuleNotFoundError: No java install detected. Please install java to use language-tool-python


I would like to check the number if issues in a given sentence.

my code is

import language_tool_python
tl = language_tool_python.LanguageTool('en-US')

txt = "good mooorning sirr and medam my namee anderen i am from amerecia !"
m = tl.check(txt)
len(m)

Instead of returning the number i am getting error message as shown below.

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-1c4c9134d6f4> in <module>
      1 import language_tool_python
----> 2 tool = language_tool_python.LanguageTool('en-US')
      3 
      4 text = "Your the best but their are allso  good !"
      5 matches = tool.check(text)

E:\Anaconda\lib\site-packages\language_tool_python\server.py in __init__(self, language, motherTongue, remote_server, newSpellings, new_spellings_persist)
     43             self._update_remote_server_config(self._url)
     44         elif not self._server_is_alive():
---> 45             self._start_server_on_free_port()
     46         if language is None:
     47             try:

E:\Anaconda\lib\site-packages\language_tool_python\server.py in _start_server_on_free_port(self)
    212             self._url = 'http://{}:{}/v2/'.format(self._HOST, self._port)
    213             try:
--> 214                 self._start_local_server()
    215                 break
    216             except ServerError:

E:\Anaconda\lib\site-packages\language_tool_python\server.py in _start_local_server(self)
    222     def _start_local_server(self):
    223         # Before starting local server, download language tool if needed.
--> 224         download_lt()
    225         err = None
    226         try:

E:\Anaconda\lib\site-packages\language_tool_python\download_lt.py in download_lt(update)
    142     ]
    143 
--> 144     confirm_java_compatibility()
    145     version = LATEST_VERSION
    146     filename = FILENAME.format(version=version)

E:\Anaconda\lib\site-packages\language_tool_python\download_lt.py in confirm_java_compatibility()
     73         # found because of a PATHEXT-related issue
     74         # (https://bugs.python.org/issue2200).
---> 75         raise ModuleNotFoundError('No java install detected. Please install java to use language-tool-python.')
     76 
     77     output = subprocess.check_output([java_path, '-version'],

ModuleNotFoundError: No java install detected. Please install java to use language-tool-python.

When I run the code I get no java install detected How to solve this issue?


Solution

  • I think this is not an issue with the Code itself when I run the code you provided

    import language_tool_python
    tl = language_tool_python.LanguageTool('en-US')
    
    txt = "good mooorning sirr and medam my namee anderen i am from amerecia !"
    m = tl.check(txt)
    len(m)
    

    I get as result a number in this case

     OUT: 8
    

    In the Documentation of the language-tool-python is written:

    By default, language_tool_python will download a LanguageTool server .jar and run that in the background to detect grammar errors locally. However, LanguageTool also offers a Public HTTP Proofreading API that is supported as well. Follow the link for rate-limiting details. (Running locally won't have the same restrictions.)

    So You will need Java (JRE and SKD). Also it's Written in the Requirements of the library:

    Prerequisites Python 3.5+ LanguageTool (Java 8.0 or higher) The installation process should take care of downloading LanguageTool (it may take a few minutes). Otherwise, you can manually download LanguageTool-stable.zip and unzip it into where the language_tool_python package resides.

    Source:

    I Hope I could help.