skrutable 2.9.2__tar.gz → 2.9.3__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.
- {skrutable-2.9.2 → skrutable-2.9.3}/PKG-INFO +1 -1
- skrutable-2.9.3/src/skrutable/__init__.py +1 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/phonemes.py +1 -1
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/scansion.py +2 -1
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/scheme_maps.py +21 -2
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/splitting.py +2 -1
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/transliteration.py +32 -8
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable.egg-info/PKG-INFO +1 -1
- skrutable-2.9.2/src/skrutable/__init__.py +0 -1
- {skrutable-2.9.2 → skrutable-2.9.3}/LICENSE.md +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/README.md +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/setup.cfg +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/setup.py +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/config.json +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/config.py +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/generate_scheme_vectors.py +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/impossible_bigrams.json +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/manual.md +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/meter_identification.py +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/meter_patterns.py +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/profiling_runner.py +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/run_examples.py +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/scheme_detection.py +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/scheme_vectors.json +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/scheme_vectors_mbh.py +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/utils.py +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable/virAma_avoidance.py +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable.egg-info/SOURCES.txt +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable.egg-info/dependency_links.txt +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable.egg-info/requires.txt +0 -0
- {skrutable-2.9.2 → skrutable-2.9.3}/src/skrutable.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.9.3"
|
|
@@ -63,7 +63,7 @@ SLP_chars = ( [ c for c in Roman_upper if c not in ['V','Z'] ]
|
|
|
63
63
|
|
|
64
64
|
IAST_chars = ( [c for c in Roman_lower if c not in ['f','q','w','x','z'] ]
|
|
65
65
|
+ ['ñ','ā','ī','ś','ū','ḍ','ḥ','ḷ','ḹ','ḻ','ṃ','ṅ','ṇ','ṛ','ṝ','ṣ','ṭ','ẖ','ḫ','ï','ü','ĕ','ŏ']
|
|
66
|
-
+ ['̄', '́', '̇', '̣', '̥', '̱', '̮', '̱', 'ṁ', 'ē', 'ō', '\u0303'] ) # also accept ISO etc. alternates
|
|
66
|
+
+ ['̄', '́', '̇', '̣', '̥', '̱', '̮', '̱', 'ṁ', 'ē', 'ō', '\u0303', '\u0310'] ) # also accept ISO etc. alternates
|
|
67
67
|
# need to add more in case of capital letters, etc.; see scheme_maps.IAST_SLP
|
|
68
68
|
|
|
69
69
|
HK_chars = ( ['A','D','G','H','I','J','L','M','N','R','S','T','U']
|
|
@@ -418,7 +418,8 @@ class Scanner(object):
|
|
|
418
418
|
T.scheme_out = 'SLP'
|
|
419
419
|
|
|
420
420
|
V.text_cleaned = self.clean_input(V.text_raw, V.original_scheme)
|
|
421
|
-
|
|
421
|
+
# anunāsika flattened to anusvāra for scansion (A~l → AMl keeps syllable count)
|
|
422
|
+
V.text_SLP = timed('scan_translit')(T.transliterate)(V.text_cleaned, preserve_anunasika=False)
|
|
422
423
|
V.text_syllabified = self.syllabify_text(V.text_SLP)
|
|
423
424
|
V.syllable_weights = self.scan_syllable_weights(V.text_syllabified)
|
|
424
425
|
V.morae_per_line = self.count_morae(V.syllable_weights)
|
|
@@ -85,7 +85,26 @@ to SLP IAST_SLP, DEV_SLP, HK_SLP, VH_SLP, ITRANS_SLP
|
|
|
85
85
|
from SLP SLP_IAST, SLP_DEV, SLP_HK, SLP_VH, SLP_ITRANS
|
|
86
86
|
"""
|
|
87
87
|
IAST_SLP = [
|
|
88
|
-
# Normalization 0: anunāsika
|
|
88
|
+
# Normalization 0: anunāsika → SLP ~
|
|
89
|
+
# Standard form is m̐, which is TWO codepoints: m (U+006D) + combining candrabindu (U+0310).
|
|
90
|
+
# Also accepted: any letter + combining tilde (U+0303), e.g. ã or l̃,
|
|
91
|
+
# whether typed as base + U+0303 or as a single precomposed codepoint (ã U+00E3, ỹ U+1EF9, etc.).
|
|
92
|
+
# Position is taken as written here; a mark on a semivowel (l̃, lm̐)
|
|
93
|
+
# is moved onto the preceding vowel later, in Transliterator.transliterate().
|
|
94
|
+
# 0a: decomposed ñ (n + U+0303) is the palatal nasal, not a nasalized n
|
|
95
|
+
('n\u0303','\u00f1'),('N\u0303','\u00f1'),
|
|
96
|
+
# 0b: precomposed tilde letters → base + combining tilde
|
|
97
|
+
('\u00e3','a\u0303'),('\u00c3','a\u0303'), # a-tilde
|
|
98
|
+
('\u0129','i\u0303'),('\u0128','i\u0303'), # i-tilde
|
|
99
|
+
('\u0169','u\u0303'),('\u0168','u\u0303'), # u-tilde
|
|
100
|
+
('\u1ebd','e\u0303'),('\u1ebc','e\u0303'), # e-tilde
|
|
101
|
+
('\u00f5','o\u0303'),('\u00d5','o\u0303'), # o-tilde
|
|
102
|
+
('\u1ef9','y\u0303'),('\u1ef8','y\u0303'), # y-tilde
|
|
103
|
+
('\u1e7d','v\u0303'),('\u1e7c','v\u0303'), # v-tilde
|
|
104
|
+
# 0c: tilde typed before macron → macron first, so the long vowel can merge below
|
|
105
|
+
('\u0303\u0304','\u0304\u0303'),
|
|
106
|
+
# 0d: the anunāsika signs themselves
|
|
107
|
+
('m\u0310','~'),('M\u0310','~'),
|
|
89
108
|
('\u0303','~'),
|
|
90
109
|
# Normalization 1: ISO under-circles to under-dots (longs will feed into later rules_
|
|
91
110
|
('r̥','ṛ'),('R̥','ṛ'), # r ̥ -> ṛ
|
|
@@ -588,7 +607,7 @@ SLP_SLP = [
|
|
|
588
607
|
|
|
589
608
|
SLP_IAST = [
|
|
590
609
|
# Transliteration 1: all simple mappings
|
|
591
|
-
('~','\
|
|
610
|
+
('~','m\u0310'), # anunāsika: m̐ (m + combining candrabindu U+0310)
|
|
592
611
|
('A','ā'),
|
|
593
612
|
('I','ī'),
|
|
594
613
|
('U','ū'),
|
|
@@ -246,8 +246,9 @@ class Splitter(object):
|
|
|
246
246
|
"""
|
|
247
247
|
|
|
248
248
|
# transliterate input to IAST (auto-detects if from_scheme is None)
|
|
249
|
+
# anunāsika flattened to anusvāra, which the splitter model expects
|
|
249
250
|
T = Transliterator()
|
|
250
|
-
text = T.transliterate(text, from_scheme=from_scheme, to_scheme='IAST')
|
|
251
|
+
text = T.transliterate(text, from_scheme=from_scheme, to_scheme='IAST', preserve_anunasika=False)
|
|
251
252
|
|
|
252
253
|
# save original punctuation
|
|
253
254
|
sentences: List[str]
|
|
@@ -13,6 +13,15 @@ DEFAULT_SCHEME_OUT = config["default_scheme_out"] # e.g. "IAST"
|
|
|
13
13
|
AVOID_VIRAMA_INDIC_SCRIPTS_DEFAULT = config["avoid_virama_indic_scripts"] # e.g. True
|
|
14
14
|
AVOID_VIRAMA_NON_INDIC_SCRIPTS_DEFAULT = config["avoid_virama_non_indic_scripts"] # e.g. False
|
|
15
15
|
|
|
16
|
+
# Nasalized semivowel (y, l, v), e.g. the first l of devān + loke.
|
|
17
|
+
# Phonetically the nasalization belongs to the semivowel (strict SLP devAl~loke),
|
|
18
|
+
# but IAST, ISO 15919, and Indic scripts all write the sign on the preceding vowel
|
|
19
|
+
# (devām̐lloke, देवाँल्लोके). skrutable follows that practice, also internally:
|
|
20
|
+
# its SLP ~ means "candrabindu as written", so the parked form is devA~lloke.
|
|
21
|
+
# Any sign found on the semivowel itself (l~, l̃, lm̐, ल्ँ, also anusvāra lṃ, ल्ं)
|
|
22
|
+
# is therefore moved to before the semivowel.
|
|
23
|
+
_re_nasal_sign_on_semivowel = re.compile(r'([ylv])[~M]')
|
|
24
|
+
|
|
16
25
|
|
|
17
26
|
class Transliterator():
|
|
18
27
|
"""
|
|
@@ -141,13 +150,15 @@ class Transliterator():
|
|
|
141
150
|
"""
|
|
142
151
|
Internal method.
|
|
143
152
|
|
|
144
|
-
Normalizes SLP ~ (anunāsika) to M (anusvāra)
|
|
145
|
-
|
|
146
|
-
|
|
153
|
+
Normalizes SLP ~ (anunāsika) to M (anusvāra)
|
|
154
|
+
when preserve_anunasika is False, and always for IASTREDUCED.
|
|
155
|
+
Schemes without an anunāsika representation (HK, VH, WX)
|
|
156
|
+
otherwise just pass SLP ~ through.
|
|
157
|
+
|
|
158
|
+
The sign is always already on the vowel by this point
|
|
159
|
+
(see _re_nasal_sign_on_semivowel), so this is a plain substitution (A~ → AM).
|
|
147
160
|
"""
|
|
148
|
-
|
|
149
|
-
conditionally_normalize = ['IAST', 'ITRANS', 'SLP', 'DEV', 'BENGALI', 'GUJARATI']
|
|
150
|
-
if to_scheme in always_normalize or (to_scheme in conditionally_normalize and not preserve_anunasika):
|
|
161
|
+
if to_scheme == 'IASTREDUCED' or not preserve_anunasika:
|
|
151
162
|
self.contents = self.contents.replace('~', 'M')
|
|
152
163
|
|
|
153
164
|
def transliterate(
|
|
@@ -157,7 +168,7 @@ class Transliterator():
|
|
|
157
168
|
to_scheme=None,
|
|
158
169
|
avoid_virama_indic_scripts: bool = AVOID_VIRAMA_INDIC_SCRIPTS_DEFAULT,
|
|
159
170
|
avoid_virama_non_indic_scripts: bool = AVOID_VIRAMA_NON_INDIC_SCRIPTS_DEFAULT,
|
|
160
|
-
preserve_anunasika: bool =
|
|
171
|
+
preserve_anunasika: bool = True,
|
|
161
172
|
):
|
|
162
173
|
"""
|
|
163
174
|
User-facing method.
|
|
@@ -171,6 +182,17 @@ class Transliterator():
|
|
|
171
182
|
Executes transliteration via SLP,
|
|
172
183
|
including linear preprocessing in case of DEV.
|
|
173
184
|
|
|
185
|
+
Anunāsika (candrabindu): preserved by default,
|
|
186
|
+
or flattened to anusvāra if preserve_anunasika is False.
|
|
187
|
+
IAST output uses m̐, which is two codepoints:
|
|
188
|
+
m (U+006D) + combining candrabindu (U+0310).
|
|
189
|
+
IAST input also accepts any letter + tilde (ã, l̃),
|
|
190
|
+
combining (U+0303) or precomposed.
|
|
191
|
+
The sign is always written after the vowel, as in practice:
|
|
192
|
+
devān + loke is devām̐lloke / देवाँल्लोके (SLP devA~lloke),
|
|
193
|
+
and a sign given on the semivowel itself
|
|
194
|
+
(devāl̃loke, devālm̐loke, strict SLP devAl~loke) is moved there.
|
|
195
|
+
|
|
174
196
|
Result returned via updated self.contents
|
|
175
197
|
and also directly as string.
|
|
176
198
|
"""
|
|
@@ -195,8 +217,10 @@ class Transliterator():
|
|
|
195
217
|
# transliterate first to hub scheme SLP
|
|
196
218
|
self.linear_preprocessing(self.scheme_in, 'SLP')
|
|
197
219
|
self.map_replace(self.scheme_in, 'SLP')
|
|
220
|
+
# park any nasal sign written on a semivowel onto the preceding vowel (Al~l → A~ll)
|
|
221
|
+
self.contents = _re_nasal_sign_on_semivowel.sub(r'~\1', self.contents)
|
|
198
222
|
|
|
199
|
-
# normalize anunāsika (~) to anusvāra (M)
|
|
223
|
+
# normalize anunāsika (~) to anusvāra (M) unless preserving
|
|
200
224
|
self.normalize_anunasika(self.scheme_out, preserve_anunasika)
|
|
201
225
|
|
|
202
226
|
# avoid undesirable virāmas specified in virāma_avoidance.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.9.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|