skrutable 2.9.1__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.1 → skrutable-2.9.3}/PKG-INFO +1 -1
- skrutable-2.9.3/src/skrutable/__init__.py +1 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/phonemes.py +10 -10
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/scansion.py +2 -1
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/scheme_maps.py +45 -11
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/splitting.py +2 -1
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/transliteration.py +32 -8
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable.egg-info/PKG-INFO +1 -1
- skrutable-2.9.1/src/skrutable/__init__.py +0 -1
- {skrutable-2.9.1 → skrutable-2.9.3}/LICENSE.md +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/README.md +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/setup.cfg +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/setup.py +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/config.json +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/config.py +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/generate_scheme_vectors.py +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/impossible_bigrams.json +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/manual.md +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/meter_identification.py +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/meter_patterns.py +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/profiling_runner.py +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/run_examples.py +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/scheme_detection.py +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/scheme_vectors.json +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/scheme_vectors_mbh.py +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/utils.py +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable/virAma_avoidance.py +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable.egg-info/SOURCES.txt +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable.egg-info/dependency_links.txt +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable.egg-info/requires.txt +0 -0
- {skrutable-2.9.1 → skrutable-2.9.3}/src/skrutable.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.9.3"
|
|
@@ -23,7 +23,7 @@ vowels_that_preempt_virAma = ( SLP_vowels + DEV_vowel_mAtrAs +
|
|
|
23
23
|
BENGALI_vowel_mAtrAs + GUJARATI_vowel_mAtrAs )
|
|
24
24
|
|
|
25
25
|
SLP_unvoiced_consonants = ['k','K','c','C','w','W','t','T','p','P','z','S','s']
|
|
26
|
-
SLP_voiced_consonants = ['g','G','N','j','J','Y','q','Q','R','d','D','n','b','B','m','y','r','l','v','h']
|
|
26
|
+
SLP_voiced_consonants = ['g','G','N','j','J','Y','q','Q','R','d','D','n','b','B','m','y','r','l','v','L','h']
|
|
27
27
|
|
|
28
28
|
SLP_consonants = SLP_unvoiced_consonants + SLP_voiced_consonants
|
|
29
29
|
"""Voice distinguished for sake of destroy_spaces functionality.
|
|
@@ -39,15 +39,15 @@ SLP_consonants_for_scansion_set = set(SLP_consonants_for_scansion)
|
|
|
39
39
|
|
|
40
40
|
DEV_consonants = ['क', 'ख', 'ग', 'घ', 'ङ','च', 'छ', 'ज', 'झ', 'ञ',
|
|
41
41
|
'ट', 'ठ', 'ड', 'ढ', 'ण','त', 'थ', 'द', 'ध', 'न','प', 'फ', 'ब', 'भ', 'म',
|
|
42
|
-
'य', 'र', 'ल', 'व','श', 'ष', 'स', 'ह']
|
|
42
|
+
'य', 'र', 'ल', 'व','ळ','श', 'ष', 'स', 'ह']
|
|
43
43
|
|
|
44
44
|
BENGALI_consonants = ['ক', 'খ', 'গ', 'ঘ', 'ঙ','চ', 'ছ', 'জ', 'ঝ', 'ঞ',
|
|
45
45
|
'ট', 'ঠ', 'ড', 'ঢ', 'ণ','ত', 'থ', 'দ', 'ধ', 'ন','প', 'ফ', 'ব', 'ভ', 'ম',
|
|
46
|
-
'য', 'র', 'ল', 'ব','শ', 'ষ', 'স', 'হ']
|
|
46
|
+
'য', 'র', 'ল', 'ল়', 'ব','শ', 'ষ', 'স', 'হ']
|
|
47
47
|
|
|
48
48
|
GUJARATI_consonants = ['ક', 'ખ', 'ગ', 'ઘ', 'ઙ','ચ', 'છ', 'જ', 'ઝ', 'ઞ',
|
|
49
49
|
'ટ', 'ઠ', 'ડ', 'ઢ', 'ણ','ત', 'થ', 'દ', 'ધ', 'ન','પ', 'ફ', 'બ', 'ભ', 'મ',
|
|
50
|
-
'ય', 'ર', 'લ', 'વ','શ', 'ષ', 'સ', 'હ']
|
|
50
|
+
'ય', 'ર', 'લ', 'ળ', 'વ','શ', 'ષ', 'સ', 'હ']
|
|
51
51
|
|
|
52
52
|
# lookup table to use like e.g. SLP_and_indic_consonants['BENGALI']
|
|
53
53
|
SLP_and_indic_consonants = ( SLP_consonants + DEV_consonants +
|
|
@@ -58,24 +58,24 @@ SLP_and_indic_consonants = ( SLP_consonants + DEV_consonants +
|
|
|
58
58
|
Roman_upper = [chr(n) for n in range(65,91)]
|
|
59
59
|
Roman_lower = [chr(n) for n in range(97,123)]
|
|
60
60
|
|
|
61
|
-
SLP_chars = ( [ c for c in Roman_upper if c not in ['
|
|
61
|
+
SLP_chars = ( [ c for c in Roman_upper if c not in ['V','Z'] ]
|
|
62
62
|
+ Roman_lower + ['~'] )
|
|
63
63
|
|
|
64
64
|
IAST_chars = ( [c for c in Roman_lower if c not in ['f','q','w','x','z'] ]
|
|
65
|
-
+ ['ñ','ā','ī','ś','ū','ḍ','ḥ','ḷ','ḹ','ṃ','ṅ','ṇ','ṛ','ṝ','ṣ','ṭ','ẖ','ḫ','ï','ü','ĕ','ŏ']
|
|
66
|
-
+ ['̄', '́', '̇', '̣', '̥', '̱', '̮', '̱', 'ṁ', 'ē', 'ō', '\u0303'] ) # also accept ISO etc. alternates
|
|
65
|
+
+ ['ñ','ā','ī','ś','ū','ḍ','ḥ','ḷ','ḹ','ḻ','ṃ','ṅ','ṇ','ṛ','ṝ','ṣ','ṭ','ẖ','ḫ','ï','ü','ĕ','ŏ']
|
|
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
|
-
HK_chars = ( ['A','D','G','H','I','J','M','N','R','S','T','U']
|
|
69
|
+
HK_chars = ( ['A','D','G','H','I','J','L','M','N','R','S','T','U']
|
|
70
70
|
+ [c for c in Roman_lower if c not in ['f','q','w','x'] ] )
|
|
71
71
|
|
|
72
72
|
VH_chars = ( ['B','C','D','G','J','K','L','P','R','T'] + ['"','.','~']
|
|
73
73
|
+ [ c for c in Roman_lower if c not in ['f','q','w','x','z'] ] )
|
|
74
74
|
|
|
75
|
-
ITRANS_chars = ( ['C','D','E','I','L','N','O','R','S','T'] + ['.','^','~']
|
|
75
|
+
ITRANS_chars = ( ['C','D','E','I','L','N','O','R','S','T','Y'] + ['.','^','~']
|
|
76
76
|
+ [c for c in Roman_lower if c not in ['f','q','v','x','z'] ] )
|
|
77
77
|
|
|
78
|
-
WX_chars = list({tup[0] for tup in scheme_maps.WX_SLP})
|
|
78
|
+
WX_chars = list({tup[0] for tup in scheme_maps.WX_SLP if tup[0] != 'lY'}) + ['lY']
|
|
79
79
|
|
|
80
80
|
# build Indic sets from respective scheme maps, but exclude numbers
|
|
81
81
|
|
|
@@ -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)
|
|
@@ -12,7 +12,7 @@ c ch j jh ñ c C j J Y c ch j jh J
|
|
|
12
12
|
ṭ ṭh ḍ ḍh ṇ w W q Q R T Th D Dh N
|
|
13
13
|
t th d dh n t T d D n t th d dh n
|
|
14
14
|
p ph b bh m p P b B m p ph b bh m
|
|
15
|
-
y r l v
|
|
15
|
+
y r l v ḻ y r l v L y r l v L
|
|
16
16
|
ś ṣ s h ṃ ḥ ' S z s h M H ' z S s h M H '
|
|
17
17
|
|
|
18
18
|
(IASTREDUCED: a a i i u u ... jh n t th d dh n t ... s s s h m h ')
|
|
@@ -25,7 +25,7 @@ DEV
|
|
|
25
25
|
ट ठ ड ढ ण
|
|
26
26
|
त थ द ध न
|
|
27
27
|
प फ ब भ म
|
|
28
|
-
य र ल व
|
|
28
|
+
य र ल व ळ
|
|
29
29
|
श ष स ह ं ः ऽ
|
|
30
30
|
१ २ ३ ४ ५ ६ ७ ८ ९ ०
|
|
31
31
|
|
|
@@ -37,7 +37,7 @@ BENGALI
|
|
|
37
37
|
ট ঠ ড ঢ ণ
|
|
38
38
|
ত থ দ ধ ন
|
|
39
39
|
প ফ ব ভ ম
|
|
40
|
-
য র ল ব
|
|
40
|
+
য র ল ব ল়
|
|
41
41
|
শ ষ স হ ং ঃ ঽ
|
|
42
42
|
১ ২ ৩ ৪ ৫ ৬ ৭ ৮ ৯ ০
|
|
43
43
|
|
|
@@ -49,7 +49,7 @@ GUJARATI
|
|
|
49
49
|
ટ ઠ ડ ઢ ણ
|
|
50
50
|
ત થ દ ધ ન
|
|
51
51
|
પ ફ બ ભ મ
|
|
52
|
-
ય ર લ વ
|
|
52
|
+
ય ર લ વ ળ
|
|
53
53
|
શ ષ સ હ ં ઃ ઽ
|
|
54
54
|
૧ ૨ ૩ ૪ ૫ ૬ ૭ ૮ ૯ ૦
|
|
55
55
|
|
|
@@ -61,7 +61,7 @@ c ch j jh ~n c C j J F
|
|
|
61
61
|
.t .th .d .dh .n t T d D N
|
|
62
62
|
t th d dh n w W x X n
|
|
63
63
|
p ph b bh m p P b B m
|
|
64
|
-
y r l v
|
|
64
|
+
y r l v .la y r l v lY
|
|
65
65
|
"s .s s h .m .h .a S R s M H Z
|
|
66
66
|
|
|
67
67
|
ITRANS
|
|
@@ -72,7 +72,7 @@ ch Ch j jh ~n
|
|
|
72
72
|
T Th D Dh N
|
|
73
73
|
t th d dh n
|
|
74
74
|
p ph b bh m
|
|
75
|
-
y r l v
|
|
75
|
+
y r l v L
|
|
76
76
|
sh Sh s h .m H .a
|
|
77
77
|
|
|
78
78
|
CSX REE OAST
|
|
@@ -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 ̥ -> ṛ
|
|
@@ -112,6 +131,7 @@ IAST_SLP = [
|
|
|
112
131
|
('ṭ','ṭ'), ('Ṭ','Ṭ'),
|
|
113
132
|
('ḍ','ḍ'), ('Ḍ','Ḍ'),
|
|
114
133
|
('ṇ','ṇ'), ('Ṇ','Ṇ'),
|
|
134
|
+
('ḻ','ḻ'), ('Ḻ','Ḻ'),
|
|
115
135
|
('ś','ś'), ('Ś','Ś'),
|
|
116
136
|
('ṣ','ṣ'), ('Ṣ','Ṣ'),
|
|
117
137
|
('ḥ','ḥ'), ('Ḥ','Ḥ'),
|
|
@@ -127,7 +147,7 @@ IAST_SLP = [
|
|
|
127
147
|
('U','u'),('V','v'),('W','w'),('X','x'),('Y','y'),('Z','z'),
|
|
128
148
|
('Ā','ā'),('Ī','ī'),('Ū','ū'),('Ṛ','ṛ'), ('Ḷ','ḷ'),
|
|
129
149
|
('Ṅ','ṅ'),('Ñ','ñ'),('Ṭ','ṭ'),('Ḍ','ḍ'),('Ṇ','ṇ'),
|
|
130
|
-
('Ś','ś'),('Ṣ','ṣ'),('Ḥ','ḥ'),('Ḫ','h'),('Ṃ','ṃ'),
|
|
150
|
+
('Ḻ','ḻ'),('Ś','ś'),('Ṣ','ṣ'),('Ḥ','ḥ'),('Ḫ','h'),('Ṃ','ṃ'),
|
|
131
151
|
# Transliteration 1: careful ordering to avoid bleeding/feeding
|
|
132
152
|
('ṭh','W'),
|
|
133
153
|
('ṭ','w'),
|
|
@@ -156,6 +176,7 @@ IAST_SLP = [
|
|
|
156
176
|
('dh','D'),
|
|
157
177
|
('ph','P'),
|
|
158
178
|
('bh','B'),
|
|
179
|
+
('ḻ','L'),
|
|
159
180
|
('ś','S'),
|
|
160
181
|
('ṣ','z'),
|
|
161
182
|
('ṃ','M'),
|
|
@@ -241,6 +262,7 @@ DEV_SLP = [
|
|
|
241
262
|
('य', 'y'),
|
|
242
263
|
('र', 'r'),
|
|
243
264
|
('ल', 'l'),
|
|
265
|
+
('ळ', 'L'),
|
|
244
266
|
('व', 'v'),
|
|
245
267
|
('श', 'S'),
|
|
246
268
|
('ष', 'z'),
|
|
@@ -318,6 +340,7 @@ BENGALI_SLP = [
|
|
|
318
340
|
('য', 'y'),
|
|
319
341
|
('র', 'r'),
|
|
320
342
|
('ল', 'l'),
|
|
343
|
+
('ল়', 'L'),
|
|
321
344
|
('ব', 'v'),
|
|
322
345
|
('শ', 'S'),
|
|
323
346
|
('ষ', 'z'),
|
|
@@ -395,6 +418,7 @@ GUJARATI_SLP = [
|
|
|
395
418
|
('ય', 'y'),
|
|
396
419
|
('ર', 'r'),
|
|
397
420
|
('લ', 'l'),
|
|
421
|
+
('ળ', 'L'),
|
|
398
422
|
('વ', 'v'),
|
|
399
423
|
('શ', 'S'),
|
|
400
424
|
('ષ', 'z'),
|
|
@@ -456,6 +480,7 @@ VH_SLP = [
|
|
|
456
480
|
('dh','D'),
|
|
457
481
|
('ph','P'),
|
|
458
482
|
('bh','B'),
|
|
483
|
+
('.l','L'),
|
|
459
484
|
('"s','S'),
|
|
460
485
|
('.s','z'),
|
|
461
486
|
("’", "'"),
|
|
@@ -478,6 +503,7 @@ WX_SLP = [
|
|
|
478
503
|
('d','q'), # ḍ
|
|
479
504
|
('x','d'), # d
|
|
480
505
|
('L','x'), # ḷ
|
|
506
|
+
('lY','L'), # ḻ
|
|
481
507
|
# Transliteration 2: roundabout swaps to avoid bleeding/feeding
|
|
482
508
|
# V not used in either scheme
|
|
483
509
|
('t','V'), # ṭ
|
|
@@ -581,7 +607,7 @@ SLP_SLP = [
|
|
|
581
607
|
|
|
582
608
|
SLP_IAST = [
|
|
583
609
|
# Transliteration 1: all simple mappings
|
|
584
|
-
('~','\
|
|
610
|
+
('~','m\u0310'), # anunāsika: m̐ (m + combining candrabindu U+0310)
|
|
585
611
|
('A','ā'),
|
|
586
612
|
('I','ī'),
|
|
587
613
|
('U','ū'),
|
|
@@ -608,6 +634,7 @@ SLP_IAST = [
|
|
|
608
634
|
('D','dh'),
|
|
609
635
|
('P','ph'),
|
|
610
636
|
('B','bh'),
|
|
637
|
+
('L','ḻ'),
|
|
611
638
|
('S','ś'),
|
|
612
639
|
('z','ṣ'),
|
|
613
640
|
# Remain the same: ...
|
|
@@ -690,6 +717,7 @@ SLP_DEV = [
|
|
|
690
717
|
('y', 'य'),
|
|
691
718
|
('r', 'र'),
|
|
692
719
|
('l', 'ल'),
|
|
720
|
+
('L', 'ळ'),
|
|
693
721
|
('v', 'व'),
|
|
694
722
|
('S', 'श'),
|
|
695
723
|
('z', 'ष'),
|
|
@@ -755,6 +783,7 @@ SLP_BENGALI = [
|
|
|
755
783
|
('y', 'য'),
|
|
756
784
|
('r', 'র'),
|
|
757
785
|
('l', 'ল'),
|
|
786
|
+
('L', 'ল়'),
|
|
758
787
|
('v', 'ব'),
|
|
759
788
|
('S', 'শ'),
|
|
760
789
|
('z', 'ষ'),
|
|
@@ -820,6 +849,7 @@ SLP_GUJARATI = [
|
|
|
820
849
|
('y', 'ય'),
|
|
821
850
|
('r', 'ર'),
|
|
822
851
|
('l', 'લ'),
|
|
852
|
+
('L', 'ળ'),
|
|
823
853
|
('v', 'વ'),
|
|
824
854
|
('S', 'શ'),
|
|
825
855
|
('z', 'ષ'),
|
|
@@ -866,6 +896,7 @@ SLP_VH = [
|
|
|
866
896
|
('D','dh'),
|
|
867
897
|
('P','ph'),
|
|
868
898
|
('B','bh'),
|
|
899
|
+
('L','.l'),
|
|
869
900
|
('S','"s'),
|
|
870
901
|
('z','.s'),
|
|
871
902
|
("'",'.a'),
|
|
@@ -873,7 +904,7 @@ SLP_VH = [
|
|
|
873
904
|
|
|
874
905
|
SLP_WX = [
|
|
875
906
|
# Transliteration 1: very careful ordering to avoid bleeding/feeding
|
|
876
|
-
|
|
907
|
+
('L', 'ळ'), # ḻ
|
|
877
908
|
('x','L'), # ḷ
|
|
878
909
|
# now progressively map to what is freed up
|
|
879
910
|
('d','x'), # d
|
|
@@ -897,7 +928,9 @@ SLP_WX = [
|
|
|
897
928
|
('W','V'), # ṭh
|
|
898
929
|
('T','W'), # th
|
|
899
930
|
('V','T'), # ṭh
|
|
900
|
-
# Transliteration 3:
|
|
931
|
+
# Transliteration 3: finish up trickiest case
|
|
932
|
+
('ळ','lY'), # ḻ
|
|
933
|
+
# Transliteration 4: simpler remaining mapping
|
|
901
934
|
("'",'Z'),
|
|
902
935
|
]
|
|
903
936
|
|
|
@@ -996,6 +1029,7 @@ SLP_IASTREDUCED = [
|
|
|
996
1029
|
('D','dh'),
|
|
997
1030
|
('P','ph'),
|
|
998
1031
|
('B','bh'),
|
|
1032
|
+
('L','l'),
|
|
999
1033
|
('S','s'),
|
|
1000
1034
|
('z','s'),
|
|
1001
1035
|
]
|
|
@@ -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.1"
|
|
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
|