A multilingual grammaticality util based on LanguageTool
Project description
LTScore
LanguageTool wrapper for multilingual grammaticality assessment. For Welsh, it uses CySgor, which is based on the Cysill grammar checker, but works with the same principles as LTScore.
Utility
In low resource languages settings, LTScore can be used as a tool to evaluate the grammaticality of generated text, such as machine translation outputs or conversational AIs. From this, it can be used to filter through training corpora (like sorting legit content from cheap autotranslated websites in fineweb), and improve training data quality, or to evaluate the outputs of a model during training or inference when other methods are not available or satisfactory.
Languages supported
LTScore supports the following languages:
- ar: Arabic
- ast: Asturian
- be: Belarusian
- br: Breton
- ca: Catalan
- crh: Crimean Tatar
- cy: Welsh
- da: Danish
- de: German
- el: Greek
- en: English
- eo: Esperanto
- es: Spanish
- fa: Persian
- fr: French
- ga: Irish
- gl: Galician
- it: Italian
- ja: Japanese
- km: Khmer
- nl: Dutch
- pl: Polish
- pt: Portuguese
- ro: Romanian
- ru: Russian
- sk: Slovak
- sl: Slovenian
- sv: Swedish
- ta: Tamil
- tl: Tagalog
- uk: Ukrainian
- zh: Chinese
Installation
pip install ltscore
Run the Docker image locally
You can download the LanguageTool image from Docker Hub, then using the port 8010 as indicated below.
docker pull erikvl87/languagetool
docker run --rm -p 8010:8010 erikvl87/languagetool
For more details about the Docker container's configuration, see this link.
LTScore as a CLI
There are two ways to use the CLI, either by entering a text file's path, or directly a text. The CLI returns a string of numbers representing the grammaticality score of the text.
# With a text as a positional character
ltscore -l br "Kalz dud a zo amañ!"
# With a -p or --path flag
ltscore -l br -p ./src/ltscore/assets/text-sample-br.txt
or alternatively with the pipe operator:
cat src/ltscore/assets/text-sample-br.txt | ltscore -l br
JSON file processing
LTScore can also process some files for short analysis.
Adding LTScore to an existing file
Given a file data.ndjson with the following content:
{"source": "'Mañ an dud o tont.", "target": "Les gens arrivent.", "prediction": "Les gens vient."}
{"source": "Un devezh dilabour eo Lun Fask.", "target": "Le lundi de Pâques est un jour férié.", "prediction": "Le lundi de Pâques ai un jours fériée."}
running ltscore -t prediction -l fr -p data.ndjson and will get the file updated in the following way:
{"source":"'Mañ an dud o tont.","target":"Les gens arrivent.","prediction":"Les gens vient.","ltscore":33.333333333333336,"mistakes_categories":["CAT_GRAMMAIRE"]}
{"source":"Un devezh dilabour eo Lun Fask.","target":"Le lundi de Pâques est un jour férié.","prediction":"Le lundi de Pâques ai un jours fériée.","ltscore":25.0,"mistakes_categories":["CAT_HOMONYMES_PARONYMES","AGREEMENT"]}
Generating a report
Adding the -r or --report flag will generate a markdown report with a KDE plot of the LTScore distribution, descriptive statistics, and an analysis of sentences based on the mistake categories. The report will be saved in the same directory as the input file with the name ltscore_report.md.
To use it on the file available in src/tests/fixtures/text-sample-br.ndjson, which analyzes a breton texts, you would run:
ltscore -rt prediction -l br -p tests/fixtures/openai-whisper-large-v3--cv-25.0-2026-03-09-br.jsonl
You would then get a report in the same directory as the input file with the ending ltscore_report.md containing a KDE plot of the LTScore distribution, descriptive statistics, and an analysis of sentences based on the mistake categories.
LTScore as a library
One can also use this package as a python library:
from ltscore import get_score, get_mistakes
# get the scores
df["scores"] = df.apply(lambda row: get_score(row["text"], language=row["language"]), axis=1)
# returns a list of mistakes for each text
df["mistakes"] = df.apply(lambda row: get_mistakes(row["text"], language=row["language"]), axis=1)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ltscore-1.1.1.tar.gz.
File metadata
- Download URL: ltscore-1.1.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84bfef6fede2147f821fed13c640acdfe3d1dc48facf75300d6a73f12ce5cb85
|
|
| MD5 |
d29a0bbdfb3ad4617dc6647b49ce4218
|
|
| BLAKE2b-256 |
220cd39c71c86e8c7b5bd18e82b92399df050cf261a0f6ee5bd596893842ea23
|
Provenance
The following attestation bundles were made for ltscore-1.1.1.tar.gz:
Publisher:
publish.yml on Cymru-Breizh/LTScore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ltscore-1.1.1.tar.gz -
Subject digest:
84bfef6fede2147f821fed13c640acdfe3d1dc48facf75300d6a73f12ce5cb85 - Sigstore transparency entry: 1453481267
- Sigstore integration time:
-
Permalink:
Cymru-Breizh/LTScore@cac418a1e5a2e36e961d0307fc209b24af1c2f79 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/Cymru-Breizh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cac418a1e5a2e36e961d0307fc209b24af1c2f79 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ltscore-1.1.1-py3-none-any.whl.
File metadata
- Download URL: ltscore-1.1.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0879674870dea19e2feaddfee29d158aa05bfa3fa09a7431b97c2204357423a5
|
|
| MD5 |
5dbe2f6354d032b2bd601d6051c09fae
|
|
| BLAKE2b-256 |
c307b0c4f7ae1dfff72534ecf00b54d2612bb391bbfb69e9316411fee6b00ad5
|
Provenance
The following attestation bundles were made for ltscore-1.1.1-py3-none-any.whl:
Publisher:
publish.yml on Cymru-Breizh/LTScore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ltscore-1.1.1-py3-none-any.whl -
Subject digest:
0879674870dea19e2feaddfee29d158aa05bfa3fa09a7431b97c2204357423a5 - Sigstore transparency entry: 1453481950
- Sigstore integration time:
-
Permalink:
Cymru-Breizh/LTScore@cac418a1e5a2e36e961d0307fc209b24af1c2f79 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/Cymru-Breizh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cac418a1e5a2e36e961d0307fc209b24af1c2f79 -
Trigger Event:
push
-
Statement type: