Local server configuration¶
When using a local LanguageTool server you can tune its behaviour by passing a config
dictionary to LanguageTool. Internally, the
dictionary is validated and written to a temporary *.cfg file that is passed to the
Java process via --config.
Note
config is only available for local servers. Combining config with
remote_server raises ValueError.
Quick example¶
import language_tool_python
with language_tool_python.LanguageTool(
"en-US",
config={
"cacheSize": 1000,
"cacheTTLSeconds": 300,
"maxTextLength": 100_000,
"pipelineCaching": True,
},
) as tool:
print(tool.correct("A sentence with a error in the Hitchhiker's Guide tot he Galaxy"))
# → A sentence with an error in the Hitchhiker's Guide to the Galaxy
Accepted keys¶
Limits¶
Key |
Type |
Description |
|---|---|---|
|
|
Maximum number of characters accepted per request. Requests exceeding this limit are rejected. |
|
|
Hard character limit that applies even to privileged users with a special token. Requests exceeding this limit are rejected. |
|
|
Maximum time in milliseconds allowed for a single check request. |
|
|
If the ratio of errors to words exceeds this value, the check is aborted. |
|
|
Maximum number of spelling suggestions returned per error. Applies to Hunspell-based languages only. |
|
|
Maximum number of threads used concurrently for checking. |
|
|
Maximum number of requests that can queue up before new requests are rejected. |
Rate limiting¶
Key |
Type |
Description |
|---|---|---|
|
|
Maximum number of requests allowed within |
|
|
Maximum total request body size in bytes within the rate-limit window. |
|
|
Maximum number of timed-out requests before the server starts rejecting new ones. |
|
|
Duration of the rate-limiting window in seconds. |
Pipeline caching¶
Key |
Type |
Description |
|---|---|---|
|
|
Number of sentences to keep in the internal cache (default: 0, disabled). |
|
|
How many seconds sentences are kept in the cache (default: 300 if |
|
|
Enable internal pipeline caching for faster repeated checks. |
|
|
Maximum number of cached pipelines. |
|
|
Expiry time for cached pipelines in seconds. |
|
|
Fill the pipeline cache on startup to reduce first-request latency. Can significantly slow down server start. |
External models¶
All path values must point to existing files or directories, the path is validated when
LanguageToolConfig is instantiated.
Key |
Type |
Description |
|---|---|---|
|
|
Path to a directory containing |
|
|
Path to a fastText language-identification model file. |
|
|
Path to the fastText binary executable. |
|
|
Path to an XML file containing custom rules. |
Access control¶
Key |
Type |
Description |
|---|---|---|
|
|
Comma-separated referrer URLs (or a collection) that are blocked from using the server. |
|
|
Activate only the premium rules, ignoring all free rules. |
|
|
Trust the |
Miscellaneous¶
Key |
Type |
Description |
|---|---|---|
|
|
Comma-separated rule IDs (or a collection) that are disabled globally for all requests. |
|
|
Whether to compute replacement suggestions. Disabling this speeds up checking when suggestions are not needed. |
Language-specific keys¶
In addition to the keys above, you can configure per-language spell-checking by using
keys of the form lang-<code> or lang-<code>-dictPath:
Key pattern |
Type |
Description |
|---|---|---|
|
|
Display name of the language (e.g. |
|
|
Absolute path to the Hunspell |
API reference¶
See LanguageToolConfig for the full class
documentation.