skrutable 2.9.0__tar.gz → 2.9.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.9.0 → skrutable-2.9.1}/PKG-INFO +1 -1
- skrutable-2.9.1/src/skrutable/__init__.py +1 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/meter_identification.py +3 -3
- skrutable-2.9.1/src/skrutable/profiling_runner.py +111 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable.egg-info/PKG-INFO +1 -1
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable.egg-info/SOURCES.txt +1 -0
- skrutable-2.9.0/src/skrutable/__init__.py +0 -1
- {skrutable-2.9.0 → skrutable-2.9.1}/LICENSE.md +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/README.md +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/setup.cfg +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/setup.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/config.json +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/config.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/generate_scheme_vectors.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/impossible_bigrams.json +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/manual.md +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/meter_patterns.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/phonemes.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/run_examples.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/scansion.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/scheme_detection.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/scheme_maps.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/scheme_vectors.json +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/scheme_vectors_mbh.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/splitting.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/transliteration.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/utils.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable/virAma_avoidance.py +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable.egg-info/dependency_links.txt +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable.egg-info/requires.txt +0 -0
- {skrutable-2.9.0 → skrutable-2.9.1}/src/skrutable.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.9.1"
|
|
@@ -1576,7 +1576,9 @@ class VerseTester(object):
|
|
|
1576
1576
|
close1 = abs(eff1 - std_ardha[0]) <= 1
|
|
1577
1577
|
close2 = abs(eff2 - std_ardha[1]) <= 1
|
|
1578
1578
|
if close1 and close2:
|
|
1579
|
-
#
|
|
1579
|
+
# For hypermetric ardhas (1 mora over), attempt krama rescue before
|
|
1580
|
+
# reporting as imperfect. A g→l flip removes 1 mora; if it also passes
|
|
1581
|
+
# gaṇa validation, the ardha is rescued to perfect.
|
|
1580
1582
|
g8_morae_close = 4 if jAti_name == 'āryāgīti' else 2
|
|
1581
1583
|
four_line_pre = len(w_p) >= 4
|
|
1582
1584
|
_cache_key_close = (ardha1_w, ardha2_w, jAti_name)
|
|
@@ -1780,8 +1782,6 @@ class VerseTester(object):
|
|
|
1780
1782
|
continue
|
|
1781
1783
|
|
|
1782
1784
|
# Decompose each ardha into mātrā-gaṇas and validate against Hahn's rules.
|
|
1783
|
-
# Cache keyed on (ardha weights, jāti name) — constant across wiggle candidates
|
|
1784
|
-
# when resplit_keep_midpoint is True (ardhas never change, only cd split does).
|
|
1785
1785
|
g8_morae = 4 if jAti_name == 'āryāgīti' else 2
|
|
1786
1786
|
_cache_key = (ardha1_w, ardha2_w, jAti_name)
|
|
1787
1787
|
if _cache_key in self._jAti_ardha_cache:
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Profiling runner: runs identify_meter_batch on a corpus N times and reports
|
|
3
|
+
mean ± range for key metrics. Use this to compare branches — differences
|
|
4
|
+
smaller than the observed run-to-run range are noise.
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
cd src
|
|
8
|
+
python skrutable/profiling_runner.py /path/to/corpus.txt [--runs N] [--no-parallel]
|
|
9
|
+
|
|
10
|
+
--runs defaults to 5. --no-parallel uses identify_meter in a loop instead of
|
|
11
|
+
identify_meter_batch (no multiprocessing); wall-clock equals CPU time.
|
|
12
|
+
Results print to stderr (same as flush_profiling_report).
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import sys
|
|
16
|
+
import os
|
|
17
|
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
|
18
|
+
import time
|
|
19
|
+
import skrutable.utils as _utils
|
|
20
|
+
_utils._DEBUG_TIMING = True
|
|
21
|
+
|
|
22
|
+
import skrutable.meter_identification as _mi
|
|
23
|
+
from skrutable.meter_identification import MeterIdentifier, flush_profiling_report
|
|
24
|
+
|
|
25
|
+
_SCAN_KEYS = ('scan_clean', 'scan_translit', 'scan_syllabify', 'scan_weights', 'scan_morae_gana')
|
|
26
|
+
_ID_CASCADE_KEYS = ('anuzwuB', 'ardhatraya', 'samavftta_etc', 'samavftta', 'upajAti',
|
|
27
|
+
'ardhasamavftta_perfect', 'vizamavftta', 'jAti',
|
|
28
|
+
'lev_samavftta', 'lev_upajAti', 'lev_ardha', 'lev_vizama')
|
|
29
|
+
_SCAN_LABELS = ('clean', 'transl', 'syl', 'wts', 'mor+g')
|
|
30
|
+
_ID_CASCADE_LABELS = ('anuṣṭ', 'anuṣṭ3', 'vftta↑', 'samav', 'upajāti',
|
|
31
|
+
'ardha✓', 'vizama', 'jāti',
|
|
32
|
+
'lev✗sama', 'lev✗upaj', 'lev✗ardh', 'lev✗visa')
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def run_once(verses, no_parallel=False):
|
|
36
|
+
_mi._category_totals.clear()
|
|
37
|
+
_utils._section_totals.clear()
|
|
38
|
+
|
|
39
|
+
MI = MeterIdentifier()
|
|
40
|
+
t0 = time.perf_counter()
|
|
41
|
+
if no_parallel:
|
|
42
|
+
for v in verses:
|
|
43
|
+
MI.identify_meter(v, resplit_option='resplit_max', resplit_keep_midpoint=True)
|
|
44
|
+
else:
|
|
45
|
+
MI.identify_meter_batch(verses, resplit_option='resplit_max', resplit_keep_midpoint=True)
|
|
46
|
+
wall = time.perf_counter() - t0
|
|
47
|
+
|
|
48
|
+
scan_total = sum(
|
|
49
|
+
sum(_mi._category_totals.get(cat, {}).get(k, 0.0) for cat in _mi._category_totals)
|
|
50
|
+
for k in _SCAN_KEYS
|
|
51
|
+
)
|
|
52
|
+
types_total = sum(
|
|
53
|
+
sum(_mi._category_totals.get(cat, {}).get(k, 0.0) for cat in _mi._category_totals)
|
|
54
|
+
for k in _ID_CASCADE_KEYS
|
|
55
|
+
)
|
|
56
|
+
candidates = _utils._section_totals.get('wiggle_count', 0)
|
|
57
|
+
buckets = {}
|
|
58
|
+
for key in _SCAN_KEYS + _ID_CASCADE_KEYS:
|
|
59
|
+
buckets[key] = sum(_mi._category_totals.get(cat, {}).get(key, 0.0) for cat in _mi._category_totals)
|
|
60
|
+
return {'scan': scan_total, 'types': types_total, 'wall': wall, 'candidates': candidates,
|
|
61
|
+
**buckets}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def main():
|
|
65
|
+
args = sys.argv[1:]
|
|
66
|
+
no_parallel = '--no-parallel' in args
|
|
67
|
+
args = [a for a in args if a != '--no-parallel']
|
|
68
|
+
|
|
69
|
+
n_runs = 5
|
|
70
|
+
if '--runs' in args:
|
|
71
|
+
idx = args.index('--runs')
|
|
72
|
+
n_runs = int(args[idx + 1])
|
|
73
|
+
args = args[:idx] + args[idx + 2:]
|
|
74
|
+
|
|
75
|
+
if not args:
|
|
76
|
+
print(f"Usage: python {sys.argv[0]} /path/to/corpus.txt [--runs N] [--no-parallel]", file=sys.stderr)
|
|
77
|
+
sys.exit(1)
|
|
78
|
+
|
|
79
|
+
corpus_path = args[0]
|
|
80
|
+
|
|
81
|
+
with open(corpus_path, encoding='utf-8') as f:
|
|
82
|
+
verses = f.read().splitlines()
|
|
83
|
+
|
|
84
|
+
mode = 'no-parallel' if no_parallel else 'multiprocess'
|
|
85
|
+
print(f"\nRunning {n_runs} passes over {len(verses)} verses ({mode})...", file=sys.stderr)
|
|
86
|
+
|
|
87
|
+
results = []
|
|
88
|
+
for i in range(n_runs):
|
|
89
|
+
r = run_once(verses, no_parallel=no_parallel)
|
|
90
|
+
print(f" run {i+1}: scan∑ {r['scan']:.2f}s types∑ {r['types']:.2f}s wall {r['wall']:.2f}s candidates {r['candidates']}", file=sys.stderr)
|
|
91
|
+
results.append(r)
|
|
92
|
+
|
|
93
|
+
print(file=sys.stderr)
|
|
94
|
+
col = 14
|
|
95
|
+
print(f" {'metric':{col}} {'mean':>8} {'min':>8} {'max':>8} {'range':>8}", file=sys.stderr)
|
|
96
|
+
print(f" {'-'*56}", file=sys.stderr)
|
|
97
|
+
|
|
98
|
+
summary_metrics = [
|
|
99
|
+
('scan', 'scan∑'),
|
|
100
|
+
('types', 'types∑'),
|
|
101
|
+
('wall', 'wall-clock'),
|
|
102
|
+
] + list(zip(_SCAN_KEYS, _SCAN_LABELS)) + list(zip(_ID_CASCADE_KEYS, _ID_CASCADE_LABELS))
|
|
103
|
+
|
|
104
|
+
for key, label in summary_metrics:
|
|
105
|
+
vals = [r[key] for r in results]
|
|
106
|
+
mean = sum(vals) / len(vals)
|
|
107
|
+
print(f" {label:{col}} {mean:>7.2f}s {min(vals):>7.2f}s {max(vals):>7.2f}s {max(vals)-min(vals):>7.2f}s", file=sys.stderr)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
if __name__ == '__main__':
|
|
111
|
+
main()
|
|
@@ -11,6 +11,7 @@ src/skrutable/manual.md
|
|
|
11
11
|
src/skrutable/meter_identification.py
|
|
12
12
|
src/skrutable/meter_patterns.py
|
|
13
13
|
src/skrutable/phonemes.py
|
|
14
|
+
src/skrutable/profiling_runner.py
|
|
14
15
|
src/skrutable/run_examples.py
|
|
15
16
|
src/skrutable/scansion.py
|
|
16
17
|
src/skrutable/scheme_detection.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.9.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
|