ingush-text 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ingush_text-0.1.0/CHANGELOG.md +27 -0
- ingush_text-0.1.0/CITATION.cff +33 -0
- ingush_text-0.1.0/LICENSE +21 -0
- ingush_text-0.1.0/MANIFEST.in +5 -0
- ingush_text-0.1.0/PKG-INFO +231 -0
- ingush_text-0.1.0/README.md +201 -0
- ingush_text-0.1.0/pyproject.toml +62 -0
- ingush_text-0.1.0/setup.cfg +4 -0
- ingush_text-0.1.0/src/ingush_text/__init__.py +152 -0
- ingush_text-0.1.0/src/ingush_text/_text.py +19 -0
- ingush_text-0.1.0/src/ingush_text/alphabet.py +548 -0
- ingush_text-0.1.0/src/ingush_text/data/ingush_latin.json +152 -0
- ingush_text-0.1.0/src/ingush_text/latin1930.py +290 -0
- ingush_text-0.1.0/src/ingush_text/normalize.py +296 -0
- ingush_text-0.1.0/src/ingush_text/numbers.py +254 -0
- ingush_text-0.1.0/src/ingush_text/palochka.py +360 -0
- ingush_text-0.1.0/src/ingush_text/py.typed +0 -0
- ingush_text-0.1.0/src/ingush_text/tokenizer.py +104 -0
- ingush_text-0.1.0/src/ingush_text/translit.py +396 -0
- ingush_text-0.1.0/src/ingush_text.egg-info/PKG-INFO +231 -0
- ingush_text-0.1.0/src/ingush_text.egg-info/SOURCES.txt +34 -0
- ingush_text-0.1.0/src/ingush_text.egg-info/dependency_links.txt +1 -0
- ingush_text-0.1.0/src/ingush_text.egg-info/requires.txt +3 -0
- ingush_text-0.1.0/src/ingush_text.egg-info/top_level.txt +1 -0
- ingush_text-0.1.0/tests/fixtures/ing_letters_cases.json +522 -0
- ingush_text-0.1.0/tests/fixtures/ingush_latin_cases.json +36 -0
- ingush_text-0.1.0/tests/test_alphabet.py +112 -0
- ingush_text-0.1.0/tests/test_api.py +90 -0
- ingush_text-0.1.0/tests/test_latin1930.py +67 -0
- ingush_text-0.1.0/tests/test_normalize.py +90 -0
- ingush_text-0.1.0/tests/test_numbers.py +101 -0
- ingush_text-0.1.0/tests/test_palochka.py +206 -0
- ingush_text-0.1.0/tests/test_parity.py +106 -0
- ingush_text-0.1.0/tests/test_release_metadata.py +109 -0
- ingush_text-0.1.0/tests/test_tokenizer.py +62 -0
- ingush_text-0.1.0/tests/test_translit.py +111 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `ingush-text` are documented in this file.
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2026-11-29
|
|
6
|
+
|
|
7
|
+
Initial public release extracted from [PaydaDosh](https://paydadosh.ru). Zero runtime dependencies, Python >= 3.11.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- **`ingush_text.palochka`**: display (`Ӏ`, U+04C0) and index (`ӏ`, U+04CF) palochka normalization (`normalize_palochka_display`, `normalize_palochka_index`), deterministic OCR palochka repair with optional wordlist verification (`fix_palochka`, `fix_palochka_text`, `wordlist_key`, `load_wordlist`).
|
|
11
|
+
- **`ingush_text.normalize`**: stress/brevity mark stripping preserving `й`/`ё` (`strip_stress`), Latin homoglyph folding (`fold_latin_homoglyphs`, `fold_ocr_lookalikes`), search/index keys following the PaydaDosh rules (`normalize_for_search`, `normalize_for_index`, `normalize_definition_safe`), display and dataset cleanup (`clean_for_display`, `clean_text`), `norm_space`, `strip_accents_latin_only`, `is_latin_heavy`.
|
|
12
|
+
- **`ingush_text.tokenizer`**: palochka- and diacritic-safe word tokenizer (`tokenize`) plus vowel-length acute signature helpers (`length_marks`, `length_signature`, `WORD_MARKS`).
|
|
13
|
+
- **`ingush_text.alphabet`**: 46-letter Ingush alphabet (12 digraphs with `кхь` = `к + хь` split), PUA encoding/decoding, collation keys (`sort_key`, `rev_key`), syllable counter (`syllables`), and glob-like linguistic mask matcher (`compile_mask`, `Mask`, `MaskError`).
|
|
14
|
+
- **`ingush_text.translit`**: Cyrillic-to-Latin transliteration (`transliterate`, `transliterate_all`, `palochka_unsure`, `clean_for_translit`) with the 1934 historical scheme and Nichols-based ASCII scheme.
|
|
15
|
+
- **`ingush_text.latin1930`**: 1929-1938 Ingush Latin-to-Cyrillic converter (`latin1930_to_cyrillic`; submodule `convert_word`, `iter_tokens`).
|
|
16
|
+
- **`ingush_text.numbers`**: vigesimal Ingush numerals up to `10^21 - 1` (`cardinal`, `ordinal`, `class_forms`, `class_variable`, `class_note`, `number_to_words`).
|
|
17
|
+
- `.github/workflows/publish.yml`: PyPI trusted publishing (OIDC, no tokens) on a published GitHub Release; manual runs go to TestPyPI only.
|
|
18
|
+
|
|
19
|
+
### Differences from the PaydaDosh site code
|
|
20
|
+
- `normalize_palochka_display`, `clean_text`: a run of two or more lookalikes after Cyrillic becomes a double palochka (`теIIа` -> `теӀӀа`; the site gives `теӀIа`).
|
|
21
|
+
- `fix_palochka`: a run of letter lookalikes between Cyrillic letters becomes a double palochka (`теIIа` -> `теӀӀа`, `тIIийрг` -> `тӀӀийрг`; the site leaves them as they are), and a Ukrainian `і` / `І` right after a repaired lookalike is repaired too (`а1і` -> `аӀӀ`; the site gives `аӀі`). `|` / `!` between a lowercase and an uppercase letter is kept (verse breaks `вахар|ДӀадаьккхар`, missing spaces `Дика!Хьо`). Like the site, a `|` / `!` opening a token is never repaired (`ер |сога`, `!хьо`).
|
|
22
|
+
- Latin `L` is a palochka lookalike only between two uppercase Cyrillic letters (`ГLАЛГLАЙ` -> `ГӀАЛГӀАЙ`; `Lондон` stays); the site never converts `L` in display text.
|
|
23
|
+
- `clean_text` also strips the circumflex: the combining U+0302 (`Ва̂ха` -> `Ваха`) and precomposed Latin letters with it (`êtes` -> `etes`).
|
|
24
|
+
- `clean_for_display` returns `Ӏ` (U+04C0) and repairs it only next to Cyrillic; the site function of the same name returns `ӏ` and, in a string with Cyrillic, also turns digits and Latin `1 l L I |` into it (`сантиметр 100` -> `сантиметр ӏ00`).
|
|
25
|
+
- `strip_stress`, `strip_accents_latin_only` compose the input (NFC) first: a decomposed accent after a Latin letter is removed, and a decomposed `а` + U+0306 is treated like `ӑ` by `strip_stress`.
|
|
26
|
+
- `tokenize` drops a token made only of `|` (`|`, `||`, `|||`; `мотт || лоам` -> `['мотт', 'лоам']`).
|
|
27
|
+
- Numerals: `cardinal(True)` is `None`; output uses `Ӏ` unless `palochka="ӏ"` is passed.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite it as below."
|
|
3
|
+
type: software
|
|
4
|
+
title: "ingush-text: text normalization, palochka repair, alphabet utilities, transliteration, and numerals for Ingush"
|
|
5
|
+
version: "0.1.0"
|
|
6
|
+
date-released: "2026-11-29"
|
|
7
|
+
authors:
|
|
8
|
+
- family-names: "Akhilgov"
|
|
9
|
+
given-names: "Yunus"
|
|
10
|
+
affiliation: "PaydaDosh"
|
|
11
|
+
orcid: "https://orcid.org/0009-0008-3127-094X"
|
|
12
|
+
website: "https://paydadosh.ru"
|
|
13
|
+
license: MIT
|
|
14
|
+
url: "https://paydadosh.ru"
|
|
15
|
+
repository-code: "https://github.com/paydadosh/ingush-text"
|
|
16
|
+
abstract: >-
|
|
17
|
+
Zero-dependency Python library (Python 3.11+) for Ingush (inh, ISO 639-3) text processing:
|
|
18
|
+
Cyrillic palochka (U+04C0 / U+04CF) normalization and OCR repair, Latin homoglyph
|
|
19
|
+
folding, stress and brevity mark handling without damaging й/ё, palochka-safe
|
|
20
|
+
tokenization, 46-letter Ingush alphabet encoding, collation, syllable counting,
|
|
21
|
+
pattern masks, Cyrillic-to-Latin transliteration (1934 historical alphabet and
|
|
22
|
+
ASCII/Nichols schemes), 1929-1938 Latin-to-Cyrillic conversion, and vigesimal
|
|
23
|
+
Ingush numerals up to 10^21 - 1.
|
|
24
|
+
keywords:
|
|
25
|
+
- Ingush
|
|
26
|
+
- inh
|
|
27
|
+
- palochka
|
|
28
|
+
- text normalization
|
|
29
|
+
- transliteration
|
|
30
|
+
- vigesimal numerals
|
|
31
|
+
- low-resource languages
|
|
32
|
+
- Nakh languages
|
|
33
|
+
- Caucasian languages
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yunus Akhilgov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ingush-text
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Text normalization, palochka repair, tokenization, alphabet utilities, transliteration, and vigesimal numerals for Ingush (inh)
|
|
5
|
+
Author: Yunus Akhilgov
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://paydadosh.ru
|
|
8
|
+
Project-URL: Repository, https://github.com/paydadosh/ingush-text
|
|
9
|
+
Project-URL: Issues, https://github.com/paydadosh/ingush-text/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/paydadosh/ingush-text#readme
|
|
11
|
+
Project-URL: Changelog, https://github.com/paydadosh/ingush-text/blob/main/CHANGELOG.md
|
|
12
|
+
Project-URL: Author ORCID, https://orcid.org/0009-0008-3127-094X
|
|
13
|
+
Keywords: ingush,inh,nakh,caucasian-languages,low-resource-languages,palochka,normalization,transliteration,nlp
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# ingush-text
|
|
32
|
+
|
|
33
|
+
Zero-dependency Python library for **Ingush** (ГӀалгӀай мотт, ISO 639-3 `inh`) text processing,
|
|
34
|
+
extracted from [PaydaDosh](https://paydadosh.ru).
|
|
35
|
+
|
|
36
|
+
Built for NLP/MT pipelines, search indexing, OCR post-processing, and linguistics tools working
|
|
37
|
+
with Ingush. Other North Caucasian Cyrillic orthographies share the palochka `Ӏ` and the
|
|
38
|
+
Latin-homoglyph problems, so parts of it may be useful there too (not tested on them).
|
|
39
|
+
|
|
40
|
+
- **Pure Python >= 3.11**, zero runtime dependencies, PEP 561 typed (`py.typed`).
|
|
41
|
+
- **Palochka-aware**: `tokenize` does not split words on uppercase `Ӏ` (U+04C0) or lowercase
|
|
42
|
+
`ӏ` (U+04CF); the display helpers (`normalize_palochka_display`, `fix_palochka`, `clean_text`)
|
|
43
|
+
repair `I / l / 1 / i / І / і` next to Cyrillic (Latin `L` only inside all-caps Cyrillic,
|
|
44
|
+
`ГLАЛГLАЙ`) and leave numbers (`1941 шу`), Latin text (`Jack London 1941`), Roman numerals
|
|
45
|
+
written in Latin letters and glued to a heading (`VIIIКХАЙКАНЗА`, `Корта IIНИКЪ`) and
|
|
46
|
+
dictionary markers (`||`) alone. `clean_for_display` repairs the palochka the same way but is
|
|
47
|
+
meant for plain display text: it removes `||` and folds dashes to `-`.
|
|
48
|
+
- **Diacritic-safe**: strips dictionary stress/length/brevity marks (`да́ха`, `ха̌р`, `мӑрха`)
|
|
49
|
+
without decomposing Cyrillic `й` or `ё`.
|
|
50
|
+
- **Checked against PaydaDosh**: the search/index keys gave the same output as the site code on
|
|
51
|
+
the approved headwords and definitions and the corpus sentences of the 28.11.2026 database
|
|
52
|
+
(a check run outside CI; see [Parity with PaydaDosh](https://github.com/paydadosh/ingush-text#parity-with-paydadosh)).
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install ingush-text
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
From source:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/paydadosh/ingush-text.git
|
|
64
|
+
cd ingush-text
|
|
65
|
+
pip install -e ".[dev]"
|
|
66
|
+
pytest
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Quickstart
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
import ingush_text as it
|
|
73
|
+
|
|
74
|
+
# 1. Palochka normalization (display text — keeps numbers, Latin and Roman numerals intact)
|
|
75
|
+
it.normalize_palochka_display("1941 шу, г1алг1ай мотт, шоллагIа, Jack London, Корта IIНИКЪ")
|
|
76
|
+
# -> '1941 шу, гӀалгӀай мотт, шоллагӀа, Jack London, Корта IIНИКЪ'
|
|
77
|
+
|
|
78
|
+
# 2. OCR palochka repair (with optional wordlist for word-final positions)
|
|
79
|
+
text, fixes = it.fix_palochka("гIалгIай т1ехьаг1", known={"тӀехьагӀ"})
|
|
80
|
+
# text -> 'гӀалгӀай тӀехьагӀ'
|
|
81
|
+
|
|
82
|
+
# 3. Stress stripping & search/index normalization (preserves й and ё)
|
|
83
|
+
it.strip_stress("да́ха, гӀалгӀай, актёр") # -> 'даха, гӀалгӀай, актёр'
|
|
84
|
+
it.normalize_for_index("ГIалгIай") # -> 'гӏалгӏай'
|
|
85
|
+
it.normalize_for_search("Да́ха (идти)") # -> 'даха идти'
|
|
86
|
+
|
|
87
|
+
# 4. Palochka- and diacritic-safe tokenization
|
|
88
|
+
it.tokenize("ЦӀи, да́ха а гӀалгӀай мотт")
|
|
89
|
+
# -> ['ЦӀи', 'даха', 'а', 'гӀалгӀай', 'мотт']
|
|
90
|
+
it.length_marks("да́ха") # -> frozenset({1})
|
|
91
|
+
|
|
92
|
+
# 5. 46-letter Ingush alphabet, collation, syllables, and pattern masks
|
|
93
|
+
it.letters("аьшкхьакха")
|
|
94
|
+
# -> ['аь', 'ш', 'к', 'хь', 'а', 'кх', 'а']
|
|
95
|
+
it.syllables("лоам") # -> 1
|
|
96
|
+
sorted(["аьхка", "аят", "бер", "аз"], key=it.sort_key)
|
|
97
|
+
# -> ['аз', 'аят', 'аьхка', 'бер'] (аь is a letter after а; plain sorted() puts аьхка before аят)
|
|
98
|
+
m = it.compile_mask("гӀ<м") # < = vowel, > = consonant
|
|
99
|
+
m.match_word("гӀум") # -> True
|
|
100
|
+
|
|
101
|
+
# 6. Cyrillic -> Latin transliteration (1934 historical & Nichols ASCII)
|
|
102
|
+
it.transliterate("Аьттув хилба шун!", "1934") # -> 'Ättuv xilba šun!'
|
|
103
|
+
it.transliterate("Аьттув хилба шун!", "ascii") # -> 'Eattuv xilba shun!'
|
|
104
|
+
|
|
105
|
+
# 7. Historical 1929-1938 Ingush Latin -> Cyrillic
|
|
106
|
+
it.latin1930_to_cyrillic("Ghalghaj mott, čhoagha")
|
|
107
|
+
# -> 'ГӀалгӀай мотт, чӀоагӀа'
|
|
108
|
+
|
|
109
|
+
# 8. Vigesimal Ingush numerals (up to 10^21 - 1)
|
|
110
|
+
it.cardinal(44) # -> 'шовзткъе диъ'
|
|
111
|
+
it.ordinal(2) # -> 'шоллагӀа'
|
|
112
|
+
it.class_forms(14, "в") # -> {'collective': 'вийтте'}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Modules & API
|
|
116
|
+
|
|
117
|
+
Everything listed here is exported from the top-level package (`import ingush_text as it`).
|
|
118
|
+
Names not listed are internal and may change without notice.
|
|
119
|
+
|
|
120
|
+
| Module | Exports | Purpose |
|
|
121
|
+
|---|---|---|
|
|
122
|
+
| `ingush_text.palochka` | `PALOCHKA` (`Ӏ` U+04C0), `PALOCHKA_LOWER` (`ӏ` U+04CF), `normalize_palochka_display`, `normalize_palochka_index`, `fix_palochka`, `fix_palochka_text`, `wordlist_key`, `load_wordlist` | Display/index palochka canonicalization and deterministic OCR palochka repair |
|
|
123
|
+
| `ingush_text.normalize` | `norm_space`, `strip_stress`, `strip_accents_latin_only`, `fold_latin_homoglyphs`, `fold_ocr_lookalikes`, `normalize_for_search`, `normalize_for_index`, `normalize_definition_safe`, `clean_for_display`, `clean_text`, `is_latin_heavy` | Search/index keys (PaydaDosh rules), homoglyph cleanup, stress removal, display/dataset cleanup |
|
|
124
|
+
| `ingush_text.tokenizer` | `WORD_MARKS`, `tokenize`, `length_marks`, `length_signature` | Word tokenization without splitting on `Ӏ` or vowel-length marks |
|
|
125
|
+
| `ingush_text.alphabet` | `LETTERS_RULE`, `ALPHABET`, `DIGRAPHS`, `VOWELS`, `CONSONANTS`, `SIGNS`, `fold`, `letters`, `encode`, `decode`, `strip_length`, `n_letters`, `syllables`, `last_letter_class`, `sort_key`, `rev_key`, `Mask`, `MaskError`, `compile_mask` | 46-letter Ingush alphabet (12 digraphs, `кхь` = `к`+`хь`), PUA collation, linguistic masks |
|
|
126
|
+
| `ingush_text.translit` | `SCHEMES`, `DEFAULT_SCHEME`, `RULES`, `clean_for_translit`, `transliterate`, `transliterate_all`, `palochka_unsure` (submodule also: `data`, `tokenize_letters`) | Cyrillic-to-Latin transliteration (`1934` and Nichols-based `ascii`) |
|
|
127
|
+
| `ingush_text.latin1930` | `latin1930_to_cyrillic` (submodule also: `UNITS`, `convert_word`, `iter_tokens`) | 1929–1938 Ingush Latin to modern Cyrillic conversion |
|
|
128
|
+
| `ingush_text.numbers` | `MAX_NUMBER`, `CLASS_LETTERS`, `cardinal`, `ordinal`, `class_forms`, `class_variable`, `class_note`, `number_to_words` | Base-20 (vigesimal) Ingush numerals up to `10^21 - 1` |
|
|
129
|
+
|
|
130
|
+
## Conventions & known notes
|
|
131
|
+
|
|
132
|
+
- **Input contract:** every text function takes `str` or `None`. `None` behaves like `""` and gives
|
|
133
|
+
the empty result of the function (`""`, `[]`, `frozenset()`, `0`, `False`); `bytes` and other
|
|
134
|
+
types raise `TypeError` — decode first. `compile_mask(None)` raises `MaskError` (empty mask).
|
|
135
|
+
Numeral functions take an `int` and do not raise: `cardinal`/`ordinal` return `None` for
|
|
136
|
+
anything that is not an `int` in range (`bool` included: `cardinal(True)` is `None`, the site
|
|
137
|
+
gives `цаӏ`); `class_forms` returns `{}`, `class_variable` `[]` and `class_note` the
|
|
138
|
+
"does not vary by class" text for such input; `number_to_words` also takes a digit string,
|
|
139
|
+
treats `None` as `""` (`"error": "digits_only"`) and raises `TypeError` only on `bytes`.
|
|
140
|
+
- **Palochka code points:** display-facing functions (`normalize_palochka_display`, `fix_palochka`,
|
|
141
|
+
`clean_for_display`, `clean_text`, `cardinal`, `ordinal`) return `Ӏ` (U+04C0, `PALOCHKA`) and
|
|
142
|
+
preserve numbers and Latin text. Search/index functions (`normalize_for_index`,
|
|
143
|
+
`normalize_for_search`, `normalize_palochka_index`, `wordlist_key`) use `ӏ` (U+04CF,
|
|
144
|
+
`PALOCHKA_LOWER`) with a string-wide Cyrillic gate, so in index keys `"1941 шу"` becomes `"ӏ94ӏ шу"`.
|
|
145
|
+
`cardinal()` / `ordinal()` default to `palochka="Ӏ"`; the PaydaDosh site writes `ӏ`, pass
|
|
146
|
+
`palochka="ӏ"` to get its strings.
|
|
147
|
+
- **Roman numerals:** a run of two or more lookalikes *before* Cyrillic is left alone
|
|
148
|
+
(`Корта IIНИКЪ`, `Глава IIВОЖАТЫЙ`); a run *after* Cyrillic becomes a double palochka, which is
|
|
149
|
+
a real Ingush spelling (`теIIа` -> `теӀӀа`, `тӀӀийрг`). Not caught: a single `I` glued to a
|
|
150
|
+
heading (`Глава IВОЖАТЫЙ` -> `Глава ӀВОЖАТЫЙ`) and a numeral typed with Cyrillic `Х`
|
|
151
|
+
(`ХХХII` -> `ХХХӀӀ`): they cannot be told apart from a word.
|
|
152
|
+
- **`fix_palochka` is heuristic.** `|` and `!` are repaired only between two Cyrillic letters
|
|
153
|
+
(`ц!и` -> `цӀи`) and are kept between a lowercase and an uppercase letter (verse breaks
|
|
154
|
+
`вахар|ДӀадаьккхар`, missing spaces `Дика!Хьо`) and at the start of a token (`ер |сога`, `!хьо`);
|
|
155
|
+
word-final positions are repaired only when `known` confirms the word. Check the returned `fixes`.
|
|
156
|
+
For a big word list pass the result of `load_wordlist()` (used as is), a `frozenset` (normalized
|
|
157
|
+
once and cached) or a predicate; a `set` or `list` is normalized again on every call.
|
|
158
|
+
- **`clean_for_display` differs from the PaydaDosh function of the same name**: this one returns
|
|
159
|
+
the display palochka `Ӏ` and repairs it like `normalize_palochka_display` (next to Cyrillic only).
|
|
160
|
+
The site one returns `ӏ` and uses the string-wide index gate, so in a string with Cyrillic it
|
|
161
|
+
also turns digits and Latin letters into `ӏ` (`сантиметр 100` -> `сантиметр ӏ00`,
|
|
162
|
+
`Maple клён` -> `Mapӏe клён`); here they stay.
|
|
163
|
+
- **Pattern masks:** a mask with `**` is matched against a phrase in O(len(mask) x len(key));
|
|
164
|
+
`compile_mask` does not limit the mask length, so a service that takes masks from users should
|
|
165
|
+
(PaydaDosh accepts at most 40 characters).
|
|
166
|
+
- **`cardinal(0)`** returns the PaydaDosh site string for zero for compatibility; it is not
|
|
167
|
+
confirmed by a printed source.
|
|
168
|
+
- **No bundled dictionary data:** the wheel, the sdist and the repository contain only
|
|
169
|
+
MIT-licensed code, small linguistic tables (`ingush_latin.json`) and short test strings. The
|
|
170
|
+
reference pairs used to check parity with the site (fragments of dictionary definitions and
|
|
171
|
+
corpus texts) are not distributed. `load_wordlist()` without a path returns `None`; word-final
|
|
172
|
+
palochka repair in `fix_palochka()` accepts any user-supplied wordlist or callable `known`.
|
|
173
|
+
- **Transliteration schemes:** `1934` and `ascii` follow PaydaDosh's published draft (`draft-2026-10-31`).
|
|
174
|
+
Letters absent from the 1934 alphabet (`ё`, `щ`, `ы`, `ь`, `яь`) carry tentative mappings marked in
|
|
175
|
+
`ingush_text.translit.data()`.
|
|
176
|
+
|
|
177
|
+
## Parity with PaydaDosh
|
|
178
|
+
|
|
179
|
+
The functions below were run on the approved headwords and definitions and the corpus sentences
|
|
180
|
+
of the PaydaDosh database of 28.11.2026 next to the site code. The reference pairs are private
|
|
181
|
+
(the texts have no open license), so `tests/test_parity.py` is skipped in public CI and in the
|
|
182
|
+
sdist.
|
|
183
|
+
|
|
184
|
+
| Function | PaydaDosh code | Differences on the 28.11.2026 database, and in behaviour |
|
|
185
|
+
|---|---|---|
|
|
186
|
+
| `normalize_for_index`, `normalize_for_search` (with and without `drop_pipes`) | `app/normalize.py` | none |
|
|
187
|
+
| `normalize_palochka_display` | `app/normalize.py` | a run of two or more lookalikes after Cyrillic becomes `ӀӀ` here, `ӀI` on the site (`теIIа` -> `теӀӀа`, site `теӀIа`); Latin `L` between uppercase Cyrillic is repaired here, never on the site. On the database: 2 sentences (Roman numerals typed with Cyrillic `Х`) |
|
|
188
|
+
| `clean_text` | `tools/ml_ingush/textnorm.py` `clean` | the same, plus the circumflex is stripped: the combining `U+0302` (`Ва̂ха` -> `Ваха`) and precomposed Latin letters with it (`êtes` -> `etes`, `Ô` -> `O`); on the database: 15 strings |
|
|
189
|
+
| `fix_palochka` | `app/services/text_ocr.py` | a run of two or more letter lookalikes between Cyrillic letters becomes a double palochka here and is left as is on the site (`теIIа` -> `теӀӀа`, `тIIийрг` -> `тӀӀийрг`; site `теIIа`, `тIIийрг`); a Ukrainian `і` / `І` right after a repaired lookalike is repaired too (`а1і` -> `аӀӀ`, site `аӀі`); `\|` / `!` between a lowercase and an uppercase letter is kept (verse breaks); Latin `L` as above; on the database: 80 sentences |
|
|
190
|
+
| `tokenize` | `query_tokens` | a token made only of `\|` (`\|`, `\|\|`, `\|\|\|`) is dropped here (`мотт \|\| лоам` -> `['мотт', 'лоам']`), kept as a token on the site |
|
|
191
|
+
| `clean_for_display` | `app/normalize.py` | a different function by design: see *Conventions* above |
|
|
192
|
+
| `strip_stress`, `strip_accents_latin_only` | `app/normalize.py` | the input is composed (NFC) first, so a decomposed accent after a Latin letter is removed (`X` + `U+0301` -> `X`, the site keeps it) and a decomposed `а` + `U+0306` is treated like `ӑ` by `strip_stress` (-> `а`, the site keeps it) |
|
|
193
|
+
|
|
194
|
+
Other functions (alphabet, transliteration, numerals) are tested against the fixtures shared with
|
|
195
|
+
the site (`tests/fixtures/`), not against the whole database.
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
|
|
199
|
+
**MIT** — see [LICENSE](https://github.com/paydadosh/ingush-text/blob/main/LICENSE). Copyright (c) 2026 Yunus Akhilgov.
|
|
200
|
+
|
|
201
|
+
## How to cite
|
|
202
|
+
|
|
203
|
+
See [CITATION.cff](https://github.com/paydadosh/ingush-text/blob/main/CITATION.cff), or:
|
|
204
|
+
|
|
205
|
+
> Akhilgov, Y. (2026). *ingush-text: text normalization, palochka repair, alphabet utilities,
|
|
206
|
+
> transliteration, and numerals for Ingush* (version 0.1.0). https://github.com/paydadosh/ingush-text
|
|
207
|
+
|
|
208
|
+
## Contact & related projects
|
|
209
|
+
|
|
210
|
+
- Website: <https://paydadosh.ru> · Telegram: [@paydadosh](https://t.me/paydadosh)
|
|
211
|
+
- [paydadosh-mcp](https://github.com/paydadosh/paydadosh-mcp) — open MCP server for the Ingush dictionary
|
|
212
|
+
- [ingush-frequency](https://github.com/paydadosh/ingush-frequency) — Ingush lemma frequency dictionary (27,774 words, CC BY 4.0)
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Кратко по-русски
|
|
217
|
+
|
|
218
|
+
`ingush-text` — открытая библиотека Python 3.11+ без внешних зависимостей (лицензия MIT) для работы с
|
|
219
|
+
ингушским текстом, вынесенная из проекта [PaydaDosh](https://paydadosh.ru):
|
|
220
|
+
|
|
221
|
+
- нормализация и починка палочки `Ӏ` (`U+04C0` / `U+04CF`) без порчи чисел (`1941 шу`), латиницы,
|
|
222
|
+
римских цифр (`Корта IIНИКЪ`) и `||`;
|
|
223
|
+
- снятие ударений и пометок краткости с сохранением `й` и `ё`, свёртка латинских двойников;
|
|
224
|
+
- токенизация без разрыва слов на прописной палочке `Ӏ` и знаке долготы;
|
|
225
|
+
- 46-буквенный ингушский алфавит (12 диграфов, разбор `кхь = к + хь`), алфавитная сортировка, подсчёт слогов и поиск по маскам;
|
|
226
|
+
- транслитерация кириллицы в латиницу (`1934` и `ascii` по Николс) и обратное переложение латиницы 1929–1938 гг. в кириллицу;
|
|
227
|
+
- двадцатеричные ингушские числительные прописью до `10^21 - 1` (количественные, порядковые и классные формы).
|
|
228
|
+
|
|
229
|
+
Ключи поиска и индекса совпали с кодом сайта на базе от 28.11.2026 (проверка вне CI: эталонные пары
|
|
230
|
+
из текстов словарей и корпуса не распространяются); где и почему отличаются функции показа и починки
|
|
231
|
+
палочки — в разделе «Parity with PaydaDosh».
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# ingush-text
|
|
2
|
+
|
|
3
|
+
Zero-dependency Python library for **Ingush** (ГӀалгӀай мотт, ISO 639-3 `inh`) text processing,
|
|
4
|
+
extracted from [PaydaDosh](https://paydadosh.ru).
|
|
5
|
+
|
|
6
|
+
Built for NLP/MT pipelines, search indexing, OCR post-processing, and linguistics tools working
|
|
7
|
+
with Ingush. Other North Caucasian Cyrillic orthographies share the palochka `Ӏ` and the
|
|
8
|
+
Latin-homoglyph problems, so parts of it may be useful there too (not tested on them).
|
|
9
|
+
|
|
10
|
+
- **Pure Python >= 3.11**, zero runtime dependencies, PEP 561 typed (`py.typed`).
|
|
11
|
+
- **Palochka-aware**: `tokenize` does not split words on uppercase `Ӏ` (U+04C0) or lowercase
|
|
12
|
+
`ӏ` (U+04CF); the display helpers (`normalize_palochka_display`, `fix_palochka`, `clean_text`)
|
|
13
|
+
repair `I / l / 1 / i / І / і` next to Cyrillic (Latin `L` only inside all-caps Cyrillic,
|
|
14
|
+
`ГLАЛГLАЙ`) and leave numbers (`1941 шу`), Latin text (`Jack London 1941`), Roman numerals
|
|
15
|
+
written in Latin letters and glued to a heading (`VIIIКХАЙКАНЗА`, `Корта IIНИКЪ`) and
|
|
16
|
+
dictionary markers (`||`) alone. `clean_for_display` repairs the palochka the same way but is
|
|
17
|
+
meant for plain display text: it removes `||` and folds dashes to `-`.
|
|
18
|
+
- **Diacritic-safe**: strips dictionary stress/length/brevity marks (`да́ха`, `ха̌р`, `мӑрха`)
|
|
19
|
+
without decomposing Cyrillic `й` or `ё`.
|
|
20
|
+
- **Checked against PaydaDosh**: the search/index keys gave the same output as the site code on
|
|
21
|
+
the approved headwords and definitions and the corpus sentences of the 28.11.2026 database
|
|
22
|
+
(a check run outside CI; see [Parity with PaydaDosh](https://github.com/paydadosh/ingush-text#parity-with-paydadosh)).
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install ingush-text
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
From source:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/paydadosh/ingush-text.git
|
|
34
|
+
cd ingush-text
|
|
35
|
+
pip install -e ".[dev]"
|
|
36
|
+
pytest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Quickstart
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import ingush_text as it
|
|
43
|
+
|
|
44
|
+
# 1. Palochka normalization (display text — keeps numbers, Latin and Roman numerals intact)
|
|
45
|
+
it.normalize_palochka_display("1941 шу, г1алг1ай мотт, шоллагIа, Jack London, Корта IIНИКЪ")
|
|
46
|
+
# -> '1941 шу, гӀалгӀай мотт, шоллагӀа, Jack London, Корта IIНИКЪ'
|
|
47
|
+
|
|
48
|
+
# 2. OCR palochka repair (with optional wordlist for word-final positions)
|
|
49
|
+
text, fixes = it.fix_palochka("гIалгIай т1ехьаг1", known={"тӀехьагӀ"})
|
|
50
|
+
# text -> 'гӀалгӀай тӀехьагӀ'
|
|
51
|
+
|
|
52
|
+
# 3. Stress stripping & search/index normalization (preserves й and ё)
|
|
53
|
+
it.strip_stress("да́ха, гӀалгӀай, актёр") # -> 'даха, гӀалгӀай, актёр'
|
|
54
|
+
it.normalize_for_index("ГIалгIай") # -> 'гӏалгӏай'
|
|
55
|
+
it.normalize_for_search("Да́ха (идти)") # -> 'даха идти'
|
|
56
|
+
|
|
57
|
+
# 4. Palochka- and diacritic-safe tokenization
|
|
58
|
+
it.tokenize("ЦӀи, да́ха а гӀалгӀай мотт")
|
|
59
|
+
# -> ['ЦӀи', 'даха', 'а', 'гӀалгӀай', 'мотт']
|
|
60
|
+
it.length_marks("да́ха") # -> frozenset({1})
|
|
61
|
+
|
|
62
|
+
# 5. 46-letter Ingush alphabet, collation, syllables, and pattern masks
|
|
63
|
+
it.letters("аьшкхьакха")
|
|
64
|
+
# -> ['аь', 'ш', 'к', 'хь', 'а', 'кх', 'а']
|
|
65
|
+
it.syllables("лоам") # -> 1
|
|
66
|
+
sorted(["аьхка", "аят", "бер", "аз"], key=it.sort_key)
|
|
67
|
+
# -> ['аз', 'аят', 'аьхка', 'бер'] (аь is a letter after а; plain sorted() puts аьхка before аят)
|
|
68
|
+
m = it.compile_mask("гӀ<м") # < = vowel, > = consonant
|
|
69
|
+
m.match_word("гӀум") # -> True
|
|
70
|
+
|
|
71
|
+
# 6. Cyrillic -> Latin transliteration (1934 historical & Nichols ASCII)
|
|
72
|
+
it.transliterate("Аьттув хилба шун!", "1934") # -> 'Ättuv xilba šun!'
|
|
73
|
+
it.transliterate("Аьттув хилба шун!", "ascii") # -> 'Eattuv xilba shun!'
|
|
74
|
+
|
|
75
|
+
# 7. Historical 1929-1938 Ingush Latin -> Cyrillic
|
|
76
|
+
it.latin1930_to_cyrillic("Ghalghaj mott, čhoagha")
|
|
77
|
+
# -> 'ГӀалгӀай мотт, чӀоагӀа'
|
|
78
|
+
|
|
79
|
+
# 8. Vigesimal Ingush numerals (up to 10^21 - 1)
|
|
80
|
+
it.cardinal(44) # -> 'шовзткъе диъ'
|
|
81
|
+
it.ordinal(2) # -> 'шоллагӀа'
|
|
82
|
+
it.class_forms(14, "в") # -> {'collective': 'вийтте'}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Modules & API
|
|
86
|
+
|
|
87
|
+
Everything listed here is exported from the top-level package (`import ingush_text as it`).
|
|
88
|
+
Names not listed are internal and may change without notice.
|
|
89
|
+
|
|
90
|
+
| Module | Exports | Purpose |
|
|
91
|
+
|---|---|---|
|
|
92
|
+
| `ingush_text.palochka` | `PALOCHKA` (`Ӏ` U+04C0), `PALOCHKA_LOWER` (`ӏ` U+04CF), `normalize_palochka_display`, `normalize_palochka_index`, `fix_palochka`, `fix_palochka_text`, `wordlist_key`, `load_wordlist` | Display/index palochka canonicalization and deterministic OCR palochka repair |
|
|
93
|
+
| `ingush_text.normalize` | `norm_space`, `strip_stress`, `strip_accents_latin_only`, `fold_latin_homoglyphs`, `fold_ocr_lookalikes`, `normalize_for_search`, `normalize_for_index`, `normalize_definition_safe`, `clean_for_display`, `clean_text`, `is_latin_heavy` | Search/index keys (PaydaDosh rules), homoglyph cleanup, stress removal, display/dataset cleanup |
|
|
94
|
+
| `ingush_text.tokenizer` | `WORD_MARKS`, `tokenize`, `length_marks`, `length_signature` | Word tokenization without splitting on `Ӏ` or vowel-length marks |
|
|
95
|
+
| `ingush_text.alphabet` | `LETTERS_RULE`, `ALPHABET`, `DIGRAPHS`, `VOWELS`, `CONSONANTS`, `SIGNS`, `fold`, `letters`, `encode`, `decode`, `strip_length`, `n_letters`, `syllables`, `last_letter_class`, `sort_key`, `rev_key`, `Mask`, `MaskError`, `compile_mask` | 46-letter Ingush alphabet (12 digraphs, `кхь` = `к`+`хь`), PUA collation, linguistic masks |
|
|
96
|
+
| `ingush_text.translit` | `SCHEMES`, `DEFAULT_SCHEME`, `RULES`, `clean_for_translit`, `transliterate`, `transliterate_all`, `palochka_unsure` (submodule also: `data`, `tokenize_letters`) | Cyrillic-to-Latin transliteration (`1934` and Nichols-based `ascii`) |
|
|
97
|
+
| `ingush_text.latin1930` | `latin1930_to_cyrillic` (submodule also: `UNITS`, `convert_word`, `iter_tokens`) | 1929–1938 Ingush Latin to modern Cyrillic conversion |
|
|
98
|
+
| `ingush_text.numbers` | `MAX_NUMBER`, `CLASS_LETTERS`, `cardinal`, `ordinal`, `class_forms`, `class_variable`, `class_note`, `number_to_words` | Base-20 (vigesimal) Ingush numerals up to `10^21 - 1` |
|
|
99
|
+
|
|
100
|
+
## Conventions & known notes
|
|
101
|
+
|
|
102
|
+
- **Input contract:** every text function takes `str` or `None`. `None` behaves like `""` and gives
|
|
103
|
+
the empty result of the function (`""`, `[]`, `frozenset()`, `0`, `False`); `bytes` and other
|
|
104
|
+
types raise `TypeError` — decode first. `compile_mask(None)` raises `MaskError` (empty mask).
|
|
105
|
+
Numeral functions take an `int` and do not raise: `cardinal`/`ordinal` return `None` for
|
|
106
|
+
anything that is not an `int` in range (`bool` included: `cardinal(True)` is `None`, the site
|
|
107
|
+
gives `цаӏ`); `class_forms` returns `{}`, `class_variable` `[]` and `class_note` the
|
|
108
|
+
"does not vary by class" text for such input; `number_to_words` also takes a digit string,
|
|
109
|
+
treats `None` as `""` (`"error": "digits_only"`) and raises `TypeError` only on `bytes`.
|
|
110
|
+
- **Palochka code points:** display-facing functions (`normalize_palochka_display`, `fix_palochka`,
|
|
111
|
+
`clean_for_display`, `clean_text`, `cardinal`, `ordinal`) return `Ӏ` (U+04C0, `PALOCHKA`) and
|
|
112
|
+
preserve numbers and Latin text. Search/index functions (`normalize_for_index`,
|
|
113
|
+
`normalize_for_search`, `normalize_palochka_index`, `wordlist_key`) use `ӏ` (U+04CF,
|
|
114
|
+
`PALOCHKA_LOWER`) with a string-wide Cyrillic gate, so in index keys `"1941 шу"` becomes `"ӏ94ӏ шу"`.
|
|
115
|
+
`cardinal()` / `ordinal()` default to `palochka="Ӏ"`; the PaydaDosh site writes `ӏ`, pass
|
|
116
|
+
`palochka="ӏ"` to get its strings.
|
|
117
|
+
- **Roman numerals:** a run of two or more lookalikes *before* Cyrillic is left alone
|
|
118
|
+
(`Корта IIНИКЪ`, `Глава IIВОЖАТЫЙ`); a run *after* Cyrillic becomes a double palochka, which is
|
|
119
|
+
a real Ingush spelling (`теIIа` -> `теӀӀа`, `тӀӀийрг`). Not caught: a single `I` glued to a
|
|
120
|
+
heading (`Глава IВОЖАТЫЙ` -> `Глава ӀВОЖАТЫЙ`) and a numeral typed with Cyrillic `Х`
|
|
121
|
+
(`ХХХII` -> `ХХХӀӀ`): they cannot be told apart from a word.
|
|
122
|
+
- **`fix_palochka` is heuristic.** `|` and `!` are repaired only between two Cyrillic letters
|
|
123
|
+
(`ц!и` -> `цӀи`) and are kept between a lowercase and an uppercase letter (verse breaks
|
|
124
|
+
`вахар|ДӀадаьккхар`, missing spaces `Дика!Хьо`) and at the start of a token (`ер |сога`, `!хьо`);
|
|
125
|
+
word-final positions are repaired only when `known` confirms the word. Check the returned `fixes`.
|
|
126
|
+
For a big word list pass the result of `load_wordlist()` (used as is), a `frozenset` (normalized
|
|
127
|
+
once and cached) or a predicate; a `set` or `list` is normalized again on every call.
|
|
128
|
+
- **`clean_for_display` differs from the PaydaDosh function of the same name**: this one returns
|
|
129
|
+
the display palochka `Ӏ` and repairs it like `normalize_palochka_display` (next to Cyrillic only).
|
|
130
|
+
The site one returns `ӏ` and uses the string-wide index gate, so in a string with Cyrillic it
|
|
131
|
+
also turns digits and Latin letters into `ӏ` (`сантиметр 100` -> `сантиметр ӏ00`,
|
|
132
|
+
`Maple клён` -> `Mapӏe клён`); here they stay.
|
|
133
|
+
- **Pattern masks:** a mask with `**` is matched against a phrase in O(len(mask) x len(key));
|
|
134
|
+
`compile_mask` does not limit the mask length, so a service that takes masks from users should
|
|
135
|
+
(PaydaDosh accepts at most 40 characters).
|
|
136
|
+
- **`cardinal(0)`** returns the PaydaDosh site string for zero for compatibility; it is not
|
|
137
|
+
confirmed by a printed source.
|
|
138
|
+
- **No bundled dictionary data:** the wheel, the sdist and the repository contain only
|
|
139
|
+
MIT-licensed code, small linguistic tables (`ingush_latin.json`) and short test strings. The
|
|
140
|
+
reference pairs used to check parity with the site (fragments of dictionary definitions and
|
|
141
|
+
corpus texts) are not distributed. `load_wordlist()` without a path returns `None`; word-final
|
|
142
|
+
palochka repair in `fix_palochka()` accepts any user-supplied wordlist or callable `known`.
|
|
143
|
+
- **Transliteration schemes:** `1934` and `ascii` follow PaydaDosh's published draft (`draft-2026-10-31`).
|
|
144
|
+
Letters absent from the 1934 alphabet (`ё`, `щ`, `ы`, `ь`, `яь`) carry tentative mappings marked in
|
|
145
|
+
`ingush_text.translit.data()`.
|
|
146
|
+
|
|
147
|
+
## Parity with PaydaDosh
|
|
148
|
+
|
|
149
|
+
The functions below were run on the approved headwords and definitions and the corpus sentences
|
|
150
|
+
of the PaydaDosh database of 28.11.2026 next to the site code. The reference pairs are private
|
|
151
|
+
(the texts have no open license), so `tests/test_parity.py` is skipped in public CI and in the
|
|
152
|
+
sdist.
|
|
153
|
+
|
|
154
|
+
| Function | PaydaDosh code | Differences on the 28.11.2026 database, and in behaviour |
|
|
155
|
+
|---|---|---|
|
|
156
|
+
| `normalize_for_index`, `normalize_for_search` (with and without `drop_pipes`) | `app/normalize.py` | none |
|
|
157
|
+
| `normalize_palochka_display` | `app/normalize.py` | a run of two or more lookalikes after Cyrillic becomes `ӀӀ` here, `ӀI` on the site (`теIIа` -> `теӀӀа`, site `теӀIа`); Latin `L` between uppercase Cyrillic is repaired here, never on the site. On the database: 2 sentences (Roman numerals typed with Cyrillic `Х`) |
|
|
158
|
+
| `clean_text` | `tools/ml_ingush/textnorm.py` `clean` | the same, plus the circumflex is stripped: the combining `U+0302` (`Ва̂ха` -> `Ваха`) and precomposed Latin letters with it (`êtes` -> `etes`, `Ô` -> `O`); on the database: 15 strings |
|
|
159
|
+
| `fix_palochka` | `app/services/text_ocr.py` | a run of two or more letter lookalikes between Cyrillic letters becomes a double palochka here and is left as is on the site (`теIIа` -> `теӀӀа`, `тIIийрг` -> `тӀӀийрг`; site `теIIа`, `тIIийрг`); a Ukrainian `і` / `І` right after a repaired lookalike is repaired too (`а1і` -> `аӀӀ`, site `аӀі`); `\|` / `!` between a lowercase and an uppercase letter is kept (verse breaks); Latin `L` as above; on the database: 80 sentences |
|
|
160
|
+
| `tokenize` | `query_tokens` | a token made only of `\|` (`\|`, `\|\|`, `\|\|\|`) is dropped here (`мотт \|\| лоам` -> `['мотт', 'лоам']`), kept as a token on the site |
|
|
161
|
+
| `clean_for_display` | `app/normalize.py` | a different function by design: see *Conventions* above |
|
|
162
|
+
| `strip_stress`, `strip_accents_latin_only` | `app/normalize.py` | the input is composed (NFC) first, so a decomposed accent after a Latin letter is removed (`X` + `U+0301` -> `X`, the site keeps it) and a decomposed `а` + `U+0306` is treated like `ӑ` by `strip_stress` (-> `а`, the site keeps it) |
|
|
163
|
+
|
|
164
|
+
Other functions (alphabet, transliteration, numerals) are tested against the fixtures shared with
|
|
165
|
+
the site (`tests/fixtures/`), not against the whole database.
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
**MIT** — see [LICENSE](https://github.com/paydadosh/ingush-text/blob/main/LICENSE). Copyright (c) 2026 Yunus Akhilgov.
|
|
170
|
+
|
|
171
|
+
## How to cite
|
|
172
|
+
|
|
173
|
+
See [CITATION.cff](https://github.com/paydadosh/ingush-text/blob/main/CITATION.cff), or:
|
|
174
|
+
|
|
175
|
+
> Akhilgov, Y. (2026). *ingush-text: text normalization, palochka repair, alphabet utilities,
|
|
176
|
+
> transliteration, and numerals for Ingush* (version 0.1.0). https://github.com/paydadosh/ingush-text
|
|
177
|
+
|
|
178
|
+
## Contact & related projects
|
|
179
|
+
|
|
180
|
+
- Website: <https://paydadosh.ru> · Telegram: [@paydadosh](https://t.me/paydadosh)
|
|
181
|
+
- [paydadosh-mcp](https://github.com/paydadosh/paydadosh-mcp) — open MCP server for the Ingush dictionary
|
|
182
|
+
- [ingush-frequency](https://github.com/paydadosh/ingush-frequency) — Ingush lemma frequency dictionary (27,774 words, CC BY 4.0)
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Кратко по-русски
|
|
187
|
+
|
|
188
|
+
`ingush-text` — открытая библиотека Python 3.11+ без внешних зависимостей (лицензия MIT) для работы с
|
|
189
|
+
ингушским текстом, вынесенная из проекта [PaydaDosh](https://paydadosh.ru):
|
|
190
|
+
|
|
191
|
+
- нормализация и починка палочки `Ӏ` (`U+04C0` / `U+04CF`) без порчи чисел (`1941 шу`), латиницы,
|
|
192
|
+
римских цифр (`Корта IIНИКЪ`) и `||`;
|
|
193
|
+
- снятие ударений и пометок краткости с сохранением `й` и `ё`, свёртка латинских двойников;
|
|
194
|
+
- токенизация без разрыва слов на прописной палочке `Ӏ` и знаке долготы;
|
|
195
|
+
- 46-буквенный ингушский алфавит (12 диграфов, разбор `кхь = к + хь`), алфавитная сортировка, подсчёт слогов и поиск по маскам;
|
|
196
|
+
- транслитерация кириллицы в латиницу (`1934` и `ascii` по Николс) и обратное переложение латиницы 1929–1938 гг. в кириллицу;
|
|
197
|
+
- двадцатеричные ингушские числительные прописью до `10^21 - 1` (количественные, порядковые и классные формы).
|
|
198
|
+
|
|
199
|
+
Ключи поиска и индекса совпали с кодом сайта на базе от 28.11.2026 (проверка вне CI: эталонные пары
|
|
200
|
+
из текстов словарей и корпуса не распространяются); где и почему отличаются функции показа и починки
|
|
201
|
+
палочки — в разделе «Parity with PaydaDosh».
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ingush-text"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Text normalization, palochka repair, tokenization, alphabet utilities, transliteration, and vigesimal numerals for Ingush (inh)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "Yunus Akhilgov"},
|
|
15
|
+
]
|
|
16
|
+
keywords = [
|
|
17
|
+
"ingush",
|
|
18
|
+
"inh",
|
|
19
|
+
"nakh",
|
|
20
|
+
"caucasian-languages",
|
|
21
|
+
"low-resource-languages",
|
|
22
|
+
"palochka",
|
|
23
|
+
"normalization",
|
|
24
|
+
"transliteration",
|
|
25
|
+
"nlp",
|
|
26
|
+
]
|
|
27
|
+
classifiers = [
|
|
28
|
+
"Development Status :: 4 - Beta",
|
|
29
|
+
"Intended Audience :: Developers",
|
|
30
|
+
"Intended Audience :: Science/Research",
|
|
31
|
+
"Operating System :: OS Independent",
|
|
32
|
+
"Programming Language :: Python :: 3",
|
|
33
|
+
"Programming Language :: Python :: 3.11",
|
|
34
|
+
"Programming Language :: Python :: 3.12",
|
|
35
|
+
"Programming Language :: Python :: 3.13",
|
|
36
|
+
"Topic :: Text Processing :: Linguistic",
|
|
37
|
+
"Typing :: Typed",
|
|
38
|
+
]
|
|
39
|
+
dependencies = []
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
dev = ["pytest>=7.0"]
|
|
43
|
+
|
|
44
|
+
[project.urls]
|
|
45
|
+
Homepage = "https://paydadosh.ru"
|
|
46
|
+
Repository = "https://github.com/paydadosh/ingush-text"
|
|
47
|
+
Issues = "https://github.com/paydadosh/ingush-text/issues"
|
|
48
|
+
Documentation = "https://github.com/paydadosh/ingush-text#readme"
|
|
49
|
+
Changelog = "https://github.com/paydadosh/ingush-text/blob/main/CHANGELOG.md"
|
|
50
|
+
"Author ORCID" = "https://orcid.org/0009-0008-3127-094X"
|
|
51
|
+
|
|
52
|
+
[tool.setuptools]
|
|
53
|
+
package-dir = {"" = "src"}
|
|
54
|
+
|
|
55
|
+
[tool.setuptools.packages.find]
|
|
56
|
+
where = ["src"]
|
|
57
|
+
|
|
58
|
+
[tool.setuptools.package-data]
|
|
59
|
+
ingush_text = ["py.typed", "data/*.json"]
|
|
60
|
+
|
|
61
|
+
[tool.pytest.ini_options]
|
|
62
|
+
testpaths = ["tests"]
|