Skip to content

Commit b57d33f

Browse files
committed
fix LT download in some situations
1 parent 30cb835 commit b57d33f

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

‎README.md‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,41 @@ By default, `language_tool_python` will download a LanguageTool server `.jar` an
1010

1111
Local server is the default setting. To use this, just initialize a LanguageTool object:
1212

13-
> import language_tool_python
14-
> tool = language_tool_python.LanguageTool('en-US') # use a local server (automatically set up), language English
13+
import language_tool_python
14+
tool = language_tool_python.LanguageTool('en-US') # use a local server (automatically set up), language English
1515

1616
### Using `language_tool_python` with the public LanguageTool remote server
1717

1818
There is also a built-in class for querying LanguageTool's public servers. Initialize it like this:
1919

20-
> import language_tool_python
21-
> tool = language_tool_python.LanguageToolPublicAPI('es') # use the public API, language Spanish
20+
import language_tool_python
21+
tool = language_tool_python.LanguageToolPublicAPI('es') # use the public API, language Spanish
2222

2323
### Using `language_tool_python` with the another remote server
2424

2525
Finally, you're able to pass in your own remote server as an argument to the `LanguageTool` class:
2626

27-
> import language_tool_python
28-
> tool = language_tool_python.LanguageTool('ca-ES', remote_server='https://language-tool-api.mywebsite.net') # use a remote server API, language Catalan
27+
import language_tool_python
28+
tool = language_tool_python.LanguageTool('ca-ES', remote_server='https://language-tool-api.mywebsite.net') # use a remote server API, language Catalan
2929

3030

3131

3232
## Example usage
3333

3434
From the interpreter:
3535

36-
> import language_tool_python
37-
> tool = language_tool_python.LanguageTool('en-US')
38-
> text = u'A sentence with a error in the Hitchhiker’s Guide tot he Galaxy'
39-
> matches = tool.check(text)
40-
> len(matches)
36+
import language_tool_python
37+
tool = language_tool_python.LanguageTool('en-US')
38+
text = u'A sentence with a error in the Hitchhiker’s Guide tot he Galaxy'
39+
matches = tool.check(text)
40+
len(matches)
4141
2
4242

4343
Check out some ``Match`` object attributes:
4444

45-
> matches[0].ruleId, matches[0].replacements
45+
matches[0].ruleId, matches[0].replacements
4646
('EN_A_VS_AN', ['an'])
47-
> matches[1].ruleId, matches[1].replacements
47+
matches[1].ruleId, matches[1].replacements
4848
('TOT_HE', ['to the'])
4949

5050
Print a ``Match`` object:

‎language_tool_python/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
migration URL: https://languagetool.org/http-api/migration.php
44
"""
55

6-
__version__ = '2.0.3'
6+
__version__ = '2.0.4'
77

88
from .language_tag import LanguageTag
99
from .match import Match

‎language_tool_python/server.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
from .utils import *
1515

1616
class LanguageTool:
17-
18-
"""Main class used for checking text against different rules."""
17+
""" Main class used for checking text against different rules. """
1918
_HOST = socket.gethostbyname('localhost')
2019
_MIN_PORT = 8081
2120
_MAX_PORT = 8999
@@ -148,8 +147,6 @@ def _get_attrib(cls):
148147

149148
@classmethod
150149
def _start_server_if_needed(cls):
151-
# Download language tool if needed.
152-
download_lt()
153150
# Start server.
154151
if not cls._server_is_alive() and cls._remote is False:
155152
cls._start_server_on_free_port()
@@ -180,6 +177,9 @@ def _get_root(cls, url, data=None, num_tries=2):
180177

181178
@classmethod
182179
def _start_server_on_free_port(cls):
180+
# Download language tool if needed.
181+
download_lt()
182+
183183
while True:
184184
cls._url = 'http://{}:{}/v2/'.format(cls._HOST, cls._port)
185185
try:

0 commit comments

Comments
 (0)