Speliuk
A more accurate spelling correction for the Ukrainian language.
Motivation
When using a spell checker in systems that perform an automatic spelling correction without human verification, the following questions arise:
- How to avoid false correction, i.e. when a real word that is not present in a vocabulary is corrected? This is especially viable for fusional languages such as Ukrainian.
- How to find a single best correction for a misspelled word? Many spell checkers rely on the frequency of candidates and their edit distance discarding the surrounding context.
To address these issues, we propose a system that is compatible with any spell checker but focuses on precision over recall.
We improve the accuracy of a spell checker by using these complimentary models:
- KenLM. The model is used for fast perplexity calculation to find the best candidate for a misspelled word.
- Transfomer-based NER pipeline to detect misspelled words.
- SymSpell. As of now, this is the only supported spell checker.
Installation
- For CPU-only inference, install the CPU version of PyTorch.
- Make sure you can compile Python extension modules (required for KenLM). If you are on Linux, you can install them like this:
sudo apt-get install python-dev
- Install Speliuk:
pip install speliuk
Usage
By default, Speliuk will use pre-trained models stored on Hugging Face.
>>> from speliuk.correct import Speliuk
>>> speliuk = Speliuk()
>>> speliuk.load()
>>> speliuk.correct("то він моее це зраабити для меніе?")
Correction(corrected_text='то він може це зробити для мене?', annotations=[Annotation(start=7, end=11, source_text='моее', suggestions=['може'], meta={}), Annotation(start=15, end=23, source_text='зраабити', suggestions=['зробити'], meta={}), Annotation(start=28, end=33, source_text='меніе', suggestions=['мене'], meta={})])
Speliuk can also be used directly from a spaCy model:
>>> from speliuk.correct import CorrectionPipe
>>> nlp = spacy.blank('uk')
>>> nlp.add_pipe('speliuk', config=dict(spacy_spelling_model_path='/my/custom/model'))
>>> doc = nlp("то він моее це зраабити для меніе?")
>>> doc._.speliuk_corrected
'то він може це зробити для мене?'
>>> doc.spans["speliuk_errors"]
[моее, зраабити, меніе]
Training Details
Spelling Error Detection
To detect spelling errors, a spaCy NER model is used.
It was trained on a combination of synthetic and golden data:
- For synthetic data generation, we used UberText as base texts and nlpaug for errors generation. In total, 10k samples from different categories were used.
- For golden data, we used spelling errors from the UA-GEC corpus.
Perplexity Calculation
We used KenLM for quick perplexity calculation. We used an existing model Yehor/kenlm-uk trained on UberText.
Spell Checker
We used SymSpell for error correction. The dictionary consists of 500k most frequent words from the UberText corpus.
Metadata
Release files for speliuk 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| speliuk-0.0.2.tar.gz | 7.2 kB | Without provenance | Details for speliuk-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| speliuk-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for speliuk-0.0.2-py3-none-any.whl |
Total release size: 15.1 kB
Release files / speliuk-0.0.2.tar.gz
| Download URL | speliuk-0.0.2.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f27c2702bd7d523c8fec7137bc2193397a902be25a7509e49feacca948d799b0
|
|
BLAKE2b-256 checksum How to use checksums |
d07a9fb0a30389b9241c9aa9a043a20aba335ce976ea74181068e21f233253ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.4 Linux/6.8.0-40-generic
|
Release files / speliuk-0.0.2-py3-none-any.whl
| Download URL | speliuk-0.0.2-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92ea6d70b7258e32cc3fc21416eeb772b2741e986376f5f7679c7856a3263918
|
|
BLAKE2b-256 checksum How to use checksums |
f851236954ba00b98bf52d801e50f66c52440465fe5f889be33e234c3e9f71e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.4 Linux/6.8.0-40-generic
|
Security for speliuk 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.