skrutable 2.9.2__tar.gz → 2.10.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.
- {skrutable-2.9.2 → skrutable-2.10.0}/PKG-INFO +17 -3
- skrutable-2.10.0/src/skrutable/__init__.py +1 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/phonemes.py +1 -1
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/scansion.py +2 -1
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/scheme_maps.py +21 -2
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/splitting.py +9 -2
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/transliteration.py +52 -8
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable.egg-info/PKG-INFO +17 -3
- skrutable-2.9.2/src/skrutable/__init__.py +0 -1
- {skrutable-2.9.2 → skrutable-2.10.0}/LICENSE.md +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/README.md +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/setup.cfg +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/setup.py +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/config.json +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/config.py +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/generate_scheme_vectors.py +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/impossible_bigrams.json +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/manual.md +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/meter_identification.py +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/meter_patterns.py +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/profiling_runner.py +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/run_examples.py +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/scheme_detection.py +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/scheme_vectors.json +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/scheme_vectors_mbh.py +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/utils.py +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable/virAma_avoidance.py +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable.egg-info/SOURCES.txt +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable.egg-info/dependency_links.txt +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable.egg-info/requires.txt +0 -0
- {skrutable-2.9.2 → skrutable-2.10.0}/src/skrutable.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: skrutable
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.10.0
|
|
4
4
|
Summary: skrutable library for working with Sanskrit text
|
|
5
5
|
Home-page: https://github.com/tylergneill/skrutable
|
|
6
6
|
Author: Tyler Neill
|
|
@@ -8,8 +8,22 @@ Author-email: tyler.g.neill@gmail.com
|
|
|
8
8
|
License: CC BY-SA 4.0
|
|
9
9
|
Keywords: Sanskrit text transliteration scansion meter identification sandhi compound splitting
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
|
-
Provides-Extra: testing
|
|
12
11
|
License-File: LICENSE.md
|
|
12
|
+
Requires-Dist: numpy
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Provides-Extra: testing
|
|
15
|
+
Requires-Dist: pytest; extra == "testing"
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: keywords
|
|
22
|
+
Dynamic: license
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
Dynamic: provides-extra
|
|
25
|
+
Dynamic: requires-dist
|
|
26
|
+
Dynamic: summary
|
|
13
27
|
|
|
14
28
|
# skrutable
|
|
15
29
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.10.0"
|
|
@@ -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','ū'),
|
|
@@ -234,6 +234,7 @@ class Splitter(object):
|
|
|
234
234
|
splitter_model: str='dharmamitra_2024_sept',
|
|
235
235
|
preserve_compound_hyphens: bool = PRESERVE_COMPOUND_HYPHENS_DEFAULT,
|
|
236
236
|
preserve_punctuation: bool=PRESERVE_PUNCTUATION_DEFAULT,
|
|
237
|
+
preserve_dandas: bool = False,
|
|
237
238
|
) -> str:
|
|
238
239
|
"""
|
|
239
240
|
Splits sandhi and compounds of multi-line Sanskrit string,
|
|
@@ -243,11 +244,17 @@ class Splitter(object):
|
|
|
243
244
|
from_scheme: input transliteration scheme (None = auto-detect).
|
|
244
245
|
to_scheme: output transliteration scheme (None = IAST, the hub scheme).
|
|
245
246
|
Processing always happens in IAST; transliteration wraps the call if needed.
|
|
247
|
+
preserve_dandas: passed to the output transliteration when to_scheme is set,
|
|
248
|
+
so roman output gets | and || unless True (Indic output keeps । and ॥).
|
|
249
|
+
Dandas are always kept through splitting itself,
|
|
250
|
+
so with to_scheme None the output keeps whatever dandas came in.
|
|
246
251
|
"""
|
|
247
252
|
|
|
248
253
|
# transliterate input to IAST (auto-detects if from_scheme is None)
|
|
254
|
+
# anunāsika flattened to anusvāra, which the splitter model expects
|
|
255
|
+
# dandas kept as is (handled as punctuation below)
|
|
249
256
|
T = Transliterator()
|
|
250
|
-
text = T.transliterate(text, from_scheme=from_scheme, to_scheme='IAST')
|
|
257
|
+
text = T.transliterate(text, from_scheme=from_scheme, to_scheme='IAST', preserve_anunasika=False, preserve_dandas=True)
|
|
251
258
|
|
|
252
259
|
# save original punctuation
|
|
253
260
|
sentences: List[str]
|
|
@@ -296,6 +303,6 @@ class Splitter(object):
|
|
|
296
303
|
|
|
297
304
|
# transliterate output from IAST if requested
|
|
298
305
|
if to_scheme is not None and to_scheme.upper() != 'IAST':
|
|
299
|
-
final_results = T.transliterate(final_results, from_scheme='IAST', to_scheme=to_scheme)
|
|
306
|
+
final_results = T.transliterate(final_results, from_scheme='IAST', to_scheme=to_scheme, preserve_dandas=preserve_dandas)
|
|
300
307
|
|
|
301
308
|
return final_results
|
|
@@ -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,15 +150,28 @@ 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
|
|
|
164
|
+
def normalize_dandas(self, to_scheme, preserve_dandas):
|
|
165
|
+
"""
|
|
166
|
+
Internal method.
|
|
167
|
+
|
|
168
|
+
Converts Unicode dandas (। U+0964, ॥ U+0965) to | and ||
|
|
169
|
+
for non-Indic (roman) output schemes, unless preserve_dandas is True.
|
|
170
|
+
"""
|
|
171
|
+
if to_scheme in scheme_maps.indic_schemes or preserve_dandas:
|
|
172
|
+
return
|
|
173
|
+
self.contents = self.contents.replace('\u0965', '||').replace('\u0964', '|')
|
|
174
|
+
|
|
153
175
|
def transliterate(
|
|
154
176
|
self,
|
|
155
177
|
cntnts,
|
|
@@ -157,7 +179,8 @@ class Transliterator():
|
|
|
157
179
|
to_scheme=None,
|
|
158
180
|
avoid_virama_indic_scripts: bool = AVOID_VIRAMA_INDIC_SCRIPTS_DEFAULT,
|
|
159
181
|
avoid_virama_non_indic_scripts: bool = AVOID_VIRAMA_NON_INDIC_SCRIPTS_DEFAULT,
|
|
160
|
-
preserve_anunasika: bool =
|
|
182
|
+
preserve_anunasika: bool = True,
|
|
183
|
+
preserve_dandas: bool = False,
|
|
161
184
|
):
|
|
162
185
|
"""
|
|
163
186
|
User-facing method.
|
|
@@ -171,6 +194,22 @@ class Transliterator():
|
|
|
171
194
|
Executes transliteration via SLP,
|
|
172
195
|
including linear preprocessing in case of DEV.
|
|
173
196
|
|
|
197
|
+
Anunāsika (candrabindu): preserved by default,
|
|
198
|
+
or flattened to anusvāra if preserve_anunasika is False.
|
|
199
|
+
IAST output uses m̐, which is two codepoints:
|
|
200
|
+
m (U+006D) + combining candrabindu (U+0310).
|
|
201
|
+
IAST input also accepts any letter + tilde (ã, l̃),
|
|
202
|
+
combining (U+0303) or precomposed.
|
|
203
|
+
The sign is always written after the vowel, as in practice:
|
|
204
|
+
devān + loke is devām̐lloke / देवाँल्लोके (SLP devA~lloke),
|
|
205
|
+
and a sign given on the semivowel itself
|
|
206
|
+
(devāl̃loke, devālm̐loke, strict SLP devAl~loke) is moved there.
|
|
207
|
+
|
|
208
|
+
Dandas: for non-Indic (roman) output, Unicode । and ॥
|
|
209
|
+
are converted to | and || by default,
|
|
210
|
+
or left as is if preserve_dandas is True.
|
|
211
|
+
Indic-script output always keeps them as is.
|
|
212
|
+
|
|
174
213
|
Result returned via updated self.contents
|
|
175
214
|
and also directly as string.
|
|
176
215
|
"""
|
|
@@ -195,8 +234,10 @@ class Transliterator():
|
|
|
195
234
|
# transliterate first to hub scheme SLP
|
|
196
235
|
self.linear_preprocessing(self.scheme_in, 'SLP')
|
|
197
236
|
self.map_replace(self.scheme_in, 'SLP')
|
|
237
|
+
# park any nasal sign written on a semivowel onto the preceding vowel (Al~l → A~ll)
|
|
238
|
+
self.contents = _re_nasal_sign_on_semivowel.sub(r'~\1', self.contents)
|
|
198
239
|
|
|
199
|
-
# normalize anunāsika (~) to anusvāra (M)
|
|
240
|
+
# normalize anunāsika (~) to anusvāra (M) unless preserving
|
|
200
241
|
self.normalize_anunasika(self.scheme_out, preserve_anunasika)
|
|
201
242
|
|
|
202
243
|
# avoid undesirable virāmas specified in virāma_avoidance.py
|
|
@@ -212,4 +253,7 @@ class Transliterator():
|
|
|
212
253
|
self.linear_preprocessing('SLP', self.scheme_out)
|
|
213
254
|
self.map_replace('SLP', self.scheme_out)
|
|
214
255
|
|
|
256
|
+
# convert Unicode dandas to ASCII pipes for roman output unless preserving
|
|
257
|
+
self.normalize_dandas(self.scheme_out, preserve_dandas)
|
|
258
|
+
|
|
215
259
|
return self.contents
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: skrutable
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.10.0
|
|
4
4
|
Summary: skrutable library for working with Sanskrit text
|
|
5
5
|
Home-page: https://github.com/tylergneill/skrutable
|
|
6
6
|
Author: Tyler Neill
|
|
@@ -8,8 +8,22 @@ Author-email: tyler.g.neill@gmail.com
|
|
|
8
8
|
License: CC BY-SA 4.0
|
|
9
9
|
Keywords: Sanskrit text transliteration scansion meter identification sandhi compound splitting
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
|
-
Provides-Extra: testing
|
|
12
11
|
License-File: LICENSE.md
|
|
12
|
+
Requires-Dist: numpy
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Provides-Extra: testing
|
|
15
|
+
Requires-Dist: pytest; extra == "testing"
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: keywords
|
|
22
|
+
Dynamic: license
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
Dynamic: provides-extra
|
|
25
|
+
Dynamic: requires-dist
|
|
26
|
+
Dynamic: summary
|
|
13
27
|
|
|
14
28
|
# skrutable
|
|
15
29
|
|
|
@@ -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
|