Skip to content

Commit 287d380

Browse files
committed
docs: rewrite README with quick start, features, and usage guide; migrate setup.py to pyproject.toml with improved metadata
1 parent 5ac4192 commit 287d380

4 files changed

Lines changed: 194 additions & 58 deletions

File tree

CLAUDE.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
**kaalin** is a pure Python library (zero external dependencies) for Karakalpak language operations: Latin-Cyrillic script conversion, number-to-word conversion, and Karakalpak-aware string utilities. Published to PyPI as `kaalin`.
8+
9+
## Commands
10+
11+
```bash
12+
# Install in development mode
13+
pip install -e .
14+
15+
# Run all tests
16+
python -m unittest discover test
17+
pytest test/
18+
19+
# Run a single test file
20+
python -m unittest test.test_kaalin_converter
21+
pytest test/test_num2words.py
22+
23+
# Build distribution packages
24+
python -m build
25+
26+
# CLI tools (after install)
27+
cyr2lat input.txt [output.txt]
28+
lat2cyr input.txt [output.txt]
29+
```
30+
31+
## Architecture
32+
33+
The library has four modules under `kaalin/`:
34+
35+
- **converter/**`latin2cyrillic()` and `cyrillic2latin()` functions using dictionary-based character mapping from `constants.py`. Handles multi-character sequences (e.g., "sh" → "ш") and Cyrillic soft/hard sign rules ('ьи'→'yi', 'ьо'→'yo', 'ъе'→'ye').
36+
- **number/**`to_word(number, num_type="lat")` converts integers/floats to Karakalpak words in Latin or Cyrillic script. Supports range 0 to 10^30. Raises `NumberRangeError` for out-of-range values.
37+
- **string/**`upper()` and `lower()` with Karakalpak-specific character handling ('ı' ↔ 'Í').
38+
- **cli/** — Console script entry points (`cyr2lat`, `lat2cyr`) registered in `pyproject.toml` for file-based text conversion.
39+
40+
Public API is re-exported from `kaalin/__init__.py`.
41+
42+
## Code Style
43+
44+
- 2-space indentation (per `.editorconfig`)
45+
- Max line length: 150 characters
46+
- UTF-8 encoding throughout
47+
- Python 3.10+ type hint syntax (`int | float`)
48+
49+
## Release Process
50+
51+
Version is set in `pyproject.toml` under `[project].version`. Pushing a `v*` tag triggers `.github/workflows/release.yml` which builds and publishes to PyPI via twine.
52+
53+
## Key Constraints
54+
55+
- No external runtime dependencies — keep it pure Python
56+
- CLI entry point changes must be reflected in `pyproject.toml` `[project.scripts]`
57+
- Tests use both `unittest` (converter, string) and `pytest` (number)

README.md

Lines changed: 86 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,107 @@
11
# Kaalin
22

3-
<p>
4-
Using this library, certain operations for the Karakalpak language can be performed very quickly and conveniently.
5-
</p>
3+
[![PyPI version](https://img.shields.io/pypi/v/kaalin)](https://pypi.org/project/kaalin/)
4+
[![Python](https://img.shields.io/pypi/pyversions/kaalin)](https://pypi.org/project/kaalin/)
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](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+
```
614

7-
## Example
815
```python
916
from kaalin.converter import latin2cyrillic, cyrillic2latin
1017

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 |
1130

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
1440
```
1541

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+
1646
```python
1747
from kaalin.number import to_word, NumberRangeError
1848

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
2653
```
2754

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+
2863
```python
2964
from kaalin.string import upper, lower
3065

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
3468
```
3569

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+
3776
```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
4084
```
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)

pyproject.toml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "kaalin"
7+
version = "3.3.1"
8+
description = "Karakalpak language toolkit for Python — Latin/Cyrillic script conversion, number-to-words, and string utilities"
9+
readme = "README.md"
10+
license = "MIT"
11+
requires-python = ">=3.10"
12+
authors = [
13+
{ name = "Turdibek Jumabaev", email = "turdibekjumabaev05@gmail.com" },
14+
]
15+
keywords = [
16+
"karakalpak",
17+
"karakalpakstan",
18+
"latin",
19+
"cyrillic",
20+
"transliteration",
21+
"script-conversion",
22+
"num2words",
23+
"number-to-words",
24+
"nlp",
25+
"language-tools",
26+
"turkic",
27+
]
28+
classifiers = [
29+
"Development Status :: 5 - Production/Stable",
30+
"Intended Audience :: Developers",
31+
"Programming Language :: Python :: 3",
32+
"Programming Language :: Python :: 3.10",
33+
"Programming Language :: Python :: 3.11",
34+
"Programming Language :: Python :: 3.12",
35+
"Programming Language :: Python :: 3.13",
36+
"Operating System :: OS Independent",
37+
"Topic :: Text Processing :: Linguistic",
38+
]
39+
40+
[project.urls]
41+
Homepage = "https://github.com/dontbeidle/kaalin-python"
42+
Repository = "https://github.com/dontbeidle/kaalin-python"
43+
Issues = "https://github.com/dontbeidle/kaalin-python/issues"
44+
PyPI = "https://pypi.org/project/kaalin/"
45+
46+
[project.scripts]
47+
cyr2lat = "kaalin.cli.converter:cyr2lat"
48+
lat2cyr = "kaalin.cli.converter:lat2cyr"
49+
50+
[tool.setuptools.packages.find]
51+
include = ["kaalin*"]

setup.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)