skrutable 2.2.0__tar.gz → 2.3.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.
Files changed (29) hide show
  1. {skrutable-2.2.0 → skrutable-2.3.0}/PKG-INFO +1 -1
  2. skrutable-2.3.0/src/skrutable/__init__.py +1 -0
  3. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/meter_identification.py +84 -7
  4. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable.egg-info/PKG-INFO +1 -1
  5. skrutable-2.2.0/src/skrutable/__init__.py +0 -1
  6. {skrutable-2.2.0 → skrutable-2.3.0}/LICENSE.md +0 -0
  7. {skrutable-2.2.0 → skrutable-2.3.0}/README.md +0 -0
  8. {skrutable-2.2.0 → skrutable-2.3.0}/setup.cfg +0 -0
  9. {skrutable-2.2.0 → skrutable-2.3.0}/setup.py +0 -0
  10. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/config.json +0 -0
  11. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/config.py +0 -0
  12. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/generate_scheme_vectors.py +0 -0
  13. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/impossible_bigrams.json +0 -0
  14. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/manual.md +0 -0
  15. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/meter_patterns.py +0 -0
  16. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/phonemes.py +0 -0
  17. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/run_examples.py +0 -0
  18. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/scansion.py +0 -0
  19. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/scheme_detection.py +0 -0
  20. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/scheme_maps.py +0 -0
  21. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/scheme_vectors.json +0 -0
  22. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/scheme_vectors_mbh.py +0 -0
  23. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/splitting.py +0 -0
  24. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/transliteration.py +0 -0
  25. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable/virAma_avoidance.py +0 -0
  26. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable.egg-info/SOURCES.txt +0 -0
  27. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable.egg-info/dependency_links.txt +0 -0
  28. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable.egg-info/requires.txt +0 -0
  29. {skrutable-2.2.0 → skrutable-2.3.0}/src/skrutable.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: skrutable
3
- Version: 2.2.0
3
+ Version: 2.3.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
@@ -0,0 +1 @@
1
+ __version__ = "2.3.0"
@@ -287,23 +287,61 @@ class VerseTester(object):
287
287
  meter_label += ' [%d: %s]' % ( len(w_to_id), g_to_id )
288
288
 
289
289
  score = meter_scores["samavṛtta, perfect"]
290
+ imperfect_note = None
290
291
 
291
292
  if self.pAdasamatva_count == 3:
292
- meter_label += " (? 3 eva pādāḥ yuktāḥ)"
293
+ imperfect_note = "? 3 eva pādāḥ yuktāḥ"
294
+ meter_label += " (%s)" % imperfect_note
293
295
  score = meter_scores["samavṛtta, imperfect (3)"]
294
296
  elif self.pAdasamatva_count == 2:
295
- meter_label += " (? 2 eva pādāḥ yuktāḥ)"
297
+ imperfect_note = "? 2 eva pādāḥ yuktāḥ"
298
+ meter_label += " (%s)" % imperfect_note
296
299
  score = meter_scores["samavṛtta, imperfect (2)"]
297
300
  elif self.pAdasamatva_count == 0:
298
- meter_label += " (1 eva pādaḥ)"
301
+ imperfect_note = "1 eva pādaḥ"
302
+ meter_label += " (%s)" % imperfect_note
299
303
  score = meter_scores["samavṛtta, quarter, perfect"]
300
304
 
301
305
  # experimental penalty, can later incorporate into config meter_scores
302
- if meter_label == "ajñātasamavṛtta":
306
+ if "ajñātasamavṛtta" in meter_label:
303
307
  score -= 2
304
308
 
309
+ # build diagnostic
310
+ problem_syllables = {}
311
+ canonical = w_to_id # includes final anceps
312
+ for pada_num, w in enumerate(wbp[:4], start=1):
313
+ if w == canonical:
314
+ problem_syllables[pada_num] = []
315
+ elif len(w) != len(canonical):
316
+ problem_syllables[pada_num] = list(range(len(w)))
317
+ else:
318
+ # compare position-by-position; final anceps always matches
319
+ problem_syllables[pada_num] = [
320
+ j for j in range(len(w) - 1) if w[j] != canonical[j]
321
+ ]
322
+
323
+ # collect any hyper/hypometric notes for imperfect_id_label
324
+ length_notes = []
325
+ for pada_num, w in enumerate(wbp[:4], start=1):
326
+ if len(w) > len(canonical):
327
+ length_notes.append("pāda %d hypermetric" % pada_num)
328
+ elif len(w) < len(canonical):
329
+ length_notes.append("pāda %d hypometric" % pada_num)
330
+
331
+ if imperfect_note is None:
332
+ base_label = meter_label
333
+ diagnostic = Diagnostic(perfect_id_label=base_label, problem_syllables=problem_syllables)
334
+ else:
335
+ full_imperfect = imperfect_note
336
+ if length_notes:
337
+ full_imperfect += "; " + "; ".join(length_notes)
338
+ diagnostic = Diagnostic(imperfect_id_label=full_imperfect, problem_syllables=problem_syllables)
339
+
305
340
  # may tie with pre-existing result (e.g., upajāti)
341
+ old_score = Vrs.identification_score
306
342
  self.combine_results(Vrs, new_label=meter_label, new_score=score)
343
+ if score >= old_score:
344
+ Vrs.diagnostic = diagnostic
307
345
 
308
346
 
309
347
 
@@ -340,19 +378,25 @@ class VerseTester(object):
340
378
  Vrs.identification_score = meter_scores["ardhasamavṛtta, perfect, unknown"]
341
379
 
342
380
  Vrs.meter_label = meter_label
381
+ Vrs.diagnostic = Diagnostic(perfect_id_label=meter_label, problem_syllables={1: [], 2: [], 3: [], 4: []})
343
382
 
344
383
 
345
384
  def evaluate_upajAti(self, Vrs):
346
385
  # sufficient length similarity already assured, now just evaluate
347
386
 
348
387
  wbp = Vrs.syllable_weights.split('\n') # weights by pāda
349
- wbp_lens = [ len(line) for line in wbp ]
388
+ wbp_lens_orig = [ len(line) for line in wbp ]
389
+ wbp_lens = list(wbp_lens_orig)
350
390
  gs_to_id = Vrs.gaRa_abbreviations.split('\n')
351
391
 
352
392
  # special exception for triṣṭubh-jagatī mix
353
393
  # see Karashima 2016 "The Triṣṭubh-Jagatī Verses in the Saddharmapuṇḍarīka"
354
394
  unique_sorted_lens = list(set(wbp_lens))
355
395
  unique_sorted_lens.sort()
396
+
397
+ # track which original pada indices (0-based) are excluded
398
+ excluded_indices = []
399
+
356
400
  if unique_sorted_lens != [11, 12]:
357
401
 
358
402
  # if imperfect, exclude all info for lines of non-majority lengths
@@ -365,6 +409,7 @@ class VerseTester(object):
365
409
  for i, weights in enumerate(wbp):
366
410
  if len(weights) != most_freq_pAda_len:
367
411
  to_exclude.append(i)
412
+ excluded_indices = list(to_exclude)
368
413
  for i in reversed(to_exclude): # delete in descending index order, avoid index errors
369
414
  del wbp[i]
370
415
  del wbp_lens[i]
@@ -438,7 +483,7 @@ class VerseTester(object):
438
483
  else:
439
484
  score = meter_scores["none found"]
440
485
 
441
-
486
+ imperfect_note = None
442
487
  overall_meter_label = "upajāti %s: %s" % (
443
488
  family,
444
489
  combined_meter_labels
@@ -448,9 +493,39 @@ class VerseTester(object):
448
493
  len(wbp_lens) != 4 and
449
494
  unique_sorted_lens != [11, 12]
450
495
  ): # not perfect and also not triṣṭubh-jagatī-saṃkara
451
- overall_meter_label += " (? %d eva pādāḥ yuktāḥ)" % len(wbp_lens)
496
+ imperfect_note = "? %d eva pādāḥ yuktāḥ" % len(wbp_lens)
497
+ overall_meter_label += " (%s)" % imperfect_note
498
+
499
+ # build diagnostic: problem_syllables keyed 1–4
500
+ # included pādas: no positional errors (upajāti pādas are heterogeneous by design)
501
+ # excluded pādas: hyper/hypometric
502
+ most_freq_len = wbp_lens[0] if wbp_lens else None
503
+ problem_syllables = {}
504
+ length_notes = []
505
+ for pada_num in range(1, 5):
506
+ orig_len = wbp_lens_orig[pada_num - 1] if pada_num - 1 < len(wbp_lens_orig) else None
507
+ if pada_num - 1 in excluded_indices:
508
+ problem_syllables[pada_num] = list(range(orig_len)) if orig_len is not None else []
509
+ if orig_len is not None and most_freq_len is not None:
510
+ if orig_len > most_freq_len:
511
+ length_notes.append("pāda %d hypermetric" % pada_num)
512
+ else:
513
+ length_notes.append("pāda %d hypometric" % pada_num)
514
+ else:
515
+ problem_syllables[pada_num] = []
452
516
 
517
+ if imperfect_note is None:
518
+ diagnostic = Diagnostic(perfect_id_label=overall_meter_label, problem_syllables=problem_syllables)
519
+ else:
520
+ full_imperfect = imperfect_note
521
+ if length_notes:
522
+ full_imperfect += "; " + "; ".join(length_notes)
523
+ diagnostic = Diagnostic(imperfect_id_label=full_imperfect, problem_syllables=problem_syllables)
524
+
525
+ old_score = Vrs.identification_score
453
526
  self.combine_results(Vrs, overall_meter_label, score)
527
+ if score >= old_score:
528
+ Vrs.diagnostic = diagnostic
454
529
 
455
530
 
456
531
  def is_vizamavftta(self, Vrs):
@@ -462,6 +537,7 @@ class VerseTester(object):
462
537
  if (gs_to_id[0],gs_to_id[1],gs_to_id[2],gs_to_id[3]) == (a, b, c, d):
463
538
  Vrs.identification_score = meter_scores["viṣamavṛtta, perfect"]
464
539
  Vrs.meter_label = meter_patterns.vizamavftta_by_4_tuple[(a, b, c, d)]
540
+ Vrs.diagnostic = Diagnostic(perfect_id_label=Vrs.meter_label, problem_syllables={1: [], 2: [], 3: [], 4: []})
465
541
  return True
466
542
 
467
543
  else:
@@ -593,6 +669,7 @@ class VerseTester(object):
593
669
  else: # if all four pAdas proven valid, i.e., if no breaks
594
670
  Vrs.meter_label = jAti_name + " (%s)" % str(std_pattern)[1:-1]
595
671
  Vrs.identification_score = meter_scores["jāti, perfect"]
672
+ Vrs.diagnostic = Diagnostic(perfect_id_label=Vrs.meter_label, problem_syllables={1: [], 2: [], 3: [], 4: []})
596
673
 
597
674
  # should be combining results in case of previous match
598
675
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: skrutable
3
- Version: 2.2.0
3
+ Version: 2.3.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
@@ -1 +0,0 @@
1
- __version__ = "2.2.0"
File without changes
File without changes
File without changes
File without changes