Skip to content

Commit 858b501

Browse files
committed
Update README.md
1 parent 35c8a8b commit 858b501

1 file changed

Lines changed: 73 additions & 68 deletions

File tree

README.md

Lines changed: 73 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,82 +4,53 @@
44
[![Python](https://img.shields.io/pypi/pyversions/kaalin)](https://pypi.org/project/kaalin/)
55
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
66

7-
A Python toolkit for the **Karakalpak language**: Latin-Cyrillic script conversion, number-to-words, and locale-aware string operations. Zero dependencies.
7+
A Python toolkit for the **Karakalpak language**. Zero dependencies, Python 3.10+.
88

9-
## Quick Start
9+
## Installation
1010

1111
```bash
1212
pip install kaalin
1313
```
1414

15-
```python
16-
from kaalin.converter import latin2cyrillic, cyrillic2latin
17-
18-
print(latin2cyrillic("Assalawma áleykum")) # Ассалаўма әлейкум
19-
print(cyrillic2latin("Ассалаўма әлейкум")) # Assalawma áleykum
20-
```
21-
22-
## Supported Features
15+
## Script Conversion
2316

24-
| Feature | Description |
25-
|---|---|
26-
| **Script Conversion** | Bidirectional Latin ↔ Cyrillic conversion with multi-character mapping (`sh``ш`, `ch``ч`) and special Cyrillic rules (`ьи``yi`, `ьо``yo`, `ъе``ye`) |
27-
| **Number to Words** | Converts integers and floats to Karakalpak words in Latin or Cyrillic script. Supports range 0 to 10³⁰, negative numbers, and decimal fractions |
28-
| **Word Syllabification** | Splits Karakalpak words into syllables, works with both Latin and Cyrillic scripts, preserves letter case, and recognises digraphs like `sh`, `ch`, `yu`, `ya`, `aw`, `ew` |
29-
| **String Utilities** | Karakalpak-aware `upper()` / `lower()` that correctly handle the dotless `ı``Í` character pair |
30-
| **CLI Tools** | `cyr2lat` and `lat2cyr` commands for converting text files from the terminal |
31-
32-
## API Reference
33-
34-
### Script Conversion
17+
Bidirectional Latin ↔ Cyrillic conversion. Loanwords with special characters (ь, ъ, э, ё, щ) are handled automatically.
3518

3619
```python
3720
from kaalin.converter import latin2cyrillic, cyrillic2latin
3821

39-
latin2cyrillic("Qaraqalpaqstan") # Қарақалпақстан
40-
cyrillic2latin("Қарақалпақстан") # Qaraqalpaqstan
22+
latin2cyrillic("Assalawma áleykum") # Ассалаўма әлейкум
23+
cyrillic2latin("Ассалаўма әлейкум") # Assalawma áleykum
24+
25+
# You can extend the built-in loanword dictionary with your own entries
26+
latin2cyrillic("stilistika", custom_loanwords={"stilistika": "стилистика"})
4127
```
4228

43-
Both functions accept a `str` and return a `str`. The converter handles uppercase, lowercase, and mixed-case text.
29+
## Number to Words
4430

45-
### Number to Words
31+
Converts numbers to Karakalpak words. Supports integers, floats, and negatives up to 10³⁰.
4632

4733
```python
48-
from kaalin.number import to_word, NumberRangeError
34+
from kaalin.number import to_word
4935

50-
to_word(123) # bir júz jigirma úsh
51-
to_word(999, num_type="cyr") # тоғыз жүз тоқсан тоғыз
52-
to_word(12.75) # on eki pútin júzden jetpis bes
53-
to_word(-42) # minus qırıq eki
36+
to_word(123) # bir júz jigirma úsh
37+
to_word(999, num_type="cyr") # тоғыз жүз тоқсан тоғыз
5438
```
5539

56-
**Parameters:**
57-
- `number` (`int | float`) — the number to convert
58-
- `num_type` (`str`) — output script: `"lat"` (default) or `"cyr"`
40+
## Syllabification
5941

60-
**Raises:** `NumberRangeError` if `number` exceeds 10³⁰.
61-
62-
### Word Syllabification
42+
Splits words into syllables. Works with both Latin and Cyrillic input.
6343

6444
```python
6545
from kaalin.syllable import syllabify
6646

6747
syllabify("qaraqalpaqstan") # ['qa', 'ra', 'qal', 'paq', 'stan']
68-
syllabify("kompyuter") # ['kom', 'pyu', 'ter']
6948
syllabify("Шарапат") # ['Ша', 'ра', 'пат']
70-
syllabify("Adam") # ['A', 'dam']
71-
72-
"-".join(syllabify("úydegiler")) # 'úy-de-gi-ler'
7349
```
7450

75-
**Parameters:**
76-
- `word` (`str`) — the word to split. Accepts Latin or Cyrillic input.
77-
78-
**Returns:** A `list[str]` of syllables in the same script as the input. Words with fewer than two vowels are returned as a single-element list unchanged.
79-
80-
**Raises:** `TypeError` if `word` is not a string.
51+
## String Utilities
8152

82-
### String Utilities
53+
Karakalpak-aware `upper()` / `lower()` that correctly handle the dotless `ı``Í` pair.
8354

8455
```python
8556
from kaalin.string import upper, lower
@@ -88,34 +59,68 @@ upper("Assalawma áleykum") # ASSALAWMA ÁLEYKUM
8859
lower("ASSALAWMA ÁLEYKUM") # assalawma áleykum
8960
```
9061

91-
Python's built-in `str.upper()` / `str.lower()` does not handle the Karakalpak dotless `ı` correctly. These functions fix that.
62+
## CLI
9263

93-
## CLI Usage
94-
95-
Convert text files between scripts directly from the terminal:
64+
Convert text files between scripts from the terminal:
9665

9766
```bash
98-
# Cyrillic → Latin
9967
cyr2lat input.txt # writes input-lat.txt
100-
cyr2lat input.txt output.txt # writes output.txt
101-
102-
# Latin → Cyrillic
10368
lat2cyr input.txt # writes input-cyr.txt
104-
lat2cyr input.txt output.txt # writes output.txt
10569
```
10670

107-
## When to Use Kaalin
71+
## License
72+
73+
MIT
74+
75+
<!--
76+
API REFERENCE FOR AI AGENTS
77+
78+
## converter
79+
80+
from kaalin.converter import latin2cyrillic, cyrillic2latin
81+
82+
latin2cyrillic(text: str, custom_loanwords: dict[str, str] | None = None) -> str
83+
Converts Latin script to Cyrillic. Handles multi-char sequences (sh→ш, ch→ч, ya→я, yu→ю).
84+
Built-in loanword dictionary handles words with ь, ъ, э, ё, щ automatically.
85+
custom_loanwords merges with (and overrides) built-in dict.
86+
Supports uppercase, lowercase, and mixed-case text.
87+
88+
cyrillic2latin(text: str) -> str
89+
Converts Cyrillic script to Latin. Handles special rules: ьи→yi, ьо→yo, ъе→ye.
90+
91+
## number
92+
93+
from kaalin.number import to_word, NumberRangeError
94+
95+
to_word(number: int | float, num_type: str = "lat") -> str
96+
Converts number to Karakalpak words.
97+
num_type: "lat" (default) or "cyr" for output script.
98+
Supports: 0 to 10^30, negatives, floats.
99+
Raises NumberRangeError if number exceeds 10^30.
100+
101+
## syllable
102+
103+
from kaalin.syllable import syllabify
104+
105+
syllabify(word: str) -> list[str]
106+
Splits word into syllables. Works with Latin and Cyrillic input.
107+
Auto-detects script. Preserves original case.
108+
Words with fewer than two vowels are returned as single-element list.
109+
Raises TypeError if input is not a string.
110+
111+
## string
112+
113+
from kaalin.string import upper, lower
114+
115+
upper(text: str) -> str
116+
Karakalpak-aware uppercase. Handles dotless ı → Í correctly.
108117
109-
- Converting Karakalpak text between Latin and Cyrillic scripts
110-
- Displaying numbers as Karakalpak words (invoices, checks, education)
111-
- Splitting words into syllables for hyphenation, typesetting, or language learning
112-
- NLP preprocessing for Karakalpak text (script normalization)
113-
- Building Karakalpak-language applications that need locale-aware string operations
114-
- Batch-converting text files via CLI
118+
lower(text: str) -> str
119+
Karakalpak-aware lowercase. Handles Í → ı correctly.
115120
116-
## When NOT to Use Kaalin
121+
## CLI
117122
118-
- **Not a translator** — it converts scripts (Latin ↔ Cyrillic), not languages
119-
- **Not a spell-checker** — it does not validate or correct Karakalpak text
120-
- **Not for other Turkic languages** — Kazakh, Uzbek, Turkish, etc. have different alphabets and rules
121-
- **Not an OCR tool** — it works with digital text, not images
123+
cyr2lat input.txt [output.txt] Cyrillic → Latin file conversion
124+
lat2cyr input.txt [output.txt] Latin → Cyrillic file conversion
125+
Default output: input-lat.txt / input-cyr.txt
126+
-->

0 commit comments

Comments
 (0)