kamaalg commited on
Commit
19ba2ce
·
verified ·
1 Parent(s): 0ba3b2f

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +80 -0
README.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # aztext
2
+
3
+ Lightweight, **dependency-free** Azerbaijani text-processing toolkit — the small utilities every
4
+ Azerbaijani NLP project re-implements, done once and done correctly. Pure Python standard library, no
5
+ `numpy`/`torch`/`regex` required.
6
+
7
+ Built as part of an open Azerbaijani LLM stack (tokenizer → dataset → model → evals).
8
+
9
+ ## Why
10
+
11
+ Azerbaijani (Latin script) adds `ə ğ ı i ö ş ç ü` beyond ASCII, and the **dotted/dotless i** distinction
12
+ (`i`≠`ı`, `İ`≠`I`) is meaningful — but Python's `str.lower()/upper()` get it wrong, people type without
13
+ diacritics, and Azerbaijani is easily confused with Turkish. `aztext` handles these correctly.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ pip install -e aztext # from this repo
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```python
24
+ import aztext
25
+
26
+ # Correct Turkic-i-aware casing (Python's str.upper gets this wrong)
27
+ aztext.az_upper("işıq") # -> "İŞIQ"
28
+ aztext.az_lower("İSTİQLAL") # -> "istiqlal"
29
+
30
+ # Restore diacritics to ASCII-typed text (best-effort, dictionary-based)
31
+ aztext.deasciify("ucun cixis") # -> "üçün çıxış"
32
+ aztext.ascii_fold("gözəl çıxış") # -> "gozel cixis"
33
+
34
+ # Azerbaijani vs Turkish language ID (heuristic; ə is the key signal)
35
+ aztext.is_azerbaijani("Mən kitab oxuyuram.") # -> True
36
+ aztext.detect_language("Ben kitap okuyorum.") # -> ("tr", 0.87)
37
+
38
+ # Numbers to Azerbaijani words
39
+ aztext.num_to_words(1234) # -> "min iki yüz otuz dörd"
40
+ aztext.num_to_words(-5) # -> "mənfi beş"
41
+
42
+ # Normalization, tokenization, script detection
43
+ aztext.normalize("Gözəl şəhər — “Bakı”.") # NFC, quotes/dashes, whitespace
44
+ aztext.word_tokenize("Bakı, paytaxtdır.") # -> ["Bakı", "paytaxtdır"]
45
+ aztext.sent_tokenize("Bir. İki! Üç?") # -> ["Bir.", "İki!", "Üç?"]
46
+ aztext.is_latin_azerbaijani("Azərbaycan dili") # -> True
47
+ ```
48
+
49
+ ## API
50
+
51
+ | function | does |
52
+ |---|---|
53
+ | `normalize(text)` | NFC, mojibake repair, zero-width strip, quote/dash + whitespace cleanup (preserves casing & Az letters; idempotent) |
54
+ | `deasciify(text)` | restore Azerbaijani diacritics on ASCII-typed text (dictionary best-effort) |
55
+ | `ascii_fold(text)` | strip diacritics (`ə→e`, `ş→s`, …) |
56
+ | `is_azerbaijani(text)` / `detect_language(text)` | Az-vs-Tr-vs-other heuristic ID |
57
+ | `num_to_words(n)` | Azerbaijani cardinal spelling (0 … < 10¹², negatives) |
58
+ | `word_tokenize` / `sent_tokenize` | explicit-alphabet word/sentence tokenizers |
59
+ | `is_latin_azerbaijani` / `script_ratios` | Latin-vs-Cyrillic/Arabic script detection |
60
+ | `az_lower` / `az_upper` | Turkic-i-aware case mapping |
61
+
62
+ ## Limitations (honest)
63
+
64
+ - **`deasciify` is dictionary-based best-effort.** It restores common words; unknown words pass through
65
+ unchanged, and genuinely ambiguous folds (e.g. `el` → *el* "people" vs *əl* "hand") resolve to a single
66
+ listed form. It is not a language model.
67
+ - **`detect_language` is a lightweight heuristic**, not a trained classifier — tuned for the Az/Tr split.
68
+ An optional `fasttext` model is used as a tiebreaker only if `AZTEXT_FASTTEXT_MODEL` points to one.
69
+ - Latin-script Modern (North) Azerbaijani only; Cyrillic/Perso-Arabic are detected but not transliterated.
70
+
71
+ ## Tests
72
+
73
+ ```bash
74
+ python -m pytest aztext/tests -q # or, dependency-free:
75
+ python aztext/tests/test_aztext.py
76
+ ```
77
+
78
+ ## License
79
+
80
+ MIT.