A morphological tokenizer for Uzbek language
Project description
Uzbek Tokenizer
A Python library for morphological segmentation of Uzbek text. This tokenizer breaks down Uzbek words into their constituent morphemes (stems and affixes), which is useful for natural language processing tasks like machine learning, text analysis, and linguistic research.
Features
- 🔤 Morphological Segmentation: Breaks Uzbek words into stems and affixes
- 📝 Text Normalization: Handles Unicode, punctuation, and Uzbek-specific characters
- ⚡ Efficient: Cached segmentation for repeated tokens
- 📦 Easy to Use: Simple API for both single words and batch processing
- 🎯 Agglutinative Language Support: Designed specifically for Uzbek's morphological structure
Installation
Install via pip:
pip install uzbek-tokenizer
Or clone the repository:
git clone https://github.com/IbratDO/uzbek-tokenizer.git
cd uzbek-tokenizer
pip install -e .
Quick Start
Basic Usage
from uzbek_tokenizer import apply_segmentation, normalize
# Segment a word
text = "kitoblarimizdan"
result = apply_segmentation(text)
print(result)
# Output: ['kitob', 'lar', 'imiz', 'dan']
# Segment a sentence
sentence = "kitoblarimizdan o'qidim"
result = apply_segmentation(sentence)
print(result)
# Output: ['kitob', 'lar', 'imiz', 'dan', "o'q", 'id', 'im']
Normalization Only
from uzbek_tokenizer import normalize
text = "Salom, JAHON!"
normalized = normalize(text)
print(normalized)
# Output: "salom , jahon !"
Morphological Segmentation Only
from uzbek_tokenizer import segment_morphological
word = "o'qiyotgan"
segments = segment_morphological(word)
print(segments)
# Output: ["o'q", 'i', 'yotgan']
API Reference
normalize(text: str) -> str
Normalizes Uzbek text by:
- Converting to NFC Unicode form
- Lowercasing
- Standardizing punctuation
- Handling Uzbek apostrophe variants
- Collapsing whitespace
Parameters:
text(str): Input text
Returns: Normalized text
segment_morphological(token: str) -> list[str]
Recursively segments a single token into morphemes.
Parameters:
token(str): A single word/token
Returns: List of morpheme components
apply_segmentation(line: str) -> list[str]
Normalizes text and segments all tokens into morphemes.
Parameters:
line(str): Input text (can be multiple words)
Returns: List of all morphemes
How It Works
The tokenizer uses a greedy longest-match-first algorithm:
- Normalization: Cleans and standardizes the input text
- Prefix Stripping: Removes longest matching prefixes (be-, no-)
- Suffix Stripping: Removes longest matching suffixes (47+ Uzbek suffixes)
- Recursion: Repeats until no more affixes can be removed
- Output: Returns the stem + all stripped affixes
Example: kitoblarimizdan
- Remove suffix "dan" → remainder: "kitoblarimiz"
- Remove suffix "imiz" → remainder: "kitoblar"
- Remove suffix "lar" → remainder: "kitob"
- No more affixes → stem: "kitob"
- Result:
[kitob, lar, imiz, dan]
Supported Affixes
Prefixes (2)
- be-, no-
Suffixes (47+)
Includes: -cha, -lar, -dagi, -dan, -ga, -ni, -ning, -lik, -ish, and many more
See uzbek_tokenizer/data/prefixes.txt and uzbek_tokenizer/data/suffixes.txt for the complete list.
Requirements
- Python 3.8+
- regex >= 2022.0.0
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Issues & Feedback
Found a bug or have a suggestion? Please open an issue on GitHub.
Citation
If you use this tokenizer in your research, please cite:
@software{uzbek_tokenizer_2026,
author = {Ibrat Usmonov},
title = {Uzbek Tokenizer: Morphological Segmentation for Uzbek},
year = {2026},
url = {https://github.com/IbratDO/uzbek-tokenizer}
}
Roadmap
- Vowel harmony validation
- Stem lemmatization
- Support for additional Uzbek dialects
- Performance benchmarks
- Web API
Acknowledgments
Built for Uzbek language processing with love ❤️
Status: Early alpha (v0.1.0) - API may change. Contributions welcome!
Project details
Release history Release notifications | RSS feed
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 uzbek_tokenizer-0.1.0.tar.gz.
File metadata
- Download URL: uzbek_tokenizer-0.1.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9aba0bce513dde0d68d6ad255b546235b21b979fb3697aa15d4c9fb6d0507c3
|
|
| MD5 |
5de3ca946617ea41fa071b8002e6645c
|
|
| BLAKE2b-256 |
7168ceede6febf1e91efd593810529cecaab9c7660f4c4160997d776f03f3401
|
File details
Details for the file uzbek_tokenizer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: uzbek_tokenizer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3c79d444896160d783240b95ca6040f18be7592df9c44abe1d30562641748d8
|
|
| MD5 |
af05169874ff53ab05846035fbab7c6c
|
|
| BLAKE2b-256 |
93b767c1fdd12366b1abd5200134693079fa2dfff86e612f0bb51b40835e21ed
|