Skip to main content

Uzbek Cyrillic-Latin transliterator and spell checker

Project description

uzbek-text-tools

A Python library for Uzbek natural language processing. It converts Uzbek text between Cyrillic and Latin scripts and spell-checks Latin-script Uzbek text against a 513,000-word frequency dictionary built from Uzbek Wikipedia.

Installation

pip install uzbek-text-tools

Usage

Transliterator

Convert Uzbek text between Cyrillic and Latin scripts:

from uzbek_text_tools import transliterate

print(transliterate("Салом, дўстлар!"))
# → Salom, doʻstlar!

print(transliterate("Ўзбекистон — буюк давлат."))
# → Oʻzbekiston — buyuk davlat.

The class-based interface:

from uzbek_text_tools import Transliterator

t = Transliterator()
print(t.cyrillic_to_latin("Шаҳар"))   # → Shahar
print(t.latin_to_cyrillic("Salom"))   # → Салом

Edge case handled: Е/е at the start of a word becomes Ye/ye; in the middle it becomes E/e.

transliterate("Европа метро")
# → Yevropa metro

Spell Checker

Check and correct Latin-script Uzbek text:

from uzbek_text_tools import UzbekSpellChecker

sc = UzbekSpellChecker()

# Single word
sc.is_correct("kitob")     # True
sc.is_correct("kitoob")    # False
sc.suggest("kitoob")       # ['kitob']
sc.correct("kitoob")       # 'kitob'

# Full paragraph
result = sc.check_text("Bu kitoob juda yaxshi")
print(result)
# {
#   'total_words': 4,
#   'errors_found': 1,
#   'errors': [{'word': 'kitoob', 'suggestions': ['kitob']}]
# }

Suggestions are ranked by Levenshtein distance first, then by word frequency — so common Uzbek words rank above rare ones when equidistant.

Pipeline (transliterate + spellcheck in one call)

from uzbek_text_tools import UzbekTextPipeline

pipe = UzbekTextPipeline()

# Cyrillic input
result = pipe.process("Бу китооб жуда яхши", script="cyrillic")
print(result["converted"])              # Bu kitoob juda yaxshi
print(result["spell_check"]["errors"])  # [{'word': 'kitoob', 'suggestions': ['kitob']}]

# Latin input (default)
result = pipe.process("Bu kitoob juda yaxshi")
print(result["spell_check"]["errors_found"])  # 1

How it works

Component Detail
Transliterator Character-map based; handles all 33 Cyrillic letters + 4 Uzbek-specific letters (Ғ, Қ, Ҳ, Ў); word-boundary regex for the Е→Ye rule
Dictionary 513,409 words extracted from Uzbek Wikipedia (675 article batches), frequency ≥ 3
Spell checker Levenshtein distance ≤ 2, with length-window pre-filter (±2 chars) for speed; frequency as tiebreaker

Known limitations

  • Formal vocabulary only. The dictionary comes from Wikipedia — everyday slang, SMS language, and casual speech may be flagged as errors even when correct.
  • Latin script only for spell-checking. Run Cyrillic text through the transliterator first (or use the Pipeline).
  • No morphological analysis. Uzbek is an agglutinative language; word forms like kitoblar (books) and kitoblarni (books, accusative) are treated as independent entries. Rare inflected forms may not be in the dictionary.
  • Speed. Checking a long document takes a few seconds because each unknown word is compared against up to ~50,000 length-similar candidates. A BK-tree index is planned for v0.2.

Contributing

  1. Fork the repo on GitHub
  2. Create a feature branch: git checkout -b feature/my-improvement
  3. Add or update tests in tests/
  4. Run the suite: pytest tests/
  5. Open a pull request

Ideas welcome: broader corpus (social media, news), morphology-aware checking, Latin→Cyrillic spell-check, CLI tool.

License

MIT

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

uzbek_text_tools-0.1.0.tar.gz (2.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uzbek_text_tools-0.1.0-py3-none-any.whl (2.9 MB view details)

Uploaded Python 3

File details

Details for the file uzbek_text_tools-0.1.0.tar.gz.

File metadata

  • Download URL: uzbek_text_tools-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for uzbek_text_tools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e98d537acee962bf331f06d15ec2db057f3502d2c3eeafbe037c49b4395b0014
MD5 9bb6b80922c9f778f1de873906330fb5
BLAKE2b-256 9e5efa061d07752c70e9259ab721e65e9fc4f8265eb1070c034c46bf14359c9c

See more details on using hashes here.

File details

Details for the file uzbek_text_tools-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for uzbek_text_tools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4905ea5ff470060500c5753df28de5aa53f9c12ac37e7a4cf6483281d0a5a13a
MD5 59ad9aadbc9d88f2446c68f5f6cccbaa
BLAKE2b-256 d5ca39b40b8c49e5b5ff8d87a7465897a9f2238da9349be64fb472134bc4d1a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page