|
1 | 1 | # Kaalin |
2 | 2 |
|
3 | | -<p> |
4 | | - Using this library, certain operations for the Karakalpak language can be performed very quickly and conveniently. |
5 | | -</p> |
| 3 | +[](https://pypi.org/project/kaalin/) |
| 4 | +[](https://pypi.org/project/kaalin/) |
| 5 | +[](https://opensource.org/licenses/MIT) |
| 6 | + |
| 7 | +A Python toolkit for the **Karakalpak language**: Latin-Cyrillic script conversion, number-to-words, and locale-aware string operations. Zero dependencies. |
| 8 | + |
| 9 | +## Quick Start |
| 10 | + |
| 11 | +```bash |
| 12 | +pip install kaalin |
| 13 | +``` |
6 | 14 |
|
7 | | -## Example |
8 | 15 | ```python |
9 | 16 | from kaalin.converter import latin2cyrillic, cyrillic2latin |
10 | 17 |
|
| 18 | +print(latin2cyrillic("Assalawma áleykum")) # Ассалаўма әлейкум |
| 19 | +print(cyrillic2latin("Ассалаўма әлейкум")) # Assalawma áleykum |
| 20 | +``` |
| 21 | + |
| 22 | +## Supported Features |
| 23 | + |
| 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 | +| **String Utilities** | Karakalpak-aware `upper()` / `lower()` that correctly handle the dotless `ı` ↔ `Í` character pair | |
| 29 | +| **CLI Tools** | `cyr2lat` and `lat2cyr` commands for converting text files from the terminal | |
11 | 30 |
|
12 | | -print(latin2cyrillic("Assalawma áleykum")) # Ассалаўма әлейкум |
13 | | -print(cyrillic2latin("Ассалаўма әлейкум")) # Assalawma áleykum |
| 31 | +## API Reference |
| 32 | + |
| 33 | +### Script Conversion |
| 34 | + |
| 35 | +```python |
| 36 | +from kaalin.converter import latin2cyrillic, cyrillic2latin |
| 37 | + |
| 38 | +latin2cyrillic("Qaraqalpaqstan") # Қарақалпақстан |
| 39 | +cyrillic2latin("Қарақалпақстан") # Qaraqalpaqstan |
14 | 40 | ``` |
15 | 41 |
|
| 42 | +Both functions accept a `str` and return a `str`. The converter handles uppercase, lowercase, and mixed-case text. |
| 43 | + |
| 44 | +### Number to Words |
| 45 | + |
16 | 46 | ```python |
17 | 47 | from kaalin.number import to_word, NumberRangeError |
18 | 48 |
|
19 | | - |
20 | | -try: |
21 | | - print(to_word(123)) # bir júz jigirma úsh |
22 | | - print(to_word(999, num_type="cyr")) # тоғыз жүз тоқсан тоғыз |
23 | | - print(to_word(12.75)) # on eki pútin júzden jetpis bes |
24 | | -except NumberRangeError as e: |
25 | | - print("San shegaradan asıp ketti!") |
| 49 | +to_word(123) # bir júz jigirma úsh |
| 50 | +to_word(999, num_type="cyr") # тоғыз жүз тоқсан тоғыз |
| 51 | +to_word(12.75) # on eki pútin júzden jetpis bes |
| 52 | +to_word(-42) # minus qırıq eki |
26 | 53 | ``` |
27 | 54 |
|
| 55 | +**Parameters:** |
| 56 | +- `number` (`int | float`) — the number to convert |
| 57 | +- `num_type` (`str`) — output script: `"lat"` (default) or `"cyr"` |
| 58 | + |
| 59 | +**Raises:** `NumberRangeError` if `number` exceeds 10³⁰. |
| 60 | + |
| 61 | +### String Utilities |
| 62 | + |
28 | 63 | ```python |
29 | 64 | from kaalin.string import upper, lower |
30 | 65 |
|
31 | | - |
32 | | -print(upper("Assalawma áleykum")) # ASSALAWMA ÁLEYKUM |
33 | | -print(lower("Assalawma áleykum")) # assalawma áleykum |
| 66 | +upper("Assalawma áleykum") # ASSALAWMA ÁLEYKUM |
| 67 | +lower("ASSALAWMA ÁLEYKUM") # assalawma áleykum |
34 | 68 | ``` |
35 | 69 |
|
36 | | -### Command Line Interface (CLI) |
| 70 | +Python's built-in `str.upper()` / `str.lower()` does not handle the Karakalpak dotless `ı` correctly. These functions fix that. |
| 71 | + |
| 72 | +## CLI Usage |
| 73 | + |
| 74 | +Convert text files between scripts directly from the terminal: |
| 75 | + |
37 | 76 | ```bash |
38 | | -$ cyr2lat input.txt [output.txt] |
39 | | -$ lat2cyr input.txt [output.txt] |
| 77 | +# Cyrillic → Latin |
| 78 | +cyr2lat input.txt # writes input-lat.txt |
| 79 | +cyr2lat input.txt output.txt # writes output.txt |
| 80 | + |
| 81 | +# Latin → Cyrillic |
| 82 | +lat2cyr input.txt # writes input-cyr.txt |
| 83 | +lat2cyr input.txt output.txt # writes output.txt |
40 | 84 | ``` |
| 85 | + |
| 86 | +## When to Use Kaalin |
| 87 | + |
| 88 | +- Converting Karakalpak text between Latin and Cyrillic scripts |
| 89 | +- Displaying numbers as Karakalpak words (invoices, checks, education) |
| 90 | +- NLP preprocessing for Karakalpak text (script normalization) |
| 91 | +- Building Karakalpak-language applications that need locale-aware string operations |
| 92 | +- Batch-converting text files via CLI |
| 93 | + |
| 94 | +## When NOT to Use Kaalin |
| 95 | + |
| 96 | +- **Not a translator** — it converts scripts (Latin ↔ Cyrillic), not languages |
| 97 | +- **Not a spell-checker** — it does not validate or correct Karakalpak text |
| 98 | +- **Not for other Turkic languages** — Kazakh, Uzbek, Turkish, etc. have different alphabets and rules |
| 99 | +- **Not an OCR tool** — it works with digital text, not images |
| 100 | + |
| 101 | +## Contributing |
| 102 | + |
| 103 | +See [CONTRIBUTING.md](CONTRIBUTING.md). |
| 104 | + |
| 105 | +## License |
| 106 | + |
| 107 | +[MIT](LICENSE) |
0 commit comments