ingush-text 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,152 @@
1
+ """ingush-text: zero-dependency text processing for Ingush (inh).
2
+
3
+ Extracted from PaydaDosh (https://paydadosh.ru).
4
+
5
+ Input contract (all text functions): ``str`` or ``None``; ``None`` behaves like
6
+ ``""`` and yields the empty result of the function (``""``, ``[]``,
7
+ ``frozenset()``, ``0`` or ``False``); ``bytes`` and other types raise
8
+ :class:`TypeError`.
9
+ """
10
+ from __future__ import annotations
11
+
12
+ from .alphabet import (
13
+ ALPHABET,
14
+ CONSONANTS,
15
+ DIGRAPHS,
16
+ LETTERS_RULE,
17
+ SIGNS,
18
+ VOWELS,
19
+ Mask,
20
+ MaskError,
21
+ compile_mask,
22
+ decode,
23
+ encode,
24
+ fold,
25
+ last_letter_class,
26
+ letters,
27
+ n_letters,
28
+ rev_key,
29
+ sort_key,
30
+ strip_length,
31
+ syllables,
32
+ )
33
+ from .latin1930 import latin1930_to_cyrillic
34
+ from .normalize import (
35
+ clean_for_display,
36
+ clean_text,
37
+ fold_latin_homoglyphs,
38
+ fold_ocr_lookalikes,
39
+ is_latin_heavy,
40
+ norm_space,
41
+ normalize_definition_safe,
42
+ normalize_for_index,
43
+ normalize_for_search,
44
+ strip_accents_latin_only,
45
+ strip_stress,
46
+ )
47
+ from .numbers import (
48
+ CLASS_LETTERS,
49
+ MAX_NUMBER,
50
+ cardinal,
51
+ class_forms,
52
+ class_note,
53
+ class_variable,
54
+ number_to_words,
55
+ ordinal,
56
+ )
57
+ from .palochka import (
58
+ PALOCHKA,
59
+ PALOCHKA_LOWER,
60
+ fix_palochka,
61
+ fix_palochka_text,
62
+ load_wordlist,
63
+ normalize_palochka_display,
64
+ normalize_palochka_index,
65
+ wordlist_key,
66
+ )
67
+ from .tokenizer import (
68
+ WORD_MARKS,
69
+ length_marks,
70
+ length_signature,
71
+ tokenize,
72
+ )
73
+ from .translit import (
74
+ DEFAULT_SCHEME,
75
+ RULES,
76
+ SCHEMES,
77
+ clean_for_translit,
78
+ palochka_unsure,
79
+ transliterate,
80
+ transliterate_all,
81
+ )
82
+
83
+ __version__ = "0.1.0"
84
+
85
+ __all__ = [
86
+ "__version__",
87
+ # palochka
88
+ "PALOCHKA",
89
+ "PALOCHKA_LOWER",
90
+ "normalize_palochka_display",
91
+ "normalize_palochka_index",
92
+ "fix_palochka",
93
+ "fix_palochka_text",
94
+ "wordlist_key",
95
+ "load_wordlist",
96
+ # normalize
97
+ "norm_space",
98
+ "strip_stress",
99
+ "strip_accents_latin_only",
100
+ "fold_latin_homoglyphs",
101
+ "fold_ocr_lookalikes",
102
+ "normalize_for_search",
103
+ "normalize_for_index",
104
+ "normalize_definition_safe",
105
+ "clean_for_display",
106
+ "clean_text",
107
+ "is_latin_heavy",
108
+ # tokenize
109
+ "WORD_MARKS",
110
+ "tokenize",
111
+ "length_marks",
112
+ "length_signature",
113
+ # letters
114
+ "LETTERS_RULE",
115
+ "ALPHABET",
116
+ "DIGRAPHS",
117
+ "VOWELS",
118
+ "CONSONANTS",
119
+ "SIGNS",
120
+ "fold",
121
+ "letters",
122
+ "encode",
123
+ "decode",
124
+ "strip_length",
125
+ "n_letters",
126
+ "syllables",
127
+ "last_letter_class",
128
+ "sort_key",
129
+ "rev_key",
130
+ "Mask",
131
+ "MaskError",
132
+ "compile_mask",
133
+ # translit
134
+ "SCHEMES",
135
+ "DEFAULT_SCHEME",
136
+ "RULES",
137
+ "clean_for_translit",
138
+ "transliterate",
139
+ "transliterate_all",
140
+ "palochka_unsure",
141
+ # latin1930
142
+ "latin1930_to_cyrillic",
143
+ # numbers
144
+ "MAX_NUMBER",
145
+ "CLASS_LETTERS",
146
+ "cardinal",
147
+ "ordinal",
148
+ "class_forms",
149
+ "class_variable",
150
+ "class_note",
151
+ "number_to_words",
152
+ ]
ingush_text/_text.py ADDED
@@ -0,0 +1,19 @@
1
+ """Shared input contract for every text function of the package.
2
+
3
+ ``None`` is treated as an empty string; ``str`` (and subclasses) pass through;
4
+ anything else (notably ``bytes``) raises :class:`TypeError` instead of being
5
+ silently stringified (``str(b"x")`` would give ``"b'x'"``).
6
+ """
7
+ from __future__ import annotations
8
+
9
+ from typing import Any
10
+
11
+
12
+ def as_text(value: Any) -> str:
13
+ if value is None:
14
+ return ""
15
+ if isinstance(value, str):
16
+ return value
17
+ if isinstance(value, (bytes, bytearray, memoryview)):
18
+ raise TypeError("expected str or None, got bytes; decode it first (e.g. data.decode('utf-8'))")
19
+ raise TypeError(f"expected str or None, got {type(value).__name__}")