skrutable 2.6.0__tar.gz → 2.6.1__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.6.0 → skrutable-2.6.1}/PKG-INFO +1 -1
- skrutable-2.6.1/src/skrutable/__init__.py +1 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/phonemes.py +6 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/scansion.py +33 -34
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable.egg-info/PKG-INFO +1 -1
- skrutable-2.6.0/src/skrutable/__init__.py +0 -1
- {skrutable-2.6.0 → skrutable-2.6.1}/LICENSE.md +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/README.md +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/setup.cfg +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/setup.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/config.json +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/config.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/generate_scheme_vectors.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/impossible_bigrams.json +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/manual.md +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/meter_identification.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/meter_patterns.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/run_examples.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/scheme_detection.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/scheme_maps.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/scheme_vectors.json +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/scheme_vectors_mbh.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/splitting.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/transliteration.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/utils.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable/virAma_avoidance.py +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable.egg-info/SOURCES.txt +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable.egg-info/dependency_links.txt +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable.egg-info/requires.txt +0 -0
- {skrutable-2.6.0 → skrutable-2.6.1}/src/skrutable.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.6.1"
|
|
@@ -33,6 +33,10 @@ For transliteration, 'consonant' means 'needs virāma if non-vowel follows' (no
|
|
|
33
33
|
SLP_consonants_for_scansion = SLP_consonants
|
|
34
34
|
"""For scansion, 'consonant' means 'contributes to heaviness of previous vowel' (yes M H)"""
|
|
35
35
|
|
|
36
|
+
SLP_vowels_set = set(SLP_vowels)
|
|
37
|
+
SLP_long_vowels_set = set(SLP_long_vowels)
|
|
38
|
+
SLP_consonants_for_scansion_set = set(SLP_consonants_for_scansion)
|
|
39
|
+
|
|
36
40
|
DEV_consonants = ['क', 'ख', 'ग', 'घ', 'ङ','च', 'छ', 'ज', 'झ', 'ञ',
|
|
37
41
|
'ट', 'ठ', 'ड', 'ढ', 'ण','त', 'थ', 'द', 'ध', 'न','प', 'फ', 'ब', 'भ', 'म',
|
|
38
42
|
'य', 'र', 'ल', 'व','श', 'ष', 'स', 'ह']
|
|
@@ -111,3 +115,5 @@ to_add = [' ', '\t', '\n']
|
|
|
111
115
|
for k in character_set.keys():
|
|
112
116
|
for c in to_add:
|
|
113
117
|
character_set[k].append(c)
|
|
118
|
+
|
|
119
|
+
character_set_lookup = {k: set(v) for k, v in character_set.items()}
|
|
@@ -6,6 +6,9 @@ from skrutable.config import load_config_dict_from_json_file
|
|
|
6
6
|
from skrutable.utils import timed
|
|
7
7
|
import re
|
|
8
8
|
|
|
9
|
+
_re_ws_around_newline = re.compile(r'[ \t]*\n[ \t]*')
|
|
10
|
+
_re_multi_newline = re.compile(r'\n+')
|
|
11
|
+
|
|
9
12
|
# load config variables
|
|
10
13
|
config = load_config_dict_from_json_file()
|
|
11
14
|
scansion_syllable_separator = config["scansion_syllable_separator"] # e.g. " "
|
|
@@ -160,8 +163,8 @@ class Scanner(object):
|
|
|
160
163
|
# filter out disallowed characters (numbers, irrelevant punctuation, etc.)
|
|
161
164
|
# pāda separator chars are preserved so they can be converted to \n below
|
|
162
165
|
pAda_sep_chars = set(c for sep in additional_pAda_separators for c in sep)
|
|
163
|
-
for c in
|
|
164
|
-
if c not in phonemes.
|
|
166
|
+
for c in set(cntnts):
|
|
167
|
+
if c not in phonemes.character_set_lookup[scheme_in] and c not in pAda_sep_chars:
|
|
165
168
|
cntnts = cntnts.replace(c, '')
|
|
166
169
|
|
|
167
170
|
# replace all pāda separator strings with newline
|
|
@@ -169,8 +172,8 @@ class Scanner(object):
|
|
|
169
172
|
cntnts = cntnts.replace(sep, '\n')
|
|
170
173
|
|
|
171
174
|
# strip horizontal whitespace around newlines, dedupe, strip leading/trailing
|
|
172
|
-
cntnts =
|
|
173
|
-
cntnts =
|
|
175
|
+
cntnts = _re_ws_around_newline.sub('\n', cntnts)
|
|
176
|
+
cntnts = _re_multi_newline.sub('\n', cntnts)
|
|
174
177
|
cntnts = cntnts.strip()
|
|
175
178
|
|
|
176
179
|
return cntnts
|
|
@@ -207,15 +210,15 @@ class Scanner(object):
|
|
|
207
210
|
# place scansion_syllable_separator after vowels
|
|
208
211
|
for letter in line:
|
|
209
212
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if line_syllables[-1] == scansion_syllable_separator:
|
|
213
|
+
if letter in ('M', 'H'):
|
|
214
|
+
# M and H are explicit syllable codas: strip any trailing separator, append, re-add separator
|
|
215
|
+
if line_syllables and line_syllables[-1] == scansion_syllable_separator:
|
|
213
216
|
line_syllables = line_syllables[:-1]
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
line_syllables +=
|
|
217
|
+
line_syllables += letter + scansion_syllable_separator
|
|
218
|
+
elif letter in phonemes.SLP_vowels_set:
|
|
219
|
+
line_syllables += letter + scansion_syllable_separator
|
|
220
|
+
else:
|
|
221
|
+
line_syllables += letter
|
|
219
222
|
|
|
220
223
|
# e.g. 'ya.dA.ya.dA.hi.Da.rma.sya.glA.ni.rBa.va.ti.BA.ra.ta.'
|
|
221
224
|
# BUT e.g. 'a.Byu.tTA.na.ma.Da.rma.sya.ta.dA.tmA.na.Msf.jA.mya.ha.m'
|
|
@@ -256,8 +259,6 @@ class Scanner(object):
|
|
|
256
259
|
|
|
257
260
|
for line in text_lines:
|
|
258
261
|
|
|
259
|
-
line_weights = ''
|
|
260
|
-
|
|
261
262
|
syllables = line.split(scansion_syllable_separator)
|
|
262
263
|
|
|
263
264
|
try:
|
|
@@ -265,34 +266,37 @@ class Scanner(object):
|
|
|
265
266
|
syllables.pop(-1) # in case of final separator(s)
|
|
266
267
|
except IndexError: pass
|
|
267
268
|
|
|
269
|
+
line_weights_chars = []
|
|
270
|
+
|
|
268
271
|
for n, syllable in enumerate(syllables):
|
|
269
272
|
|
|
270
273
|
if (
|
|
271
274
|
# heavy by nature
|
|
272
|
-
syllable[-1] in phonemes.
|
|
275
|
+
syllable[-1] in phonemes.SLP_long_vowels_set or syllable[-1] in ('M', 'H')
|
|
273
276
|
|
|
274
277
|
or
|
|
275
278
|
|
|
276
279
|
# heavy by position:
|
|
277
280
|
# consonant closes syllable or next syllable begins with a cluster
|
|
278
|
-
syllable[-1] in
|
|
281
|
+
syllable[-1] in phonemes.SLP_consonants_for_scansion_set
|
|
279
282
|
or
|
|
280
283
|
n <= (len(syllables)-2)
|
|
281
284
|
and len(syllables[n+1]) > 1
|
|
282
|
-
and syllables[n+1][0] in
|
|
283
|
-
and syllables[n+1][1] in
|
|
285
|
+
and syllables[n+1][0] in phonemes.SLP_consonants_for_scansion_set
|
|
286
|
+
and syllables[n+1][1] in phonemes.SLP_consonants_for_scansion_set
|
|
287
|
+
|
|
284
288
|
|
|
285
289
|
):
|
|
286
290
|
|
|
287
|
-
|
|
288
|
-
#
|
|
291
|
+
line_weights_chars.append('g')
|
|
292
|
+
# line_weights_chars.append('g_')
|
|
289
293
|
# insofar as two 'l's can equal one 'g', could use this alternative for better visual alignment
|
|
290
294
|
|
|
291
295
|
else:
|
|
292
296
|
|
|
293
|
-
|
|
297
|
+
line_weights_chars.append('l')
|
|
294
298
|
|
|
295
|
-
weights_by_line.append(
|
|
299
|
+
weights_by_line.append(''.join(line_weights_chars))
|
|
296
300
|
|
|
297
301
|
syllable_weights = '\n'.join(weights_by_line) # restore newlines
|
|
298
302
|
return syllable_weights
|
|
@@ -325,21 +329,16 @@ class Scanner(object):
|
|
|
325
329
|
Returns string of 'gaRa'-trisyllable abbreviation, e.g. 'nml'.
|
|
326
330
|
"""
|
|
327
331
|
|
|
328
|
-
for c in
|
|
329
|
-
if c not in
|
|
332
|
+
for c in set(syl_wts):
|
|
333
|
+
if c not in {'l', 'g'}:
|
|
330
334
|
return None
|
|
331
335
|
|
|
332
|
-
|
|
333
|
-
overall_abbreviation = ''
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
weights_of_curr_gaRa += single_weight
|
|
337
|
-
if len(weights_of_curr_gaRa) == 3:
|
|
338
|
-
overall_abbreviation += meter_patterns.gaRas_by_weights[weights_of_curr_gaRa]
|
|
339
|
-
weights_of_curr_gaRa = ''
|
|
340
|
-
|
|
336
|
+
n = len(syl_wts) // 3 * 3
|
|
337
|
+
overall_abbreviation = ''.join(
|
|
338
|
+
meter_patterns.gaRas_by_weights[syl_wts[i:i+3]] for i in range(0, n, 3)
|
|
339
|
+
)
|
|
341
340
|
# leftover lights and heavies (l/g)
|
|
342
|
-
overall_abbreviation +=
|
|
341
|
+
overall_abbreviation += syl_wts[n:]
|
|
343
342
|
|
|
344
343
|
return overall_abbreviation
|
|
345
344
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.6.0"
|
|
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
|
|
File without changes
|
|
File without changes
|