ingush-text
Zero-dependency Python library for Ingush (ГӀалгӀай мотт, ISO 639-3 inh) text processing,
extracted from PaydaDosh.
Built for NLP/MT pipelines, search indexing, OCR post-processing, and linguistics tools working
with Ingush. Other North Caucasian Cyrillic orthographies share the palochka Ӏ and the
Latin-homoglyph problems, so parts of it may be useful there too (not tested on them).
- Pure Python >= 3.11, zero runtime dependencies, PEP 561 typed (
py.typed). - Palochka-aware:
tokenizedoes not split words on uppercaseӀ(U+04C0) or lowercaseӏ(U+04CF); the display helpers (normalize_palochka_display,fix_palochka,clean_text) repairI / l / 1 / i / І / іnext to Cyrillic (LatinLonly inside all-caps Cyrillic,ГLАЛГLАЙ) and leave numbers (1941 шу), Latin text (Jack London 1941), Roman numerals written in Latin letters and glued to a heading (VIIIКХАЙКАНЗА,Корта IIНИКЪ) and dictionary markers (||) alone.clean_for_displayrepairs the palochka the same way but is meant for plain display text: it removes||and folds dashes to-. - Diacritic-safe: strips dictionary stress/length/brevity marks (
да́ха,ха̌р,мӑрха) without decomposing Cyrillicйorё. - Checked against PaydaDosh: the search/index keys gave the same output as the site code on the approved headwords and definitions and the corpus sentences of the 28.11.2026 database (a check run outside CI; see Parity with PaydaDosh).
Install
pip install ingush-text
From source:
git clone https://github.com/paydadosh/ingush-text.git
cd ingush-text
pip install -e ".[dev]"
pytest
Quickstart
import ingush_text as it
# 1. Palochka normalization (display text — keeps numbers, Latin and Roman numerals intact)
it.normalize_palochka_display("1941 шу, г1алг1ай мотт, шоллагIа, Jack London, Корта IIНИКЪ")
# -> '1941 шу, гӀалгӀай мотт, шоллагӀа, Jack London, Корта IIНИКЪ'
# 2. OCR palochka repair (with optional wordlist for word-final positions)
text, fixes = it.fix_palochka("гIалгIай т1ехьаг1", known={"тӀехьагӀ"})
# text -> 'гӀалгӀай тӀехьагӀ'
# 3. Stress stripping & search/index normalization (preserves й and ё)
it.strip_stress("да́ха, гӀалгӀай, актёр") # -> 'даха, гӀалгӀай, актёр'
it.normalize_for_index("ГIалгIай") # -> 'гӏалгӏай'
it.normalize_for_search("Да́ха (идти)") # -> 'даха идти'
# 4. Palochka- and diacritic-safe tokenization
it.tokenize("ЦӀи, да́ха а гӀалгӀай мотт")
# -> ['ЦӀи', 'даха', 'а', 'гӀалгӀай', 'мотт']
it.length_marks("да́ха") # -> frozenset({1})
# 5. 46-letter Ingush alphabet, collation, syllables, and pattern masks
it.letters("аьшкхьакха")
# -> ['аь', 'ш', 'к', 'хь', 'а', 'кх', 'а']
it.syllables("лоам") # -> 1
sorted(["аьхка", "аят", "бер", "аз"], key=it.sort_key)
# -> ['аз', 'аят', 'аьхка', 'бер'] (аь is a letter after а; plain sorted() puts аьхка before аят)
m = it.compile_mask("гӀ<м") # < = vowel, > = consonant
m.match_word("гӀум") # -> True
# 6. Cyrillic -> Latin transliteration (1934 historical & Nichols ASCII)
it.transliterate("Аьттув хилба шун!", "1934") # -> 'Ättuv xilba šun!'
it.transliterate("Аьттув хилба шун!", "ascii") # -> 'Eattuv xilba shun!'
# 7. Historical 1929-1938 Ingush Latin -> Cyrillic
it.latin1930_to_cyrillic("Ghalghaj mott, čhoagha")
# -> 'ГӀалгӀай мотт, чӀоагӀа'
# 8. Vigesimal Ingush numerals (up to 10^21 - 1)
it.cardinal(44) # -> 'шовзткъе диъ'
it.ordinal(2) # -> 'шоллагӀа'
it.class_forms(14, "в") # -> {'collective': 'вийтте'}
Modules & API
Everything listed here is exported from the top-level package (import ingush_text as it).
Names not listed are internal and may change without notice.
| Module | Exports | Purpose |
|---|---|---|
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 |
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 |
ingush_text.tokenizer |
WORD_MARKS, tokenize, length_marks, length_signature |
Word tokenization without splitting on Ӏ or vowel-length marks |
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 |
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) |
ingush_text.latin1930 |
latin1930_to_cyrillic (submodule also: UNITS, convert_word, iter_tokens) |
1929–1938 Ingush Latin to modern Cyrillic conversion |
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 |
Conventions & known notes
- Input contract: every text function takes
strorNone.Nonebehaves like""and gives the empty result of the function ("",[],frozenset(),0,False);bytesand other types raiseTypeError— decode first.compile_mask(None)raisesMaskError(empty mask). Numeral functions take anintand do not raise:cardinal/ordinalreturnNonefor anything that is not anintin range (boolincluded:cardinal(True)isNone, the site givesцаӏ);class_formsreturns{},class_variable[]andclass_notethe "does not vary by class" text for such input;number_to_wordsalso takes a digit string, treatsNoneas""("error": "digits_only") and raisesTypeErroronly onbytes. - Palochka code points: display-facing functions (
normalize_palochka_display,fix_palochka,clean_for_display,clean_text,cardinal,ordinal) returnӀ(U+04C0,PALOCHKA) and preserve numbers and Latin text. Search/index functions (normalize_for_index,normalize_for_search,normalize_palochka_index,wordlist_key) useӏ(U+04CF,PALOCHKA_LOWER) with a string-wide Cyrillic gate, so in index keys"1941 шу"becomes"ӏ94ӏ шу".cardinal()/ordinal()default topalochka="Ӏ"; the PaydaDosh site writesӏ, passpalochka="ӏ"to get its strings. - Roman numerals: a run of two or more lookalikes before Cyrillic is left alone
(
Корта IIНИКЪ,Глава IIВОЖАТЫЙ); a run after Cyrillic becomes a double palochka, which is a real Ingush spelling (теIIа->теӀӀа,тӀӀийрг). Not caught: a singleIglued to a heading (Глава IВОЖАТЫЙ->Глава ӀВОЖАТЫЙ) and a numeral typed with CyrillicХ(ХХХII->ХХХӀӀ): they cannot be told apart from a word. fix_palochkais heuristic.|and!are repaired only between two Cyrillic letters (ц!и->цӀи) and are kept between a lowercase and an uppercase letter (verse breaksвахар|ДӀадаьккхар, missing spacesДика!Хьо) and at the start of a token (ер |сога,!хьо); word-final positions are repaired only whenknownconfirms the word. Check the returnedfixes. For a big word list pass the result ofload_wordlist()(used as is), afrozenset(normalized once and cached) or a predicate; asetorlistis normalized again on every call.clean_for_displaydiffers from the PaydaDosh function of the same name: this one returns the display palochkaӀand repairs it likenormalize_palochka_display(next to Cyrillic only). The site one returnsӏand uses the string-wide index gate, so in a string with Cyrillic it also turns digits and Latin letters intoӏ(сантиметр 100->сантиметр ӏ00,Maple клён->Mapӏe клён); here they stay.- Pattern masks: a mask with
**is matched against a phrase in O(len(mask) x len(key));compile_maskdoes not limit the mask length, so a service that takes masks from users should (PaydaDosh accepts at most 40 characters). cardinal(0)returns the PaydaDosh site string for zero for compatibility; it is not confirmed by a printed source.- No bundled dictionary data: the wheel, the sdist and the repository contain only
MIT-licensed code, small linguistic tables (
ingush_latin.json) and short test strings. The reference pairs used to check parity with the site (fragments of dictionary definitions and corpus texts) are not distributed.load_wordlist()without a path returnsNone; word-final palochka repair infix_palochka()accepts any user-supplied wordlist or callableknown. - Transliteration schemes:
1934andasciifollow PaydaDosh's published draft (draft-2026-10-31). Letters absent from the 1934 alphabet (ё,щ,ы,ь,яь) carry tentative mappings marked iningush_text.translit.data().
Parity with PaydaDosh
The functions below were run on the approved headwords and definitions and the corpus sentences
of the PaydaDosh database of 28.11.2026 next to the site code. The reference pairs are private
(the texts have no open license), so tests/test_parity.py is skipped in public CI and in the
sdist.
| Function | PaydaDosh code | Differences on the 28.11.2026 database, and in behaviour |
|---|---|---|
normalize_for_index, normalize_for_search (with and without drop_pipes) |
app/normalize.py |
none |
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 Х) |
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 |
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 |
tokenize |
query_tokens |
a token made only of | (|, ||, |||) is dropped here (мотт || лоам -> ['мотт', 'лоам']), kept as a token on the site |
clean_for_display |
app/normalize.py |
a different function by design: see Conventions above |
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) |
Other functions (alphabet, transliteration, numerals) are tested against the fixtures shared with
the site (tests/fixtures/), not against the whole database.
License
MIT — see LICENSE. Copyright (c) 2026 Yunus Akhilgov.
How to cite
See CITATION.cff, or:
Akhilgov, Y. (2026). ingush-text: text normalization, palochka repair, alphabet utilities, transliteration, and numerals for Ingush (version 0.1.0). https://github.com/paydadosh/ingush-text
Contact & related projects
- Website: https://paydadosh.ru · Telegram: @paydadosh
- paydadosh-mcp — open MCP server for the Ingush dictionary
- ingush-frequency — Ingush lemma frequency dictionary (27,774 words, CC BY 4.0)
Кратко по-русски
ingush-text — открытая библиотека Python 3.11+ без внешних зависимостей (лицензия MIT) для работы с
ингушским текстом, вынесенная из проекта PaydaDosh:
- нормализация и починка палочки
Ӏ(U+04C0/U+04CF) без порчи чисел (1941 шу), латиницы, римских цифр (Корта IIНИКЪ) и||; - снятие ударений и пометок краткости с сохранением
йиё, свёртка латинских двойников; - токенизация без разрыва слов на прописной палочке
Ӏи знаке долготы; - 46-буквенный ингушский алфавит (12 диграфов, разбор
кхь = к + хь), алфавитная сортировка, подсчёт слогов и поиск по маскам; - транслитерация кириллицы в латиницу (
1934иasciiпо Николс) и обратное переложение латиницы 1929–1938 гг. в кириллицу; - двадцатеричные ингушские числительные прописью до
10^21 - 1(количественные, порядковые и классные формы).
Ключи поиска и индекса совпали с кодом сайта на базе от 28.11.2026 (проверка вне CI: эталонные пары из текстов словарей и корпуса не распространяются); где и почему отличаются функции показа и починки палочки — в разделе «Parity with PaydaDosh».
Metadata
Release files for ingush-text 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ingush_text-0.1.0.tar.gz | 64.0 kB | With provenance | Details for ingush_text-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ingush_text-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for ingush_text-0.1.0-py3-none-any.whl |
Total release size: 107.8 kB
Release files / ingush_text-0.1.0.tar.gz
| Download URL | ingush_text-0.1.0.tar.gz |
|---|---|
| Size | 64.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4b1cd8df76ff67e8bbf6807ed5dc1fab3e107d0edd7174d75f74952bcb697ce
|
|
BLAKE2b-256 checksum How to use checksums |
8471aae06dc586bb8ffbc88fd73d6134dc976b7c0e776b7babeca49536c06560
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / ingush_text-0.1.0-py3-none-any.whl
| Download URL | ingush_text-0.1.0-py3-none-any.whl |
|---|---|
| Size | 43.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e992d6d9106679d68e7c8b538ce1f03e810a6b660af5364349597097b69618b1
|
|
BLAKE2b-256 checksum How to use checksums |
bfd812d5eae3710d83e6c153c785f2a4fe04b702abeac84c71d639895d5e8a69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logSecurity for ingush-text 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ingush_text-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.