beaunix commited on
Commit
2874635
·
verified ·
1 Parent(s): df88f0b

upload sources files

Browse files
src/artifacts/bbaw_clean.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:efc61f36ddbad83fe80db0578e619d5c3a03ea9604bcf25f86b538f8297f4afe
3
+ size 4906492
src/artifacts/best_modelv10.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45e9230c4eb8b1b217aa5a77c72343586724ca4ae0163195cb8f1cff921bd9ef
3
+ size 51503961
src/artifacts/class_map50_v9.json ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Aa1": 0.767958,
3
+ "a1": 0.78309,
4
+ "a2": 0.880375,
5
+ "a24": 0.838667,
6
+ "a30": 0.8955,
7
+ "a40": 0.815635,
8
+ "a42": 0.703666,
9
+ "a50": 0.734643,
10
+ "b1": 0.745614,
11
+ "cartouche": 0.742518,
12
+ "d1": 0.8355,
13
+ "d2": 0.722694,
14
+ "d4": 0.690576,
15
+ "d10": 0.748036,
16
+ "d21": 0.697142,
17
+ "d28": 0.815521,
18
+ "d35": 0.766456,
19
+ "d36": 0.745607,
20
+ "d37": 0.80672,
21
+ "d39": 0.6975,
22
+ "d40": 0.637171,
23
+ "d45": 0.995,
24
+ "d46": 0.662479,
25
+ "d54": 0.7205,
26
+ "d55": 0.716696,
27
+ "d56": 0.995,
28
+ "d58": 0.761667,
29
+ "d60": 0.802125,
30
+ "e1": 0.714966,
31
+ "e7": 0.796,
32
+ "m4": 0.8103,
33
+ "e16": 0.945,
34
+ "e23": 0.775109,
35
+ "e34": 0.727156,
36
+ "f1": 0.768667,
37
+ "f4": 0.688677,
38
+ "f12": 0.695202,
39
+ "f13": 0.7915,
40
+ "f26": 0.796,
41
+ "f31": 0.723599,
42
+ "f32": 0.746904,
43
+ "f35": 0.681794,
44
+ "f39": 0.661054,
45
+ "f51": 0.735154,
46
+ "g1": 0.797646,
47
+ "g5": 0.753271,
48
+ "g7": 0.83225,
49
+ "g14": 0.854692,
50
+ "g17": 0.791536,
51
+ "g25": 0.66403,
52
+ "g36": 0.851243,
53
+ "g39": 0.731365,
54
+ "g40": 0.715446,
55
+ "g41": 0.783,
56
+ "g43": 0.775861,
57
+ "h1": 0.81825,
58
+ "h6": 0.677475,
59
+ "i1": 0.578933,
60
+ "i9": 0.714246,
61
+ "i10": 0.791097,
62
+ "i12": 0.744258,
63
+ "f34": 0.752229,
64
+ "l1": 0.677185,
65
+ "l2": 0.806576,
66
+ "m2": 0.8824,
67
+ "m3": 0.632262,
68
+ "m12": 0.634417,
69
+ "m16": 0.8955,
70
+ "m17": 0.682438,
71
+ "m18": 0.523278,
72
+ "o29": 0.596375,
73
+ "m22": 0.64869,
74
+ "m23": 0.739798,
75
+ "m24": 0.656,
76
+ "m42": 0.6955,
77
+ "n1": 0.770312,
78
+ "n5": 0.694625,
79
+ "n8": 0.666929,
80
+ "n14": 0.68853,
81
+ "n17": 0.66668,
82
+ "n23": 0.572786,
83
+ "n25": 0.797167,
84
+ "n26": 0.655639,
85
+ "n27": 0.354075,
86
+ "n29": 0.663982,
87
+ "n33": 0.635015,
88
+ "n35": 0.643757,
89
+ "n36": 0.645833,
90
+ "n37": 0.758489,
91
+ "o1": 0.749785,
92
+ "o3": 0.90775,
93
+ "o4": 0.77066,
94
+ "o6": 0.795963,
95
+ "o28": 0.740014,
96
+ "o34": 0.677944,
97
+ "o49": 0.683443,
98
+ "p1": 0.8635,
99
+ "p3": 0.73425,
100
+ "q1": 0.812199,
101
+ "q3": 0.691889,
102
+ "r4": 0.723896,
103
+ "r7": 0.746,
104
+ "r8": 0.770637,
105
+ "r11": 0.737125,
106
+ "s3": 0.661427,
107
+ "s19": 0.398,
108
+ "s28": 0.732064,
109
+ "s29": 0.732999,
110
+ "s34": 0.720939,
111
+ "s38": 0.773072,
112
+ "s40": 0.661568,
113
+ "t22": 0.683295,
114
+ "t28": 0.791067,
115
+ "t30": 0.4455,
116
+ "u1": 0.602771,
117
+ "u6": 0.746445,
118
+ "u15": 0.745386,
119
+ "u23": 0.741667,
120
+ "u33": 0.829683,
121
+ "u36": 0.782055,
122
+ "unknown": 0.625642,
123
+ "v4": 0.823063,
124
+ "v6": 0.81325,
125
+ "v7": 0.762101,
126
+ "v13": 0.785994,
127
+ "v20": 0.72525,
128
+ "v28": 0.694478,
129
+ "v29": 0.732064,
130
+ "v30": 0.79309,
131
+ "v31": 0.792846,
132
+ "w10": 0.696229,
133
+ "w14": 0.638561,
134
+ "w17": 0.82971,
135
+ "w19": 0.84904,
136
+ "w22": 0.615812,
137
+ "w24": 0.797227,
138
+ "w25": 0.635681,
139
+ "x1": 0.657659,
140
+ "x8": 0.700294,
141
+ "y1": 0.667995,
142
+ "y2": 0.702071,
143
+ "y3": 0.808833,
144
+ "y5": 0.710031,
145
+ "z1": 0.590246,
146
+ "z2": 0.690017,
147
+ "z3": 0.66365,
148
+ "z4": 0.697406,
149
+ "z7": 0.774771,
150
+ "z11": 0.77225,
151
+ "Aa15": 0.61919
152
+ }
src/artifacts/confusion_matrix_v9_normalized.csv ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,Aa1,a1,a2,a24,a30,a40,a42,a50,b1,cartouche,d1,d2,d4,d10,d21,d28,d35,d36,d37,d39,d40,d45,d46,d54,d55,d56,d58,d60,e1,e7,m4,e16,e23,e34,f1,f4,f12,f13,f26,f31,f32,f35,f39,f51,g1,g5,g7,g14,g17,g25,g36,g39,g40,g41,g43,h1,h6,i1,i9,i10,i12,f34,l1,l2,m2,m3,m12,m16,m17,m18,o29,m22,m23,m24,m42,n1,n5,n8,n14,n17,n23,n25,n26,n27,n29,n33,n35,n36,n37,o1,o3,o4,o6,o28,o34,o49,p1,p3,q1,q3,r4,r7,r8,r11,s3,s19,s28,s29,s34,s38,s40,t22,t28,t30,u1,u6,u15,u23,u33,u36,unknown,v4,v6,v7,v13,v20,v28,v29,v30,v31,w10,w14,w17,w19,w22,w24,w25,x1,x8,y1,y2,y3,y5,z1,z2,z3,z4,z7,z11,Aa15,background
2
+ Aa1,0.9230769230769231,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.02564102564102564,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0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.6666666666666666,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.3333333333333333
122
+ unknown,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.012345679012345678,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.006172839506172839,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.012345679012345678,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.7222222222222222,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.006172839506172839,0.0,0.006172839506172839,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.2345679012345679
123
+ v4,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.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,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.8076923076923077,0.19230769230769232
152
+ background,0.0,0.005076142131979695,0.0,0.005076142131979695,0.0,0.0,0.0,0.0,0.0,0.13705583756345177,0.0,0.01015228426395939,0.01015228426395939,0.0,0.03553299492385787,0.0,0.005076142131979695,0.01015228426395939,0.0,0.005076142131979695,0.015228426395939087,0.0,0.030456852791878174,0.005076142131979695,0.0,0.0,0.01015228426395939,0.0,0.005076142131979695,0.0,0.0,0.0,0.0,0.005076142131979695,0.0,0.0,0.01015228426395939,0.0,0.0,0.0,0.005076142131979695,0.005076142131979695,0.01015228426395939,0.005076142131979695,0.0,0.01015228426395939,0.0,0.0,0.005076142131979695,0.01015228426395939,0.0,0.0,0.0,0.0,0.015228426395939087,0.0,0.005076142131979695,0.0,0.02030456852791878,0.005076142131979695,0.005076142131979695,0.005076142131979695,0.02030456852791878,0.005076142131979695,0.0,0.01015228426395939,0.0,0.0,0.030456852791878174,0.005076142131979695,0.01015228426395939,0.0,0.015228426395939087,0.0,0.0,0.0,0.025380710659898477,0.005076142131979695,0.005076142131979695,0.02030456852791878,0.0,0.0,0.0,0.01015228426395939,0.0,0.0,0.030456852791878174,0.01015228426395939,0.005076142131979695,0.0,0.0,0.005076142131979695,0.0,0.0,0.025380710659898477,0.01015228426395939,0.0,0.005076142131979695,0.0,0.005076142131979695,0.005076142131979695,0.0,0.005076142131979695,0.0,0.0,0.0,0.0,0.015228426395939087,0.01015228426395939,0.005076142131979695,0.005076142131979695,0.01015228426395939,0.0,0.005076142131979695,0.030456852791878174,0.005076142131979695,0.0,0.0,0.0,0.005076142131979695,0.030456852791878174,0.0,0.0,0.005076142131979695,0.01015228426395939,0.005076142131979695,0.005076142131979695,0.0,0.0,0.0,0.005076142131979695,0.005076142131979695,0.0,0.0,0.0,0.0,0.01015228426395939,0.05583756345177665,0.015228426395939087,0.01015228426395939,0.0,0.0,0.0,0.030456852791878174,0.015228426395939087,0.0,0.0,0.0,0.005076142131979695,0.02030456852791878,0.0
src/artifacts/sphinx_trie_v4.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87727e0f65fb34bdc28555e509849f78bb66d538b3ececa36e68161fc3bd3cdd
3
+ size 24261317
src/cartouche_matcher.py ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import math
7
+ from dataclasses import dataclass
8
+ from pathlib import Path
9
+ from typing import Optional
10
+ from collections import Counter
11
+
12
+ UNKNOWN_TOKEN = 'Unknown'
13
+ EPS = 1e-6
14
+ SKIP_NAME = -3.0 # name code the detector missed entirely
15
+ SKIP_SLOT = -2.5 # spurious detection (double-box, bracket noise)
16
+ GAP_FILL = -1.2 # synthetic Unknown slot consumed by a name code
17
+ SUB_COARSE = -4.0 # substitution without a confusion matrix
18
+ SUB_CAP = -5.0 # floor for matrix-derived substitution scores
19
+ # (keeps one bad sub cheaper than del+ins)
20
+ ACCEPT_THRESHOLD = -2.0 # min normalized score to accept a name
21
+
22
+
23
+ def normalize_code(yolo_name: str) -> str:
24
+ """YOLO class name -> canonical Gardiner code ('n35'->'N35',
25
+ 'aa15'->'Aa15', 'unknown'->'Unknown'). 'cartouche' passes through."""
26
+ if yolo_name in ('cartouche', UNKNOWN_TOKEN):
27
+
28
+ return yolo_name
29
+
30
+ if yolo_name.lower() == 'unknown':
31
+
32
+ return UNKNOWN_TOKEN
33
+
34
+ if yolo_name[:2].lower() == 'aa':
35
+
36
+ return 'Aa' + yolo_name[2:]
37
+
38
+ return yolo_name[0].upper() + yolo_name[1:]
39
+
40
+
41
+ @dataclass
42
+ class RoyalMatch:
43
+ name_key : str # key in royal_names.json
44
+ translit : str
45
+ english : str
46
+ spelling : list[str] # the matched spelling (canonical codes)
47
+ score : float # normalized alignment score
48
+ aligned_codes : list[str] # per input slot: assigned name code,
49
+ # or original top-1 if slot was skipped
50
+ verified : bool
51
+
52
+
53
+ def load_royal_names(path: Optional[Path] = None) -> dict:
54
+ """Load royal_names.json -> {key: meta}. Missing file -> {}."""
55
+ p = Path(path) if path else Path(__file__).parent / 'royal_names.json'
56
+ if not p.exists():
57
+ return {}
58
+ with open(p, encoding='utf-8') as f:
59
+ data = json.load(f)
60
+ return data.get('names', {})
61
+
62
+
63
+ def _match_score(
64
+ slot : list[tuple[str, float]],
65
+ code : str,
66
+ sub_cost : Optional[dict],
67
+ ) -> float:
68
+ """Score for aligning one detected slot to one name code."""
69
+ top1 = slot[0][0] if slot else UNKNOWN_TOKEN
70
+
71
+ for c, conf in slot:
72
+
73
+ if c == code:
74
+
75
+ return math.log(conf + EPS)
76
+
77
+ if top1 == UNKNOWN_TOKEN:
78
+
79
+ return GAP_FILL
80
+
81
+ if sub_cost is not None:
82
+
83
+ c = sub_cost.get((top1.lower(), code.lower()))
84
+
85
+ if c is not None:
86
+
87
+ return max(-c, SUB_CAP)
88
+
89
+ return SUB_COARSE
90
+
91
+ # Needleman-Wunsch over (slots x spelling).
92
+ def _align(
93
+ slots : list[list[tuple[str, float]]],
94
+ spelling : list[str],
95
+ sub_cost : Optional[dict],
96
+ ) -> tuple[float, list[str]]:
97
+ """
98
+ Needleman-Wunsch over (slots x spelling).
99
+ Returns
100
+ (normalized_score, aligned_codes) — aligned_codes has one entry per
101
+ slot: the name code assigned to it, or the slot's own top-1 when the
102
+ slot was skipped as spurious.
103
+ """
104
+ m, n = len(slots), len(spelling)
105
+
106
+ NEG = float('-inf')
107
+
108
+ dp = [[NEG] * (n + 1) for _ in range(m + 1)]
109
+ back = [[None] * (n + 1) for _ in range(m + 1)]
110
+
111
+ dp[0][0] = 0.0
112
+
113
+ for i in range(1, m + 1):
114
+
115
+ dp[i][0] = dp[i - 1][0] + SKIP_SLOT
116
+ back[i][0] = 'up'
117
+
118
+ for j in range(1, n + 1):
119
+
120
+ dp[0][j] = dp[0][j - 1] + SKIP_NAME
121
+ back[0][j] = 'left'
122
+
123
+ for i in range(1, m + 1):
124
+ for j in range(1, n + 1):
125
+ diag = dp[i - 1][j - 1] + _match_score(
126
+ slots[i - 1], spelling[j - 1], sub_cost)
127
+ up = dp[i - 1][j] + SKIP_SLOT # spurious slot
128
+ left = dp[i][j - 1] + SKIP_NAME # missed name code
129
+ best = max(diag, up, left)
130
+ dp[i][j] = best
131
+ back[i][j] = ('diag' if best == diag else
132
+ 'up' if best == up else 'left')
133
+
134
+ # Backtrack: assign a code (or keep top-1) per slot
135
+ aligned = [''] * m
136
+ i, j = m, n
137
+
138
+ while i > 0 or j > 0:
139
+ move = back[i][j]
140
+ if move == 'diag':
141
+ aligned[i - 1] = spelling[j - 1]
142
+ i, j = i - 1, j - 1
143
+ elif move == 'up':
144
+ aligned[i - 1] = slots[i - 1][0][0] # spurious: keep YOLO code
145
+ i -= 1
146
+ else:
147
+ j -= 1 # missed sign: no slot
148
+ return dp[m][n] / max(n, 1), aligned
149
+
150
+
151
+ def match_cartouche(
152
+ slots : list[list[tuple[str, float]]],
153
+ royal_names : dict,
154
+ sub_cost : Optional[dict] = None,
155
+ threshold : float = ACCEPT_THRESHOLD,
156
+ ) -> Optional[RoyalMatch]:
157
+ """
158
+ Match a cartouche's interior slots (reading order, top-3 per slot,
159
+ canonical Gardiner codes) against every royal-name spelling. Returns
160
+ the best RoyalMatch, or None if nothing c
161
+ clears `threshold` — in that case the caller keeps the raw YOLO codes.
162
+ """
163
+ slots = [s for s in slots if s]
164
+
165
+ if not slots:
166
+ return None
167
+
168
+ best: Optional[RoyalMatch] = None
169
+
170
+ for key, meta in royal_names.items():
171
+
172
+ prior = 0.1 * math.log(meta.get('freq', 1) + 1)
173
+
174
+ for spelling in meta.get('spellings', []):
175
+
176
+ if not spelling:
177
+ continue
178
+
179
+ # Cartouche interior reading order depends on which way the
180
+ # wall/figures face, which is independent of (and sometimes
181
+ # opposite to) the `direction` passed for the outer text —
182
+ # royal_names.json spellings are recorded in one canonical
183
+ # order, so a mirrored cartouche must not be penalized as a
184
+ # bad match. Try both orientations, keep the better one.
185
+ score_fwd, aligned_fwd = _align(slots, spelling, sub_cost)
186
+ score_rev, aligned_rev = _align(
187
+ list(reversed(slots)), spelling, sub_cost)
188
+
189
+ if score_rev > score_fwd:
190
+ score, aligned = score_rev, list(reversed(aligned_rev))
191
+ else:
192
+ score, aligned = score_fwd, aligned_fwd
193
+
194
+ score += prior
195
+
196
+ if best is None or score > best.score:
197
+
198
+ best = RoyalMatch(
199
+ name_key = key,
200
+ translit = meta.get('translit', key),
201
+ english = meta.get('english', ''),
202
+ spelling = list(spelling),
203
+ score = score,
204
+ aligned_codes = aligned,
205
+ verified = bool(meta.get('verified', False)),
206
+ )
207
+
208
+ if best is not None and best.score < threshold:
209
+ return None
210
+
211
+ return best
212
+
213
+
214
+ def apply_panel_consensus(
215
+ results : list[Optional[RoyalMatch]],
216
+ slots_per_cart : list[list[list[tuple[str, float]]]],
217
+ royal_names : dict,
218
+ sub_cost : Optional[dict] = None,
219
+ min_votes : int = 2,
220
+ margin : float = 1.0,
221
+ floor : float = -3.0,
222
+ ) -> list[tuple[Optional[RoyalMatch], bool]]:
223
+ """
224
+ Panel-level aggregation: a wall/panel usually names ONE king, so
225
+ confidently-resolved cartouches inform the refused ones.
226
+
227
+ If >= `min_votes` cartouches resolved to the same name, each refused
228
+ cartouche is re-scored against THAT name only; it adopts the consensus
229
+ iff (a) the consensus score clears `floor` (an absolute guard — pixels
230
+ that actively contradict the name stay refused; matters especially
231
+ when the lexicon is small and the margin test is vacuous) and (b) the
232
+ consensus name is within `margin` of the cartouche's own best name.
233
+
234
+ Returns [(match_or_None, inferred)] aligned with the inputs;
235
+ inferred=True marks consensus-adopted results (surface this in the
236
+ API — it is a contextual inference, not a pixel-level read).
237
+ """
238
+
239
+ votes = Counter(r.name_key for r in results if r is not None)
240
+ if not votes:
241
+ return [(r, False) for r in results]
242
+ top_name, n_votes = votes.most_common(1)[0]
243
+ if n_votes < min_votes:
244
+ return [(r, False) for r in results]
245
+
246
+ consensus_lex = {top_name: royal_names[top_name]}
247
+ out: list[tuple[Optional[RoyalMatch], bool]] = []
248
+ for r, slots in zip(results, slots_per_cart):
249
+ if r is not None or not slots:
250
+ out.append((r, False))
251
+ continue
252
+ best_any = match_cartouche(slots, royal_names, sub_cost,
253
+ threshold=float('-inf'))
254
+ best_cons = match_cartouche(slots, consensus_lex, sub_cost,
255
+ threshold=float('-inf'))
256
+ if (best_cons is not None and best_any is not None
257
+ and best_cons.score >= floor
258
+ and best_cons.score >= best_any.score - margin):
259
+ out.append((best_cons, True))
260
+ else:
261
+ out.append((None, False))
262
+ return out
263
+
src/determinatives.json ADDED
@@ -0,0 +1,1075 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "source": "auto-mined from dickson.csv",
3
+ "criteria": "last_count>=5 AND last_rate>=0.5 OR last_count>=2 AND last_rate>=0.7",
4
+ "count": 178,
5
+ "codes": {
6
+ "Z2": {
7
+ "last_count": 762,
8
+ "total_count": 887,
9
+ "last_rate": 0.859,
10
+ "category": "plural_three"
11
+ },
12
+ "Z1": {
13
+ "last_count": 483,
14
+ "total_count": 827,
15
+ "last_rate": 0.584,
16
+ "category": "singular_or_ideogram"
17
+ },
18
+ "Y1": {
19
+ "last_count": 416,
20
+ "total_count": 648,
21
+ "last_rate": 0.642,
22
+ "category": "abstract"
23
+ },
24
+ "D54": {
25
+ "last_count": 310,
26
+ "total_count": 387,
27
+ "last_rate": 0.801,
28
+ "category": "motion"
29
+ },
30
+ "A2": {
31
+ "last_count": 270,
32
+ "total_count": 320,
33
+ "last_rate": 0.844,
34
+ "category": "man"
35
+ },
36
+ "D40": {
37
+ "last_count": 228,
38
+ "total_count": 269,
39
+ "last_rate": 0.848,
40
+ "category": "body_part"
41
+ },
42
+ "A1": {
43
+ "last_count": 225,
44
+ "total_count": 363,
45
+ "last_rate": 0.62,
46
+ "category": "man"
47
+ },
48
+ "O1": {
49
+ "last_count": 206,
50
+ "total_count": 317,
51
+ "last_rate": 0.65,
52
+ "category": "house_or_place"
53
+ },
54
+ "G37": {
55
+ "last_count": 175,
56
+ "total_count": 265,
57
+ "last_rate": 0.66,
58
+ "category": "bird"
59
+ },
60
+ "A24": {
61
+ "last_count": 150,
62
+ "total_count": 190,
63
+ "last_rate": 0.789,
64
+ "category": "man"
65
+ },
66
+ "Z3": {
67
+ "last_count": 113,
68
+ "total_count": 120,
69
+ "last_rate": 0.942,
70
+ "category": "plural_three_horizontal"
71
+ },
72
+ "F51": {
73
+ "last_count": 100,
74
+ "total_count": 130,
75
+ "last_rate": 0.769,
76
+ "category": "animal_part"
77
+ },
78
+ "M3": {
79
+ "last_count": 99,
80
+ "total_count": 161,
81
+ "last_rate": 0.615,
82
+ "category": "wood"
83
+ },
84
+ "Q7": {
85
+ "last_count": 81,
86
+ "total_count": 89,
87
+ "last_rate": 0.91,
88
+ "category": "furniture"
89
+ },
90
+ "B1": {
91
+ "last_count": 80,
92
+ "total_count": 118,
93
+ "last_rate": 0.678,
94
+ "category": "woman"
95
+ },
96
+ "A40": {
97
+ "last_count": 79,
98
+ "total_count": 94,
99
+ "last_rate": 0.84,
100
+ "category": "god"
101
+ },
102
+ "N25": {
103
+ "last_count": 76,
104
+ "total_count": 85,
105
+ "last_rate": 0.894,
106
+ "category": "foreign_land"
107
+ },
108
+ "N5": {
109
+ "last_count": 67,
110
+ "total_count": 115,
111
+ "last_rate": 0.583,
112
+ "category": "sun_or_time"
113
+ },
114
+ "S28": {
115
+ "last_count": 65,
116
+ "total_count": 84,
117
+ "last_rate": 0.774,
118
+ "category": "crown_or_dress"
119
+ },
120
+ "O39": {
121
+ "last_count": 58,
122
+ "total_count": 80,
123
+ "last_rate": 0.725,
124
+ "category": "building_or_place"
125
+ },
126
+ "O49": {
127
+ "last_count": 55,
128
+ "total_count": 67,
129
+ "last_rate": 0.821,
130
+ "category": "town_or_place"
131
+ },
132
+ "V1": {
133
+ "last_count": 52,
134
+ "total_count": 91,
135
+ "last_rate": 0.571,
136
+ "category": "rope_basket"
137
+ },
138
+ "F27": {
139
+ "last_count": 45,
140
+ "total_count": 55,
141
+ "last_rate": 0.818,
142
+ "category": "animal_part"
143
+ },
144
+ "P1": {
145
+ "last_count": 42,
146
+ "total_count": 52,
147
+ "last_rate": 0.808,
148
+ "category": "ship"
149
+ },
150
+ "G7": {
151
+ "last_count": 39,
152
+ "total_count": 44,
153
+ "last_rate": 0.886,
154
+ "category": "bird"
155
+ },
156
+ "E1": {
157
+ "last_count": 38,
158
+ "total_count": 60,
159
+ "last_rate": 0.633,
160
+ "category": "mammal"
161
+ },
162
+ "T30": {
163
+ "last_count": 38,
164
+ "total_count": 63,
165
+ "last_rate": 0.603,
166
+ "category": "weapon_tool"
167
+ },
168
+ "M1": {
169
+ "last_count": 35,
170
+ "total_count": 61,
171
+ "last_rate": 0.574,
172
+ "category": "plant"
173
+ },
174
+ "N31": {
175
+ "last_count": 35,
176
+ "total_count": 63,
177
+ "last_rate": 0.556,
178
+ "category": "celestial_or_geographical"
179
+ },
180
+ "D3": {
181
+ "last_count": 34,
182
+ "total_count": 50,
183
+ "last_rate": 0.68,
184
+ "category": "body_part"
185
+ },
186
+ "W10": {
187
+ "last_count": 34,
188
+ "total_count": 54,
189
+ "last_rate": 0.63,
190
+ "category": "vessel"
191
+ },
192
+ "N1": {
193
+ "last_count": 28,
194
+ "total_count": 50,
195
+ "last_rate": 0.56,
196
+ "category": "celestial_or_geographical"
197
+ },
198
+ "N8": {
199
+ "last_count": 28,
200
+ "total_count": 37,
201
+ "last_rate": 0.757,
202
+ "category": "celestial_or_geographical"
203
+ },
204
+ "Z8": {
205
+ "last_count": 26,
206
+ "total_count": 49,
207
+ "last_rate": 0.531,
208
+ "category": "stroke_or_marker"
209
+ },
210
+ "I12": {
211
+ "last_count": 25,
212
+ "total_count": 25,
213
+ "last_rate": 1.0,
214
+ "category": "reptile"
215
+ },
216
+ "A17": {
217
+ "last_count": 24,
218
+ "total_count": 45,
219
+ "last_rate": 0.533,
220
+ "category": "man"
221
+ },
222
+ "P5": {
223
+ "last_count": 24,
224
+ "total_count": 35,
225
+ "last_rate": 0.686,
226
+ "category": "ship"
227
+ },
228
+ "N2": {
229
+ "last_count": 23,
230
+ "total_count": 25,
231
+ "last_rate": 0.92,
232
+ "category": "celestial_or_geographical"
233
+ },
234
+ "W22": {
235
+ "last_count": 22,
236
+ "total_count": 33,
237
+ "last_rate": 0.667,
238
+ "category": "vessel"
239
+ },
240
+ "A7": {
241
+ "last_count": 21,
242
+ "total_count": 34,
243
+ "last_rate": 0.618,
244
+ "category": "man"
245
+ },
246
+ "Y2": {
247
+ "last_count": 19,
248
+ "total_count": 26,
249
+ "last_rate": 0.731,
250
+ "category": "writing_or_abstract"
251
+ },
252
+ "A30": {
253
+ "last_count": 18,
254
+ "total_count": 32,
255
+ "last_rate": 0.562,
256
+ "category": "man"
257
+ },
258
+ "W3": {
259
+ "last_count": 18,
260
+ "total_count": 32,
261
+ "last_rate": 0.562,
262
+ "category": "vessel"
263
+ },
264
+ "D12": {
265
+ "last_count": 17,
266
+ "total_count": 24,
267
+ "last_rate": 0.708,
268
+ "category": "body_part"
269
+ },
270
+ "D26": {
271
+ "last_count": 17,
272
+ "total_count": 20,
273
+ "last_rate": 0.85,
274
+ "category": "body_part"
275
+ },
276
+ "D53": {
277
+ "last_count": 16,
278
+ "total_count": 28,
279
+ "last_rate": 0.571,
280
+ "category": "body_part"
281
+ },
282
+ "V19": {
283
+ "last_count": 16,
284
+ "total_count": 26,
285
+ "last_rate": 0.615,
286
+ "category": "rope_basket"
287
+ },
288
+ "A13": {
289
+ "last_count": 15,
290
+ "total_count": 21,
291
+ "last_rate": 0.714,
292
+ "category": "man"
293
+ },
294
+ "A14": {
295
+ "last_count": 15,
296
+ "total_count": 19,
297
+ "last_rate": 0.789,
298
+ "category": "man"
299
+ },
300
+ "X4": {
301
+ "last_count": 15,
302
+ "total_count": 28,
303
+ "last_rate": 0.536,
304
+ "category": "bread_or_food"
305
+ },
306
+ "A28": {
307
+ "last_count": 14,
308
+ "total_count": 27,
309
+ "last_rate": 0.519,
310
+ "category": "man"
311
+ },
312
+ "Z6": {
313
+ "last_count": 14,
314
+ "total_count": 17,
315
+ "last_rate": 0.824,
316
+ "category": "stroke_or_marker"
317
+ },
318
+ "I14": {
319
+ "last_count": 13,
320
+ "total_count": 14,
321
+ "last_rate": 0.929,
322
+ "category": "reptile"
323
+ },
324
+ "D55": {
325
+ "last_count": 12,
326
+ "total_count": 13,
327
+ "last_rate": 0.923,
328
+ "category": "motion"
329
+ },
330
+ "I3": {
331
+ "last_count": 12,
332
+ "total_count": 19,
333
+ "last_rate": 0.632,
334
+ "category": "reptile"
335
+ },
336
+ "N4": {
337
+ "last_count": 12,
338
+ "total_count": 16,
339
+ "last_rate": 0.75,
340
+ "category": "celestial_or_geographical"
341
+ },
342
+ "O40": {
343
+ "last_count": 12,
344
+ "total_count": 12,
345
+ "last_rate": 1.0,
346
+ "category": "building_or_place"
347
+ },
348
+ "A15": {
349
+ "last_count": 11,
350
+ "total_count": 19,
351
+ "last_rate": 0.579,
352
+ "category": "man"
353
+ },
354
+ "A20": {
355
+ "last_count": 11,
356
+ "total_count": 13,
357
+ "last_rate": 0.846,
358
+ "category": "man"
359
+ },
360
+ "A55": {
361
+ "last_count": 11,
362
+ "total_count": 13,
363
+ "last_rate": 0.846,
364
+ "category": "man"
365
+ },
366
+ "D6": {
367
+ "last_count": 11,
368
+ "total_count": 16,
369
+ "last_rate": 0.688,
370
+ "category": "body_part"
371
+ },
372
+ "H5": {
373
+ "last_count": 11,
374
+ "total_count": 12,
375
+ "last_rate": 0.917,
376
+ "category": "bird_part"
377
+ },
378
+ "H8": {
379
+ "last_count": 11,
380
+ "total_count": 14,
381
+ "last_rate": 0.786,
382
+ "category": "bird_part"
383
+ },
384
+ "N34": {
385
+ "last_count": 11,
386
+ "total_count": 18,
387
+ "last_rate": 0.611,
388
+ "category": "celestial_or_geographical"
389
+ },
390
+ "R3": {
391
+ "last_count": 11,
392
+ "total_count": 12,
393
+ "last_rate": 0.917,
394
+ "category": "temple_object"
395
+ },
396
+ "A32": {
397
+ "last_count": 10,
398
+ "total_count": 11,
399
+ "last_rate": 0.909,
400
+ "category": "man"
401
+ },
402
+ "A53": {
403
+ "last_count": 10,
404
+ "total_count": 20,
405
+ "last_rate": 0.5,
406
+ "category": "man"
407
+ },
408
+ "A9": {
409
+ "last_count": 10,
410
+ "total_count": 19,
411
+ "last_rate": 0.526,
412
+ "category": "man"
413
+ },
414
+ "D7": {
415
+ "last_count": 10,
416
+ "total_count": 11,
417
+ "last_rate": 0.909,
418
+ "category": "body_part"
419
+ },
420
+ "F44": {
421
+ "last_count": 10,
422
+ "total_count": 20,
423
+ "last_rate": 0.5,
424
+ "category": "animal_part"
425
+ },
426
+ "I13": {
427
+ "last_count": 10,
428
+ "total_count": 10,
429
+ "last_rate": 1.0,
430
+ "category": "reptile"
431
+ },
432
+ "W23": {
433
+ "last_count": 10,
434
+ "total_count": 18,
435
+ "last_rate": 0.556,
436
+ "category": "vessel"
437
+ },
438
+ "X6": {
439
+ "last_count": 10,
440
+ "total_count": 19,
441
+ "last_rate": 0.526,
442
+ "category": "bread_or_food"
443
+ },
444
+ "B3": {
445
+ "last_count": 9,
446
+ "total_count": 11,
447
+ "last_rate": 0.818,
448
+ "category": "woman"
449
+ },
450
+ "C7": {
451
+ "last_count": 9,
452
+ "total_count": 10,
453
+ "last_rate": 0.9,
454
+ "category": "god"
455
+ },
456
+ "D27": {
457
+ "last_count": 9,
458
+ "total_count": 16,
459
+ "last_rate": 0.562,
460
+ "category": "body_part"
461
+ },
462
+ "M15": {
463
+ "last_count": 9,
464
+ "total_count": 18,
465
+ "last_rate": 0.5,
466
+ "category": "plant"
467
+ },
468
+ "M33": {
469
+ "last_count": 9,
470
+ "total_count": 13,
471
+ "last_rate": 0.692,
472
+ "category": "plant"
473
+ },
474
+ "W4": {
475
+ "last_count": 9,
476
+ "total_count": 12,
477
+ "last_rate": 0.75,
478
+ "category": "vessel"
479
+ },
480
+ "A4": {
481
+ "last_count": 8,
482
+ "total_count": 12,
483
+ "last_rate": 0.667,
484
+ "category": "man"
485
+ },
486
+ "F7": {
487
+ "last_count": 8,
488
+ "total_count": 11,
489
+ "last_rate": 0.727,
490
+ "category": "animal_part"
491
+ },
492
+ "M43": {
493
+ "last_count": 8,
494
+ "total_count": 14,
495
+ "last_rate": 0.571,
496
+ "category": "plant"
497
+ },
498
+ "O24": {
499
+ "last_count": 8,
500
+ "total_count": 9,
501
+ "last_rate": 0.889,
502
+ "category": "building_or_place"
503
+ },
504
+ "O32": {
505
+ "last_count": 8,
506
+ "total_count": 12,
507
+ "last_rate": 0.667,
508
+ "category": "building_or_place"
509
+ },
510
+ "Q6": {
511
+ "last_count": 8,
512
+ "total_count": 13,
513
+ "last_rate": 0.615,
514
+ "category": "furniture"
515
+ },
516
+ "V16": {
517
+ "last_count": 8,
518
+ "total_count": 13,
519
+ "last_rate": 0.615,
520
+ "category": "rope_basket"
521
+ },
522
+ "W1": {
523
+ "last_count": 8,
524
+ "total_count": 16,
525
+ "last_rate": 0.5,
526
+ "category": "vessel"
527
+ },
528
+ "A21": {
529
+ "last_count": 7,
530
+ "total_count": 14,
531
+ "last_rate": 0.5,
532
+ "category": "man"
533
+ },
534
+ "D5": {
535
+ "last_count": 7,
536
+ "total_count": 9,
537
+ "last_rate": 0.778,
538
+ "category": "body_part"
539
+ },
540
+ "E17": {
541
+ "last_count": 7,
542
+ "total_count": 9,
543
+ "last_rate": 0.778,
544
+ "category": "mammal"
545
+ },
546
+ "E3": {
547
+ "last_count": 7,
548
+ "total_count": 10,
549
+ "last_rate": 0.7,
550
+ "category": "mammal"
551
+ },
552
+ "E31": {
553
+ "last_count": 7,
554
+ "total_count": 13,
555
+ "last_rate": 0.538,
556
+ "category": "mammal"
557
+ },
558
+ "N11": {
559
+ "last_count": 7,
560
+ "total_count": 12,
561
+ "last_rate": 0.583,
562
+ "category": "celestial_or_geographical"
563
+ },
564
+ "P10": {
565
+ "last_count": 7,
566
+ "total_count": 8,
567
+ "last_rate": 0.875,
568
+ "category": "ship"
569
+ },
570
+ "Q2": {
571
+ "last_count": 7,
572
+ "total_count": 7,
573
+ "last_rate": 1.0,
574
+ "category": "furniture"
575
+ },
576
+ "T2": {
577
+ "last_count": 7,
578
+ "total_count": 8,
579
+ "last_rate": 0.875,
580
+ "category": "weapon_tool"
581
+ },
582
+ "T7": {
583
+ "last_count": 7,
584
+ "total_count": 9,
585
+ "last_rate": 0.778,
586
+ "category": "weapon_tool"
587
+ },
588
+ "A19": {
589
+ "last_count": 6,
590
+ "total_count": 10,
591
+ "last_rate": 0.6,
592
+ "category": "man"
593
+ },
594
+ "A26": {
595
+ "last_count": 6,
596
+ "total_count": 6,
597
+ "last_rate": 1.0,
598
+ "category": "man"
599
+ },
600
+ "D49": {
601
+ "last_count": 6,
602
+ "total_count": 10,
603
+ "last_rate": 0.6,
604
+ "category": "body_part"
605
+ },
606
+ "E10": {
607
+ "last_count": 6,
608
+ "total_count": 6,
609
+ "last_rate": 1.0,
610
+ "category": "mammal"
611
+ },
612
+ "E12": {
613
+ "last_count": 6,
614
+ "total_count": 6,
615
+ "last_rate": 1.0,
616
+ "category": "mammal"
617
+ },
618
+ "E22": {
619
+ "last_count": 6,
620
+ "total_count": 6,
621
+ "last_rate": 1.0,
622
+ "category": "mammal"
623
+ },
624
+ "E28": {
625
+ "last_count": 6,
626
+ "total_count": 9,
627
+ "last_rate": 0.667,
628
+ "category": "mammal"
629
+ },
630
+ "F10": {
631
+ "last_count": 6,
632
+ "total_count": 10,
633
+ "last_rate": 0.6,
634
+ "category": "animal_part"
635
+ },
636
+ "F19": {
637
+ "last_count": 6,
638
+ "total_count": 9,
639
+ "last_rate": 0.667,
640
+ "category": "animal_part"
641
+ },
642
+ "G54": {
643
+ "last_count": 6,
644
+ "total_count": 9,
645
+ "last_rate": 0.667,
646
+ "category": "bird"
647
+ },
648
+ "O27": {
649
+ "last_count": 6,
650
+ "total_count": 6,
651
+ "last_rate": 1.0,
652
+ "category": "building_or_place"
653
+ },
654
+ "S2": {
655
+ "last_count": 6,
656
+ "total_count": 8,
657
+ "last_rate": 0.75,
658
+ "category": "crown_or_dress"
659
+ },
660
+ "A51": {
661
+ "last_count": 5,
662
+ "total_count": 8,
663
+ "last_rate": 0.625,
664
+ "category": "man"
665
+ },
666
+ "B2": {
667
+ "last_count": 5,
668
+ "total_count": 6,
669
+ "last_rate": 0.833,
670
+ "category": "woman"
671
+ },
672
+ "D10": {
673
+ "last_count": 5,
674
+ "total_count": 6,
675
+ "last_rate": 0.833,
676
+ "category": "body_part"
677
+ },
678
+ "D32": {
679
+ "last_count": 5,
680
+ "total_count": 10,
681
+ "last_rate": 0.5,
682
+ "category": "body_part"
683
+ },
684
+ "D44": {
685
+ "last_count": 5,
686
+ "total_count": 6,
687
+ "last_rate": 0.833,
688
+ "category": "body_part"
689
+ },
690
+ "D57": {
691
+ "last_count": 5,
692
+ "total_count": 6,
693
+ "last_rate": 0.833,
694
+ "category": "body_part"
695
+ },
696
+ "D9": {
697
+ "last_count": 5,
698
+ "total_count": 5,
699
+ "last_rate": 1.0,
700
+ "category": "body_part"
701
+ },
702
+ "E32": {
703
+ "last_count": 5,
704
+ "total_count": 6,
705
+ "last_rate": 0.833,
706
+ "category": "mammal"
707
+ },
708
+ "F9": {
709
+ "last_count": 5,
710
+ "total_count": 9,
711
+ "last_rate": 0.556,
712
+ "category": "animal_part"
713
+ },
714
+ "O18": {
715
+ "last_count": 5,
716
+ "total_count": 5,
717
+ "last_rate": 1.0,
718
+ "category": "building_or_place"
719
+ },
720
+ "R1": {
721
+ "last_count": 5,
722
+ "total_count": 5,
723
+ "last_rate": 1.0,
724
+ "category": "temple_object"
725
+ },
726
+ "S36": {
727
+ "last_count": 5,
728
+ "total_count": 7,
729
+ "last_rate": 0.714,
730
+ "category": "crown_or_dress"
731
+ },
732
+ "S4": {
733
+ "last_count": 5,
734
+ "total_count": 6,
735
+ "last_rate": 0.833,
736
+ "category": "crown_or_dress"
737
+ },
738
+ "X3": {
739
+ "last_count": 5,
740
+ "total_count": 5,
741
+ "last_rate": 1.0,
742
+ "category": "bread_or_food"
743
+ },
744
+ "B5": {
745
+ "last_count": 4,
746
+ "total_count": 4,
747
+ "last_rate": 1.0,
748
+ "category": "woman"
749
+ },
750
+ "E14": {
751
+ "last_count": 4,
752
+ "total_count": 5,
753
+ "last_rate": 0.8,
754
+ "category": "mammal"
755
+ },
756
+ "E25": {
757
+ "last_count": 4,
758
+ "total_count": 4,
759
+ "last_rate": 1.0,
760
+ "category": "mammal"
761
+ },
762
+ "F1": {
763
+ "last_count": 4,
764
+ "total_count": 4,
765
+ "last_rate": 1.0,
766
+ "category": "animal_part"
767
+ },
768
+ "G48": {
769
+ "last_count": 4,
770
+ "total_count": 4,
771
+ "last_rate": 1.0,
772
+ "category": "bird"
773
+ },
774
+ "N15": {
775
+ "last_count": 4,
776
+ "total_count": 5,
777
+ "last_rate": 0.8,
778
+ "category": "celestial_or_geographical"
779
+ },
780
+ "O20": {
781
+ "last_count": 4,
782
+ "total_count": 4,
783
+ "last_rate": 1.0,
784
+ "category": "building_or_place"
785
+ },
786
+ "O21": {
787
+ "last_count": 4,
788
+ "total_count": 4,
789
+ "last_rate": 1.0,
790
+ "category": "building_or_place"
791
+ },
792
+ "O26": {
793
+ "last_count": 4,
794
+ "total_count": 4,
795
+ "last_rate": 1.0,
796
+ "category": "building_or_place"
797
+ },
798
+ "S11": {
799
+ "last_count": 4,
800
+ "total_count": 5,
801
+ "last_rate": 0.8,
802
+ "category": "crown_or_dress"
803
+ },
804
+ "S21": {
805
+ "last_count": 4,
806
+ "total_count": 4,
807
+ "last_rate": 1.0,
808
+ "category": "crown_or_dress"
809
+ },
810
+ "S35": {
811
+ "last_count": 4,
812
+ "total_count": 5,
813
+ "last_rate": 0.8,
814
+ "category": "crown_or_dress"
815
+ },
816
+ "S6": {
817
+ "last_count": 4,
818
+ "total_count": 4,
819
+ "last_rate": 1.0,
820
+ "category": "crown_or_dress"
821
+ },
822
+ "A27": {
823
+ "last_count": 3,
824
+ "total_count": 3,
825
+ "last_rate": 1.0,
826
+ "category": "man"
827
+ },
828
+ "A54": {
829
+ "last_count": 3,
830
+ "total_count": 3,
831
+ "last_rate": 1.0,
832
+ "category": "man"
833
+ },
834
+ "D8": {
835
+ "last_count": 3,
836
+ "total_count": 4,
837
+ "last_rate": 0.75,
838
+ "category": "body_part"
839
+ },
840
+ "E15": {
841
+ "last_count": 3,
842
+ "total_count": 4,
843
+ "last_rate": 0.75,
844
+ "category": "mammal"
845
+ },
846
+ "E24": {
847
+ "last_count": 3,
848
+ "total_count": 3,
849
+ "last_rate": 1.0,
850
+ "category": "mammal"
851
+ },
852
+ "E30": {
853
+ "last_count": 3,
854
+ "total_count": 4,
855
+ "last_rate": 0.75,
856
+ "category": "mammal"
857
+ },
858
+ "E6": {
859
+ "last_count": 3,
860
+ "total_count": 3,
861
+ "last_rate": 1.0,
862
+ "category": "mammal"
863
+ },
864
+ "E7": {
865
+ "last_count": 3,
866
+ "total_count": 3,
867
+ "last_rate": 1.0,
868
+ "category": "mammal"
869
+ },
870
+ "G42": {
871
+ "last_count": 3,
872
+ "total_count": 4,
873
+ "last_rate": 0.75,
874
+ "category": "bird"
875
+ },
876
+ "G6": {
877
+ "last_count": 3,
878
+ "total_count": 4,
879
+ "last_rate": 0.75,
880
+ "category": "bird"
881
+ },
882
+ "G8": {
883
+ "last_count": 3,
884
+ "total_count": 3,
885
+ "last_rate": 1.0,
886
+ "category": "bird"
887
+ },
888
+ "H1": {
889
+ "last_count": 3,
890
+ "total_count": 3,
891
+ "last_rate": 1.0,
892
+ "category": "bird_part"
893
+ },
894
+ "M37": {
895
+ "last_count": 3,
896
+ "total_count": 4,
897
+ "last_rate": 0.75,
898
+ "category": "plant"
899
+ },
900
+ "M41": {
901
+ "last_count": 3,
902
+ "total_count": 3,
903
+ "last_rate": 1.0,
904
+ "category": "plant"
905
+ },
906
+ "S1": {
907
+ "last_count": 3,
908
+ "total_count": 3,
909
+ "last_rate": 1.0,
910
+ "category": "crown_or_dress"
911
+ },
912
+ "S26": {
913
+ "last_count": 3,
914
+ "total_count": 3,
915
+ "last_rate": 1.0,
916
+ "category": "crown_or_dress"
917
+ },
918
+ "S37": {
919
+ "last_count": 3,
920
+ "total_count": 3,
921
+ "last_rate": 1.0,
922
+ "category": "crown_or_dress"
923
+ },
924
+ "S7": {
925
+ "last_count": 3,
926
+ "total_count": 3,
927
+ "last_rate": 1.0,
928
+ "category": "crown_or_dress"
929
+ },
930
+ "T17": {
931
+ "last_count": 3,
932
+ "total_count": 4,
933
+ "last_rate": 0.75,
934
+ "category": "weapon_tool"
935
+ },
936
+ "V10": {
937
+ "last_count": 3,
938
+ "total_count": 3,
939
+ "last_rate": 1.0,
940
+ "category": "rope_basket"
941
+ },
942
+ "V9": {
943
+ "last_count": 3,
944
+ "total_count": 3,
945
+ "last_rate": 1.0,
946
+ "category": "rope_basket"
947
+ },
948
+ "A29": {
949
+ "last_count": 2,
950
+ "total_count": 2,
951
+ "last_rate": 1.0,
952
+ "category": "man"
953
+ },
954
+ "A52": {
955
+ "last_count": 2,
956
+ "total_count": 2,
957
+ "last_rate": 1.0,
958
+ "category": "noble"
959
+ },
960
+ "C10": {
961
+ "last_count": 2,
962
+ "total_count": 2,
963
+ "last_rate": 1.0,
964
+ "category": "god"
965
+ },
966
+ "C9": {
967
+ "last_count": 2,
968
+ "total_count": 2,
969
+ "last_rate": 1.0,
970
+ "category": "god"
971
+ },
972
+ "E2": {
973
+ "last_count": 2,
974
+ "total_count": 2,
975
+ "last_rate": 1.0,
976
+ "category": "mammal"
977
+ },
978
+ "E26": {
979
+ "last_count": 2,
980
+ "total_count": 2,
981
+ "last_rate": 1.0,
982
+ "category": "mammal"
983
+ },
984
+ "G13": {
985
+ "last_count": 2,
986
+ "total_count": 2,
987
+ "last_rate": 1.0,
988
+ "category": "bird"
989
+ },
990
+ "G16": {
991
+ "last_count": 2,
992
+ "total_count": 2,
993
+ "last_rate": 1.0,
994
+ "category": "bird"
995
+ },
996
+ "G31": {
997
+ "last_count": 2,
998
+ "total_count": 2,
999
+ "last_rate": 1.0,
1000
+ "category": "bird"
1001
+ },
1002
+ "G34": {
1003
+ "last_count": 2,
1004
+ "total_count": 2,
1005
+ "last_rate": 1.0,
1006
+ "category": "bird"
1007
+ },
1008
+ "I2": {
1009
+ "last_count": 2,
1010
+ "total_count": 2,
1011
+ "last_rate": 1.0,
1012
+ "category": "reptile"
1013
+ },
1014
+ "L3": {
1015
+ "last_count": 2,
1016
+ "total_count": 2,
1017
+ "last_rate": 1.0,
1018
+ "category": "insect"
1019
+ },
1020
+ "L4": {
1021
+ "last_count": 2,
1022
+ "total_count": 2,
1023
+ "last_rate": 1.0,
1024
+ "category": "insect"
1025
+ },
1026
+ "N22": {
1027
+ "last_count": 2,
1028
+ "total_count": 2,
1029
+ "last_rate": 1.0,
1030
+ "category": "celestial_or_geographical"
1031
+ },
1032
+ "O25": {
1033
+ "last_count": 2,
1034
+ "total_count": 2,
1035
+ "last_rate": 1.0,
1036
+ "category": "building_or_place"
1037
+ },
1038
+ "R16": {
1039
+ "last_count": 2,
1040
+ "total_count": 2,
1041
+ "last_rate": 1.0,
1042
+ "category": "temple_object"
1043
+ },
1044
+ "S18": {
1045
+ "last_count": 2,
1046
+ "total_count": 2,
1047
+ "last_rate": 1.0,
1048
+ "category": "crown_or_dress"
1049
+ },
1050
+ "S27": {
1051
+ "last_count": 2,
1052
+ "total_count": 2,
1053
+ "last_rate": 1.0,
1054
+ "category": "crown_or_dress"
1055
+ },
1056
+ "S45": {
1057
+ "last_count": 2,
1058
+ "total_count": 2,
1059
+ "last_rate": 1.0,
1060
+ "category": "crown_or_dress"
1061
+ },
1062
+ "U38": {
1063
+ "last_count": 2,
1064
+ "total_count": 2,
1065
+ "last_rate": 1.0,
1066
+ "category": "tool_craft"
1067
+ },
1068
+ "W21": {
1069
+ "last_count": 2,
1070
+ "total_count": 2,
1071
+ "last_rate": 1.0,
1072
+ "category": "vessel"
1073
+ }
1074
+ }
1075
+ }
src/enhance_img.py ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+
3
+ # pyrefly: ignore [missing-import]
4
+ import cv2
5
+ # pyrefly: ignore [missing-import]
6
+ import numpy as np
7
+ import argparse
8
+ from pathlib import Path
9
+
10
+ # Settings for the pipeline
11
+
12
+ PRESETS = {
13
+ "default": {
14
+ "clahe_clip": 2.0,
15
+ "clahe_grid": 8,
16
+ "denoise_h": 6,
17
+ "denoise_method": "nlm", # "gaussian" | "nlm"
18
+ "unsharp_amount": 0.6,
19
+ "unsharp_radius": 1.5,
20
+ "gamma": 1.05,
21
+ },
22
+ "aggressive": {
23
+ "clahe_clip": 3.5,
24
+ "clahe_grid": 8,
25
+ "denoise_h": 10,
26
+ "denoise_method": "nlm",
27
+ "unsharp_amount": 1.0,
28
+ "unsharp_radius": 2.0,
29
+ "gamma": 0.90,
30
+ },
31
+ "gentle": {
32
+ "clahe_clip": 1.5,
33
+ "clahe_grid": 16,
34
+ "denoise_h": 3,
35
+ "denoise_method": "nlm",
36
+ "unsharp_amount": 0.3,
37
+ "unsharp_radius": 1.0,
38
+ "gamma": 1.0,
39
+ },
40
+ "fast": {
41
+ "clahe_clip": 2.0,
42
+ "clahe_grid": 8,
43
+ "denoise_h": 15,
44
+ "denoise_method": "bilateral",
45
+ "unsharp_amount": 0.6,
46
+ "unsharp_radius": 1.5,
47
+ "gamma": 1.05,
48
+ }
49
+ }
50
+
51
+
52
+ # Pipeline steps
53
+ # Constrast Adaptive Histogram Equalization (CLAHE) on L channel of LAB space
54
+ def apply_clahe(img: np.ndarray,
55
+ clip: float = 2.0,
56
+ grid: int = 8) -> np.ndarray:
57
+ """
58
+ CLAHE on L channel of LAB space.
59
+ """
60
+ # My YOLO model was trained on BGR images, so convert to LAB space ( Rock Color from Ancient Temples )
61
+ lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
62
+ l, a, b = cv2.split(lab)
63
+ # Convert to LAB, apply CLAHE on L channel, then convert back to BGR
64
+ clahe = cv2.createCLAHE(clipLimit=clip,
65
+ tileGridSize=(grid, grid))
66
+ l_clahe = clahe.apply(l)
67
+ merged = cv2.merge([l_clahe, a, b])
68
+
69
+ return cv2.cvtColor(merged, cv2.COLOR_LAB2BGR)
70
+
71
+
72
+ def apply_denoising(img: np.ndarray,
73
+ h: float = 6,
74
+ method: str = "nlm" # gaussian | nlm
75
+ ) -> np.ndarray:
76
+ """
77
+ Non-local means denoising — keep borders better than GaussianBlur.
78
+ h: strength of the filter. >10 erases fine details of the sign.
79
+ """
80
+ if h <= 0:
81
+ return img
82
+
83
+ if method == "nlm":
84
+ # Non-local means denoising — keep borders better than GaussianBlur.
85
+ return cv2.fastNlMeansDenoisingColored(
86
+ img,
87
+ None,
88
+ h=h,
89
+ hColor=h,
90
+ templateWindowSize=7, # search window size for similar patches px
91
+ searchWindowSize=21
92
+ )
93
+
94
+
95
+ elif method == "gaussian":
96
+ # Gaussian denoising — keep borders better than bilateral filter.
97
+ return cv2.fastNlMeansDenoisingColored(
98
+ img,
99
+ None,
100
+ h=h,
101
+ hColor=h,
102
+ templateWindowSize=7,
103
+ searchWindowSize=21,
104
+ sigmaColor=0,
105
+ sigmaSpace=0
106
+ )
107
+
108
+ elif method == "bilateral":
109
+ # Bilateral denoising — keep borders better than GaussianBlur.
110
+ return cv2.bilateralFilter(img, d=9, sigmaColor=h, sigmaSpace=h)
111
+
112
+ else:
113
+ raise ValueError(f"Invalid denoising method: {method}")
114
+
115
+
116
+ def apply_unsharp_mask(img: np.ndarray, # input image
117
+ amount: float = 0.6, # 0.0 = no effect, 1.5 = very aggressive
118
+ radius: float = 1.5 # use a larger radius for more aggressive effect
119
+ ) -> np.ndarray:
120
+ """
121
+ Unsharp mask — highlights the edges of the carving in stone.
122
+ amount: 0.0 = no effect, 1.5 = very aggressive.
123
+ Equation: sharpened = original + amount * (original - blurred)
124
+ """
125
+ if amount <= 0:
126
+ return img
127
+
128
+ blurred = cv2.GaussianBlur(img, (0, 0), radius)
129
+ sharpened = cv2.addWeighted(img, 1 + amount, blurred, -amount, 0)
130
+
131
+ return sharpened
132
+
133
+
134
+ def apply_gamma(img: np.ndarray, gamma: float = 1.05) -> np.ndarray:
135
+ """
136
+ Gamma correction by lookup table — fast and without artifacts.
137
+ gamma < 1.0 → brightens (useful for dark photos of tombs)
138
+ gamma > 1.0 → darkens slightly (increases visual contrast)
139
+ gamma = 1.0 → no change
140
+ """
141
+ if gamma == 1.0:
142
+ return img
143
+
144
+ inv_gamma = 1.0 / gamma
145
+
146
+ table = np.array([
147
+ ((i / 255.0) ** inv_gamma) * 255
148
+ for i in range(256)
149
+ ], dtype=np.uint8)
150
+
151
+ return cv2.LUT(img, table)
152
+
153
+
154
+ # Main pipeline
155
+
156
+ def enhance(img: np.ndarray,
157
+ preset: str = "default",
158
+ custom: dict | None = None) -> np.ndarray:
159
+ """
160
+ Complete image enhancement pipeline.
161
+
162
+ Args:
163
+ img: imagen BGR (numpy array) — output de cv2.imread()
164
+ preset: 'default' | 'aggressive' | 'gentle' | 'fast'
165
+ custom: dict with custom parameters (overrides preset)
166
+
167
+ Returns:
168
+ enhanced BGR image (same size as input)
169
+ """
170
+ if preset not in PRESETS:
171
+ raise ValueError(
172
+ f"Unknown preset: {preset!r}. "
173
+ f"Choose from {sorted(PRESETS.keys())}."
174
+ )
175
+
176
+ cfg = PRESETS.get(preset, PRESETS["default"]).copy()
177
+
178
+ if custom:
179
+ cfg.update(custom)
180
+
181
+ # Step 1 — CLAHE
182
+ out = apply_clahe(img,
183
+ clip=cfg["clahe_clip"],
184
+ grid=cfg["clahe_grid"])
185
+
186
+ # Step 2 — Denoising
187
+ out = apply_denoising(out,
188
+ h=cfg["denoise_h"],
189
+ method=cfg["denoise_method"])
190
+
191
+ # Step 3 — Unsharp mask
192
+ out = apply_unsharp_mask(out,
193
+ amount=cfg["unsharp_amount"],
194
+ radius=cfg["unsharp_radius"])
195
+
196
+ # Step 4 — Gamma
197
+ out = apply_gamma(out, gamma=cfg["gamma"])
198
+
199
+ return out
200
+
201
+
202
+ def compare_side_by_side(original: np.ndarray,
203
+ enhanced: np.ndarray,
204
+ label: str = "") -> np.ndarray:
205
+ """Generate side-by-side comparison image original | enhanced for inspection."""
206
+ h = max(original.shape[0], enhanced.shape[0])
207
+
208
+ def pad_h(img, target_h):
209
+ ph = target_h - img.shape[0]
210
+ if ph > 0:
211
+ return np.vstack([img, np.zeros((ph, img.shape[1], 3),
212
+ dtype=np.uint8)])
213
+ return img
214
+
215
+ orig_pad = pad_h(original, h)
216
+ enh_pad = pad_h(enhanced, h)
217
+
218
+ divider = np.full((h, 3, 3), 100, dtype=np.uint8)
219
+ combined = np.hstack([orig_pad, divider, enh_pad])
220
+
221
+ # Labels
222
+ cv2.putText(combined, "ORIGINAL", (10, 22),
223
+ cv2.FONT_HERSHEY_SIMPLEX, 0.6, (200, 200, 200), 1)
224
+ cv2.putText(combined, f"ENHANCED ({label})",
225
+ (orig_pad.shape[1] + 13, 22),
226
+ cv2.FONT_HERSHEY_SIMPLEX, 0.6, (100, 220, 100), 1)
227
+ return combined
228
+
229
+ # This script file will turn out to be app/utils/enhance_img.py
230
+ # when this bakcend app is built in FastAPI
231
+ # for now it is a standalone script to test the enhancement pipeline
232
+ # It will become the dritical step 0 . after user upload an image from frontend
233
+ # and before the image is sent to the model for inference
234
+
235
+ # Entry point
236
+
237
+ def main():
238
+ parser = argparse.ArgumentParser(
239
+ description="SphinxEyes — Image preprocessor for inference"
240
+ )
241
+ parser.add_argument("input", help="Input image")
242
+ parser.add_argument("--output", type=str, default=None,
243
+ help="Output path (default: <name>_enhanced.jpg)")
244
+ parser.add_argument("--preset", type=str, default="default",
245
+ choices=["default", "aggressive", "gentle", "fast"],
246
+ help="Preset de mejora (default: default)")
247
+ parser.add_argument("--show", action="store_true",
248
+ help="Show original vs enhanced comparison")
249
+ parser.add_argument("--compare-all", action="store_true",
250
+ help="Show all presets side by side")
251
+ args = parser.parse_args()
252
+
253
+ img = cv2.imread(args.input)
254
+ if img is None:
255
+ print(f"ERROR: Could not open '{args.input}'")
256
+ return
257
+
258
+ if args.compare_all:
259
+ # Compare all 3 presets
260
+ results = []
261
+ for preset_name in ["gentle", "default", "aggressive", "fast"]:
262
+ enh = enhance(img, preset=preset_name)
263
+ results.append((preset_name, enh))
264
+
265
+ # Build comparison panel
266
+ h = img.shape[0]
267
+ div = np.full((h, 3, 3), 80, dtype=np.uint8)
268
+ row = img.copy()
269
+ cv2.putText(row, "ORIGINAL", (8, 20),
270
+ cv2.FONT_HERSHEY_SIMPLEX, 0.55, (200,200,200), 1)
271
+
272
+ for name, enh in results:
273
+ cv2.putText(enh, name.upper(), (8, 20),
274
+ cv2.FONT_HERSHEY_SIMPLEX, 0.55, (100,220,100), 1)
275
+ row = np.hstack([row, div, enh])
276
+
277
+ cv2.imshow("SphinxEyes — Compare all presets (Q to quit)", row)
278
+ cv2.waitKey(0)
279
+ cv2.destroyAllWindows()
280
+ return
281
+
282
+ # Main pipeline
283
+ enhanced = enhance(img, preset=args.preset)
284
+
285
+ # Save
286
+ if args.output:
287
+ out_path = args.output
288
+ else:
289
+ p = Path(args.input)
290
+ out_path = str(p.with_stem(p.stem + '_enhanced').with_suffix('.jpg'))
291
+
292
+ cv2.imwrite(out_path, enhanced, [cv2.IMWRITE_JPEG_QUALITY, 95])
293
+ print(f" ✓ Saved: {out_path} (preset: {args.preset})")
294
+
295
+ if args.show:
296
+ comp = compare_side_by_side(img, enhanced, label=args.preset)
297
+ cv2.imshow("Original vs Enhanced (Q to quit)", comp)
298
+ cv2.waitKey(0)
299
+ cv2.destroyAllWindows()
300
+
301
+
302
+ if __name__ == "__main__":
303
+ main()
src/infer_torch.py ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ infer_torch.py — ZeroGPU detection backend for the HF Space (v10 .pt).
4
+
5
+ Why a raw forward instead of ultralytics' predict():
6
+ spatial_logic.postprocess_onnx does conf-filter -> class-agnostic NMS ->
7
+ **top-3** extraction, and those top-3 slots are what sphinx_corrector's
8
+ Viterbi consumes. model.predict() returns top-1 only, after its own NMS,
9
+ which would gut the entire NLP correction layer. DetectionModel's raw
10
+ forward returns the same [1, 4+nc, N] tensor the ONNX export (nms=False)
11
+ produces — pixel cxcywh in rows 0-3, independent sigmoid class scores in
12
+ rows 4.. — so postprocess_onnx is reused UNCHANGED.
13
+
14
+ Verified against artifacts/best_modelv10.pt: ultralytics 8.4.102, yolo11l,
15
+ imgsz 1024, nc=150, class order identical to class_map50_v9.json (0
16
+ mismatches, transmutations m4/f34/o29 still at idx 30/61/70). So the tensor
17
+ is [1, 154, 21504], exactly as v9.
18
+
19
+ ZeroGPU rules honoured here:
20
+ * `import spaces` before torch.
21
+ * The model is built on CPU at module scope and only moved to CUDA INSIDE
22
+ the @spaces.GPU function — ZeroGPU patches CUDA init, so a module-scope
23
+ .to('cuda') fails.
24
+ * postprocess_onnx runs OUTSIDE the GPU function: quota is duration-based,
25
+ so we hold the GPU only for the forward pass, and we avoid pickling
26
+ Detection dataclasses back across the fork boundary.
27
+ """
28
+
29
+ from __future__ import annotations
30
+
31
+ import os
32
+ from pathlib import Path
33
+ from typing import Callable
34
+
35
+ import numpy as np
36
+
37
+ import spaces # must precede torch (ZeroGPU)
38
+ import torch
39
+ from ultralytics import YOLO
40
+
41
+ import spatial_logic as SL
42
+
43
+ ROOT = Path(__file__).parent
44
+ WEIGHTS = Path(os.getenv('SPHINX_WEIGHTS',
45
+ ROOT / 'artifacts' / 'best_modelv10.pt'))
46
+ GPU_SECONDS = int(os.getenv('SPHINX_GPU_SECONDS', '60'))
47
+
48
+ # Built once, on CPU.
49
+ # .eval() — the detect head only emits the concatenated inference tensor in
50
+ # eval mode; training mode returns the per-stride feature maps.
51
+ # .float() — best_modelv10.pt stores a MIX of HalfStorage and FloatStorage
52
+ # tensors (verified by inspecting the checkpoint), so feeding a
53
+ # float32 input would raise "expected scalar type Half but found
54
+ # Float". Upcasting everything to fp32 removes the dtype mismatch
55
+ # and keeps this backend numerically comparable to the fp32 ONNX
56
+ # path the pipeline was validated against.
57
+ _model = YOLO(str(WEIGHTS)).model.float().eval()
58
+ for _p in _model.parameters():
59
+ _p.requires_grad_(False)
60
+
61
+
62
+ def _canvas_to_tensor(canvas: np.ndarray) -> torch.Tensor:
63
+ """BGR uint8 HWC -> RGB float32 NCHW in [0,1] (matches make_onnx_infer_fn)."""
64
+ x = canvas[:, :, ::-1].astype(np.float32) / 255.0 # BGR -> RGB
65
+ x = np.ascontiguousarray(x.transpose(2, 0, 1))[None] # HWC -> NCHW
66
+ return torch.from_numpy(x)
67
+
68
+
69
+ @spaces.GPU(duration=GPU_SECONDS)
70
+ def _forward(canvas: np.ndarray) -> np.ndarray:
71
+ """Raw forward on the letterboxed canvas. Returns [1, 4+nc, N] as numpy."""
72
+ dev = 'cuda' if torch.cuda.is_available() else 'cpu'
73
+ model = _model.to(dev)
74
+ x = _canvas_to_tensor(canvas).to(dev)
75
+ with torch.inference_mode():
76
+ out = model(x)
77
+ # DetectionModel in eval mode returns either the tensor or a
78
+ # (tensor, feature_maps) tuple depending on version — normalise.
79
+ if isinstance(out, (list, tuple)):
80
+ out = out[0]
81
+ return out.float().cpu().numpy()
82
+
83
+
84
+ def make_torch_infer_fn(
85
+ class_names : list[str],
86
+ conf_thresh : float = SL.CONF_THRESHOLD,
87
+ iou_thresh : float = SL.NMS_IOU,
88
+ imgsz : int = 1024,
89
+ ) -> Callable[[np.ndarray], list]:
90
+ """
91
+ Drop-in replacement for SL.make_onnx_infer_fn — same signature, same
92
+ Callable[[bgr], list[Detection]] contract, bboxes in original-image pixels.
93
+
94
+ Letterbox (never stretch): fragile breakpoint #9. Reuses SL.letterbox so
95
+ preprocessing is provably identical to the ONNX path.
96
+ """
97
+ def infer(bgr: np.ndarray) -> list:
98
+ canvas, scale, dx, dy = SL.letterbox(bgr, imgsz)
99
+ raw = _forward(canvas)
100
+ dets = SL.postprocess_onnx(raw, class_names, conf_thresh, iou_thresh)
101
+ # undo letterbox: original = (model - d) / scale
102
+ for d in dets:
103
+ x1, y1, x2, y2 = d.bbox
104
+ d.bbox = ((x1 - dx) / scale, (y1 - dy) / scale,
105
+ (x2 - dx) / scale, (y2 - dy) / scale)
106
+ return dets
107
+
108
+ return infer
src/initial_particles.json ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "source": "starter list — Middle Egyptian phrase-initial particles. Verify against Allen 14th ed. or Gardiner Egyptian Grammar §239 ff.",
3
+ "purpose": "Soft phrase-start prior in the SphinxTrie segmenter. When YOLO output contains one of these Gardiner sequences, the slot at its first sign is a strong candidate for a phrase boundary (the previous slot is end-of-previous-phrase).",
4
+ "particles": {
5
+ "jw": {
6
+ "gardiner": ["M17", "G43"],
7
+ "meaning": "is / circumstantial auxiliary",
8
+ "register": "narrative",
9
+ "notes": "Most common Middle Egyptian phrase-opener. Sometimes written M17 alone in late ME."
10
+ },
11
+ "jn": {
12
+ "gardiner": ["M17", "N35"],
13
+ "meaning": "by (agent marker) / interrogative",
14
+ "register": "all",
15
+ "notes": "Also marks rhetorical questions when phrase-initial."
16
+ },
17
+ "mk": {
18
+ "gardiner": ["Aa15", "V31"],
19
+ "meaning": "behold (sg.)!",
20
+ "register": "speech",
21
+ "alt_spellings": [["G17", "V31"]],
22
+ "notes": "Vocative-like attention marker. G17 V31 variant in some hands."
23
+ },
24
+ "mTn": {
25
+ "gardiner": ["Aa15", "V13", "N35"],
26
+ "meaning": "behold (pl.)!",
27
+ "register": "speech",
28
+ "alt_spellings": [["G17", "V13", "N35"]],
29
+ "notes": "Plural counterpart of mk. G17 variant common."
30
+ },
31
+ "jx": {
32
+ "gardiner": ["M17", "Aa1"],
33
+ "meaning": "may, then, so that (optative/sequential)",
34
+ "register": "all"
35
+ },
36
+ "nn": {
37
+ "gardiner": ["N35", "N35"],
38
+ "meaning": "not / there is not (negation)",
39
+ "register": "all",
40
+ "alt_spellings": [["M22"]],
41
+ "notes": "Phrase-initial negation. Single M22 (junction-of-river plant) sometimes used as logogram."
42
+ },
43
+ "HA": {
44
+ "gardiner": ["O4", "G1"],
45
+ "meaning": "would that! (wish particle)",
46
+ "register": "speech",
47
+ "alt_spellings": [["O4"]],
48
+ "notes": "Some scribes drop the alef G1."
49
+ },
50
+ "wnt": {
51
+ "gardiner": ["E34", "N35", "X1"],
52
+ "meaning": "indeed / that (subordinator)",
53
+ "register": "all"
54
+ },
55
+ "jstw": {
56
+ "gardiner": ["M17", "S29", "X1", "G43"],
57
+ "meaning": "now (parenthetical)",
58
+ "register": "narrative"
59
+ },
60
+ "Hr_ntt": {
61
+ "gardiner": ["D2", "D21", "X1", "X1"],
62
+ "meaning": "because / since (subordinator)",
63
+ "register": "all",
64
+ "notes": "Often phrase-initial in subordinate clauses introducing causes."
65
+ },
66
+ "smwn": {
67
+ "gardiner": ["S29", "Aa15", "G43", "N35"],
68
+ "meaning": "perhaps",
69
+ "register": "speech"
70
+ },
71
+ "wnn": {
72
+ "gardiner": ["E34", "N35", "N35"],
73
+ "meaning": "exists / continuative auxiliary",
74
+ "register": "all",
75
+ "notes": "Often phrase-initial when introducing existential clauses."
76
+ }
77
+ },
78
+ "notes": [
79
+ "These are typical Middle Egyptian phrase-initial particles. Coverage is intentionally narrow — these are the strongest signals; rarer particles can be added later.",
80
+ "The segmenter should treat these as soft priors: when the YOLO sequence contains a particle's full Gardiner sequence at a position, score a phrase boundary just before it.",
81
+ "Some particles (jw, jn, mk, jx) are short (2 codes) and overlap phonetically with non-particle words. Use the boundary signal cumulatively, not deterministically."
82
+ ]
83
+ }
src/layout_detector.py ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ import numpy as np
8
+
9
+ if TYPE_CHECKING:
10
+ from spatial_logic import Detection
11
+
12
+
13
+ CARTOUCHE_CLASS = 'cartouche'
14
+ EDGE_FRAC = 0.02 # touching this fraction of the image border -> drop
15
+ # the cartouche from the aspect vote (clipped)
16
+ MIN_SIGNAL_GAP = 0.10 # column-vs-row vote margin below which we tie
17
+
18
+
19
+ def _cluster_1d_bands(values: np.ndarray, bandwidth: float) -> int:
20
+ """1-D running-mean clustering. Returns the number of clusters.
21
+
22
+ Mirrors spatial_logic._group_lines so the band count matches what
23
+ the reading-order assembler would see.
24
+ """
25
+ if len(values) == 0:
26
+ return 0
27
+
28
+ v = np.sort(values)
29
+ bands = [[v[0]]]
30
+
31
+ for x in v[1:]:
32
+
33
+ mean_b = float(np.mean(bands[-1]))
34
+
35
+ if x - mean_b > bandwidth:
36
+
37
+ bands.append([x])
38
+
39
+ else:
40
+ bands[-1].append(x)
41
+
42
+ return len(bands)
43
+
44
+
45
+ def _vote_cartouche_aspect(
46
+ detections : list[Detection],
47
+ img_w: float,
48
+ img_h: float,
49
+ ) -> tuple[str | None, float]:
50
+ """Tall cartouches -> columns; wide -> rows.
51
+ Cartouches whose bbox touches the image border are dropped (clipped)."""
52
+ edge_x = EDGE_FRAC * img_w
53
+ edge_y = EDGE_FRAC * img_h
54
+ tall = wide = 0
55
+ for d in detections:
56
+
57
+ if not getattr(d, 'is_cartouche', lambda: False)():
58
+ continue
59
+
60
+ x1, y1, x2, y2 = d.bbox
61
+
62
+ if x1 <= edge_x or y1 <= edge_y or x2 >= img_w - edge_x or y2 >= img_h - edge_y:
63
+ continue
64
+
65
+ w, h = x2 - x1, y2 - y1
66
+
67
+ if h > 1.2 * w:
68
+
69
+ tall += 1
70
+
71
+ elif w > 1.2 * h:
72
+
73
+ wide += 1
74
+
75
+ total = tall + wide
76
+
77
+ if total == 0:
78
+
79
+ return None, 0.0
80
+
81
+ if tall > wide:
82
+ # tie -> historical default
83
+ return 'columns', tall / total
84
+
85
+ if wide > tall:
86
+ # tie -> historical default
87
+ return 'rows', wide / total
88
+
89
+ return None, 0.0
90
+
91
+
92
+ def _vote_band_count(
93
+ detections : list[Detection],
94
+ img_w: float,
95
+ img_h: float,
96
+ ) -> tuple[str | None, float]:
97
+ """Cluster non-cartouche centroids on x and on y; reading axis is
98
+ the one with MORE bands (signs stacked along it)."""
99
+ sign_dets = [d for d in detections
100
+ if not getattr(d, 'is_cartouche', lambda: False)()]
101
+
102
+ if len(sign_dets) < 4:
103
+
104
+ return None, 0.0
105
+
106
+ cx = np.array([d.centroid[0] for d in sign_dets])
107
+ cy = np.array([d.centroid[1] for d in sign_dets])
108
+
109
+ med_w = float(np.median([d.width for d in sign_dets]))
110
+ med_h = float(np.median([d.height for d in sign_dets]))
111
+ # bands_x : n_x: how many distinct vertical bands of signs (potential columns)
112
+ # bands_y : n_y: how many distinct horizontal bands of signs (potential rows)
113
+ n_x = _cluster_1d_bands(cx, 0.6 * med_w) # columns count
114
+ n_y = _cluster_1d_bands(cy, 0.6 * med_h) # rows count
115
+
116
+ if n_x == 0 or n_y == 0:
117
+ return None, 0.0
118
+
119
+ ratio = abs(n_y - n_x) / max(n_x, n_y)
120
+
121
+ if n_y > n_x: # more rows than columns -> text in columns
122
+
123
+ return 'columns', ratio
124
+
125
+ if n_x > n_y:
126
+
127
+ return 'rows', ratio
128
+
129
+ return None, 0.0
130
+
131
+
132
+ def _vote_sign_aspect(
133
+ detections : list[Detection],
134
+ img_w: float,
135
+ img_h: float
136
+ ) -> tuple[str | None, float]:
137
+ """Median sign aspect ratio. Mild tiebreaker."""
138
+ aspects = []
139
+
140
+ for d in detections:
141
+
142
+ if getattr(d, 'is_cartouche', lambda: False)():
143
+ continue
144
+
145
+ if d.width <= 0 or d.height <= 0:
146
+ continue
147
+
148
+ aspects.append(d.height / d.width)
149
+
150
+ if not aspects:
151
+
152
+ return None, 0.0
153
+
154
+ med = float(np.median(aspects))
155
+
156
+ if med >= 1.15:
157
+
158
+ return 'columns', min(0.3, (med - 1.0))
159
+
160
+ if med <= 0.85:
161
+
162
+ return 'rows', min(0.3, (1.0 - med))
163
+
164
+ return None, 0.0
165
+
166
+
167
+ def detect_layout_from_detections(
168
+ detections : list[Detection],
169
+ img_w: float,
170
+ img_h: float, *,
171
+ verbose: bool = False,
172
+ ) -> str:
173
+ """
174
+ Vote across three geometric signals and return 'rows' or 'columns'.
175
+ Fragile-breakpoint fallback: 'rows' on no evidence (historical default).
176
+ """
177
+ if not detections:
178
+
179
+ if verbose:
180
+
181
+ print(f"WARNING: no detections")
182
+ # fallback to historical default rows layout
183
+ return 'rows'
184
+
185
+ if img_w <= 0 or img_h <= 0:
186
+
187
+ if verbose:
188
+
189
+ print(f"WARNING: invalid image size: {img_w}x{img_h}")
190
+ # fallback to historical default rows layout
191
+ raise ValueError(f"invalid image size: {img_w}x{img_h}")
192
+
193
+ return 'rows'
194
+
195
+ votes: dict[str, float] = {'rows': 0.0, 'columns': 0.0}
196
+ # More important signals have higher weights
197
+ weights = {'cartouche_aspect': 1.5, 'band_count': 1.0, 'sign_aspect': 0.5}
198
+
199
+ for name, fn in (
200
+ ('cartouche_aspect', _vote_cartouche_aspect),
201
+ ('band_count', _vote_band_count),
202
+ ('sign_aspect', _vote_sign_aspect),
203
+ ):
204
+ if name == 'sign_aspect':
205
+
206
+ label, conf = fn(detections, img_w, img_h)
207
+
208
+ else:
209
+ label, conf = fn(detections, img_w, img_h)
210
+
211
+ if label is not None:
212
+
213
+ votes[label] += weights[name] * conf
214
+
215
+ if verbose:
216
+
217
+ print(f" layout vote [{name}]: {label} (conf={conf:.2f})")
218
+
219
+ diff = votes['columns'] - votes['rows']
220
+
221
+ if verbose:
222
+
223
+ print(f" totals: columns={votes['columns']:.2f} rows={votes['rows']:.2f}")
224
+
225
+ if abs(diff) < MIN_SIGNAL_GAP:
226
+
227
+ return 'rows' # tie -> historical default
228
+
229
+ return 'columns' if diff > 0 else 'rows'
230
+
231
+
232
+
233
+ # Legacy pixel fallback (kept for callers that don't have detections yet).
234
+
235
+ # def detect_layout(img) -> str:
236
+ # """Pixel-based fallback (morphological line detection).
237
+ # Prefer detect_layout_from_detections() — this one fails on stone reliefs.
238
+ # """
239
+ # import cv2
240
+ # gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
241
+ # binary = cv2.adaptiveThreshold(
242
+ # gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
243
+ # cv2.THRESH_BINARY_INV, 15, 4,
244
+ # )
245
+ # h, w = binary.shape
246
+ # h_kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (w // 3, 1))
247
+ # v_kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (1, h // 3))
248
+ # h_score = np.sum(cv2.morphologyEx(binary, cv2.MORPH_OPEN, h_kernel)) / 255
249
+ # v_score = np.sum(cv2.morphologyEx(binary, cv2.MORPH_OPEN, v_kernel)) / 255
250
+ # MIN_SCORE = 500
251
+ # if h_score > MIN_SCORE and h_score > v_score * 1.5:
252
+ # return 'rows'
253
+ # if v_score > MIN_SCORE and v_score > h_score * 1.5:
254
+ # return 'columns'
255
+ # return 'rows'
src/llm.py ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ llm.py — GPT transliteration for the HF Space.
4
+
5
+ Port of app/services/transliteration_services.py with the FastAPI stack
6
+ removed: pydantic-settings -> env vars (HF Space secrets are env vars, so
7
+ this is strictly simpler than shipping a .env), pydantic BaseModel ->
8
+ dataclasses (the three models carry no validators, so this is lossless).
9
+
10
+ SYSTEM_PROMPT, segment_into_chunks and build_egyptologist_prompt are copied
11
+ VERBATIM — including the h() blank->'unknown' normalization and the
12
+ matched-vs-[UNRESOLVED cartouche prompt split. Keep the '[UNRESOLVED' prefix
13
+ wording in sync with the backend if either side changes.
14
+
15
+ Contract preserved: this module NEVER raises on an LLM failure. No API key or
16
+ any OpenAI error returns a TransliterationOut with `error` set.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import json
22
+ import logging
23
+ import os
24
+ from dataclasses import dataclass, field
25
+ from typing import Optional
26
+
27
+ from openai import OpenAI
28
+
29
+ logger = logging.getLogger('sphinxeyes.transliteration')
30
+
31
+ OPENAI_API_KEY = os.getenv('OPENAI_API_KEY', '')
32
+ OPENAI_MODEL = os.getenv('OPENAI_MODEL', 'gpt-4o')
33
+ TRANSLIT_MAX_SIGNS = int(os.getenv('TRANSLIT_MAX_SIGNS', '20'))
34
+ TRANSLIT_TEMPERATURE = float(os.getenv('TRANSLIT_TEMPERATURE', '0.1'))
35
+
36
+
37
+ # Controlled vocabularies — MUST match app/schemas/transliterations.py.
38
+ # 'unknown' is always first = the default.
39
+ PERIODS = ['unknown', 'old_kingdom', 'first_intermediate', 'middle_kingdom',
40
+ 'second_intermediate', 'new_kingdom', 'third_intermediate',
41
+ 'late_period', 'ptolemaic', 'roman']
42
+ TEXT_TYPES = ['unknown', 'stela', 'temple_wall', 'tomb_wall', 'papyrus',
43
+ 'sarcophagus', 'obelisk', 'statue', 'offering_table',
44
+ 'pyramid_texts']
45
+ SUPPORTS = ['unknown', 'limestone', 'sandstone', 'granite', 'papyrus', 'wood',
46
+ 'plaster', 'faience', 'metal']
47
+ LOCATION_TYPES = ['unknown', 'pyramid', 'temple', 'tomb', 'museum', 'open_site']
48
+
49
+
50
+ @dataclass
51
+ class TextContext:
52
+ period : str = 'unknown'
53
+ text_type : str = 'unknown'
54
+ support : str = 'unknown'
55
+ location_type : str = 'unknown'
56
+ site : str = 'unknown'
57
+ dynasty : str = 'unknown'
58
+ kings_reign : str = 'unknown'
59
+
60
+
61
+ @dataclass
62
+ class ChunkTransliteration:
63
+ chunk_index : int
64
+ gardiner_codes : list[str]
65
+ transliteration : str
66
+ english_gloss : str
67
+ linguistic_notes : str = ''
68
+ confidence : str = 'LOW'
69
+ period_note : str = ''
70
+ is_cartouche : bool = False
71
+
72
+
73
+ @dataclass
74
+ class TransliterationOut:
75
+ chunks : list[ChunkTransliteration] = field(default_factory=list)
76
+ full_transliteration : str = ''
77
+ full_translation : str = ''
78
+ model : str = OPENAI_MODEL
79
+ n_chunks : int = 0
80
+ error : Optional[str] = None
81
+
82
+
83
+ # Chunking (port of segement_into_chunck.segment_into_chunks)
84
+
85
+ def segment_into_chunks(
86
+ codes : list[str],
87
+ confidences : list[float],
88
+ boundary_hints : list[int],
89
+ max_signs : int = 20,
90
+ ) -> list[list[tuple[str, float]]]:
91
+ """
92
+ Split the ordered (code, conf) sequence into chunks of at most
93
+ `max_signs`, cutting preferentially at line boundaries so a chunk
94
+ never mixes signs from different physical lines.
95
+ """
96
+ pairs = list(zip(codes, confidences))
97
+ bounds = sorted(b for b in boundary_hints if 0 < b <= len(pairs))
98
+ if not bounds or bounds[-1] != len(pairs):
99
+ bounds.append(len(pairs))
100
+
101
+ chunks: list[list[tuple[str, float]]] = []
102
+ start = 0
103
+ for b in bounds:
104
+ line = pairs[start:b]
105
+ # split an over-long line at max_signs
106
+ for i in range(0, len(line), max_signs):
107
+ piece = line[i:i + max_signs]
108
+ if piece:
109
+ chunks.append(piece)
110
+ start = b
111
+ return chunks
112
+
113
+
114
+ # Prompt (port of prompt2GPT.build_egyptologist_prompt)
115
+
116
+ # The role/methodology half of the prompt. Static -> sent as the system
117
+ # message (also lets OpenAI cache it across the per-chunk calls).
118
+ SYSTEM_PROMPT = """You are an expert Egyptologist and philologist specializing in Middle Egyptian \
119
+ (the classical language of Dynasties XI-XVIII, also used ceremonially long after). You read \
120
+ hieroglyphic inscriptions from Gardiner sign codes and produce scholarly transliterations and \
121
+ English glosses.
122
+
123
+ HOW THE INPUT WAS PRODUCED (important for judging its reliability):
124
+ The Gardiner sequence comes from a computer-vision pipeline, not a human copyist:
125
+ 1. A YOLO detector recognizes individual signs on the photograph (each has a confidence score).
126
+ 2. A spatial algorithm reconstructs reading order (quadrat stacking, line breaks).
127
+ 3. A lexicon-based corrector (Viterbi over a dictionary trie + bigram model) may have already
128
+ substituted some low-confidence detections.
129
+ 4. Cartouches are matched against a verified royal-name lexicon (Beckerath) — when a royal name
130
+ is given, it is MORE reliable than the raw sign codes around it.
131
+ Consequences you must handle:
132
+ - Signs may be MISCLASSIFIED as visually similar signs. Frequent confusions of this detector:
133
+ G1 (vulture) <-> G5 (falcon) <-> G39 (duck); N5 (sun disc) <-> N33 (pellet) <-> Aa1 (placenta)
134
+ <-> O49 (town); X1 (bread loaf) <-> X8 (conical loaf); S29 (folded cloth) <-> O34 (door bolt);
135
+ W19 (milk jug) <-> W14 (water jar); M23 (sedge) <-> M22 (rush); D21 (mouth) <-> D4 (eye);
136
+ Y1 <-> Y2 (papyrus rolls); Z1 <-> Z4 (strokes). When a LOW or MED confidence sign yields
137
+ nonsense but one of its confusion partners yields coherent Middle Egyptian, prefer the partner
138
+ and say so in the notes.
139
+ - A sign may be MISSING (detector miss) — small phonetic complements and determinatives are the
140
+ usual casualties. You may posit an omitted complement when the reading obviously requires it.
141
+ - 'Unknown' tokens are undetected signs: treat them as lacunae, transliterate as [...].
142
+ - Reading order is usually right but not guaranteed within a quadrat; minor transpositions
143
+ (e.g. honorific transposition of nTr / nsw / ra) should be restored silently.
144
+
145
+ METHOD — work like a philologist, not a code mapper:
146
+ 1. Segment the sign string into words: identify uniliterals, biliterals, triliterals, phonetic
147
+ complements (do not transliterate a complement twice), determinatives (classify, never
148
+ pronounce), and logograms.
149
+ 2. Look for the high-frequency formulae of monumental texts and let them anchor the reading:
150
+ htp-di-nsw (offering formula), sA ra (son of Ra), nb tAwy (lord of the Two Lands),
151
+ nTr nfr (the good god), di anx (given life), mAa-xrw (true of voice), anx wDA snb,
152
+ nswt-bity (dual king), Dt / nHH (forever), epithets of deities and royal titulary.
153
+ 3. If a royal cartouche is identified, use it as the chronological and thematic anchor: titles
154
+ and epithets adjacent to a cartouche almost always belong to the standard titulary sequence.
155
+ 4. Use the archaeological context: a temple wall favours royal/divine formulae; a stela favours
156
+ the offering formula and filiation (X sA Y, mAat-xrw); pyramid texts favour Old Kingdom
157
+ spellings; a papyrus may be literary or administrative.
158
+ 5. Commit to ONE most-probable reading. Note real alternatives briefly instead of hedging.
159
+
160
+ OUTPUT — JSON only, no preamble, exactly these keys:
161
+ {
162
+ "transliteration": "Unified Leiden conventions (aA not aleph-glyph fallback; use . for suffixes, = for clitics, [...] for lacunae, ( ) for restored signs)",
163
+ "english_gloss": "~ one plain-English sentence, functional gloss for non-specialists",
164
+ "linguistic_notes": "max 2 sentences: key ambiguity, any confusion-pair substitution you made, notable grammar",
165
+ "confidence": "HIGH|MEDIUM|LOW",
166
+ "period_note": "one short remark tying the reading to the stated period/reign, or '' if context was unknown"
167
+ }
168
+ Answer in ENGLISH only."""
169
+
170
+
171
+ def build_egyptologist_prompt(
172
+ codes : list[str],
173
+ confidences : list[float],
174
+ ctx : TextContext,
175
+ direction : str,
176
+ layout : str,
177
+ cartouche_names : list[str],
178
+ previous_context : str | None,
179
+ chunk_info : str,
180
+ ) -> str:
181
+ """Build the per-chunk USER message (the system message is static)."""
182
+ signs = ' — '.join(
183
+ f'{c}({"HIGH" if s >= 0.80 else "MED" if s >= 0.50 else "LOW"}:{s:.2f})'
184
+ for c, s in zip(codes, confidences)
185
+ )
186
+
187
+ def h(v: str) -> str: # human-readable context value
188
+ # blank/whitespace (client sent '' after the user erased a field)
189
+ # must read as 'unknown', not an empty line the LLM could misread
190
+ return (v or '').strip().replace('_', ' ') or 'unknown'
191
+
192
+ # Matched names are authoritative; UNRESOLVED entries (match refused)
193
+ # carry raw interior signs only — never present those as verified.
194
+ matched = [n for n in cartouche_names if not n.startswith('[UNRESOLVED')]
195
+ unresolved = [n for n in cartouche_names if n.startswith('[UNRESOLVED')]
196
+ parts = []
197
+ if matched:
198
+ parts.append(
199
+ 'Royal cartouches identified in this scene (lexicon-verified — '
200
+ 'treat as authoritative, more reliable than raw sign codes):\n '
201
+ + '\n '.join(matched))
202
+ if unresolved:
203
+ parts.append(
204
+ 'Cartouches detected but NOT resolved to a known royal name — '
205
+ 'read their raw interior signs yourself (a royal name or epithet '
206
+ 'is likely; do not invent a specific king):\n '
207
+ + '\n '.join(unresolved))
208
+ cartouche_block = '\n- '.join(parts) if parts else 'Contains cartouche: no'
209
+ previous_block = (
210
+ f'\nPREVIOUS SEGMENTS of the same inscription (already transliterated '
211
+ f'— keep names, epithets and topic consistent with them):\n'
212
+ f'{previous_context}\n' if previous_context else ''
213
+ )
214
+
215
+ return f"""DETECTED SIGN SEQUENCE ({chunk_info}; each segment is one physical line of text; Gardiner codes with detector confidence):
216
+ {signs}
217
+
218
+ ARCHAEOLOGICAL CONTEXT (fields marked 'unknown' were not supplied by the user — do not invent them, but exploit every field that IS given):
219
+ - Period: {h(ctx.period)}
220
+ - Dynasty: {h(ctx.dynasty)}
221
+ - King's reign: {h(ctx.kings_reign)}
222
+ - Text type: {h(ctx.text_type)}
223
+ - Physical support: {h(ctx.support)}
224
+ - Location type: {h(ctx.location_type)}
225
+ - Site: {h(ctx.site)}
226
+ - Reading direction: {direction}
227
+ - Layout: {layout}
228
+ - {cartouche_block}
229
+ {previous_block}
230
+ Transliterate and gloss this segment. JSON only."""
231
+
232
+
233
+ class TransliterationService:
234
+ """GPT-4o transliteration. Degrades gracefully — never raises."""
235
+
236
+ def __init__(self) -> None:
237
+ self._client = OpenAI(api_key=OPENAI_API_KEY) if OPENAI_API_KEY else None
238
+
239
+ @property
240
+ def enabled(self) -> bool:
241
+ return self._client is not None
242
+
243
+ def transliterate(
244
+ self,
245
+ raw : dict, # SphinxPipeline.run() output
246
+ ctx : TextContext,
247
+ ) -> TransliterationOut:
248
+ outer = raw['outer']
249
+ codes = outer['correction']['flat_corrected_seq']
250
+ confs = [slot[0][1] if slot else 0.0 for slot in outer['slots']]
251
+ # corrected seq and slots are index-aligned; guard anyway
252
+ if len(confs) != len(codes):
253
+ confs = (confs + [0.0] * len(codes))[:len(codes)]
254
+
255
+ cartouche_names = []
256
+ for c in raw['cartouches']:
257
+ if c.get('translit'):
258
+ cartouche_names.append(
259
+ f"{c['translit']} — {c['english']} (interior: {' '.join(c['spelling'] or [])})"
260
+ )
261
+ elif c.get('n_members', 0) > 0:
262
+ raw_codes = ' '.join(
263
+ slot[0][0] for slot in c.get('slots', []) if slot
264
+ )
265
+ if raw_codes:
266
+ cartouche_names.append(
267
+ f"[UNRESOLVED cartouche — raw signs detected but no confident "
268
+ f"royal-name match: {raw_codes}]"
269
+ )
270
+ else:
271
+ cartouche_names.append(f"[UNRESOLVED cartouche — no signs detected]")
272
+
273
+ return self.transliterate_sequence(
274
+ codes, confs, outer['boundary_hints'], cartouche_names,
275
+ direction=raw['direction'], layout=raw['layout'], ctx=ctx,
276
+ )
277
+
278
+ def transliterate_sequence(
279
+ self,
280
+ codes : list[str],
281
+ confidences : list[float],
282
+ boundary_hints : list[int],
283
+ cartouche_names : list[str],
284
+ *,
285
+ direction : str,
286
+ layout : str,
287
+ ctx : TextContext,
288
+ ) -> TransliterationOut:
289
+ if not self.enabled:
290
+ return TransliterationOut(
291
+ chunks=[], full_transliteration='', full_translation='',
292
+ model=OPENAI_MODEL, n_chunks=0,
293
+ error='OPENAI_API_KEY not configured — transliteration disabled.',
294
+ )
295
+
296
+ chunks = segment_into_chunks(
297
+ codes, confidences, boundary_hints, max_signs=TRANSLIT_MAX_SIGNS,
298
+ )
299
+
300
+ results: list[ChunkTransliteration] = []
301
+ for i, chunk in enumerate(chunks):
302
+ c_codes = [c for c, _ in chunk]
303
+ c_confs = [s for _, s in chunk]
304
+ previous = ' | '.join(r.transliteration for r in results) or None
305
+
306
+ prompt = build_egyptologist_prompt(
307
+ c_codes, c_confs, ctx,
308
+ direction=direction, layout=layout,
309
+ cartouche_names=cartouche_names,
310
+ previous_context=previous,
311
+ chunk_info=f'Segment {i + 1} of {len(chunks)}',
312
+ )
313
+ try:
314
+ response = self._client.chat.completions.create(
315
+ model = OPENAI_MODEL,
316
+ messages = [
317
+ {'role': 'system', 'content': SYSTEM_PROMPT},
318
+ {'role': 'user', 'content': prompt},
319
+ ],
320
+ temperature = TRANSLIT_TEMPERATURE,
321
+ response_format = {'type': 'json_object'},
322
+ )
323
+ parsed = json.loads(response.choices[0].message.content)
324
+ except Exception as e:
325
+ logger.exception(f'LLM transliteration failed on chunk {i}')
326
+ return TransliterationOut(
327
+ chunks=results,
328
+ full_transliteration=' | '.join(r.transliteration for r in results),
329
+ full_translation=' '.join(r.english_gloss for r in results),
330
+ model=OPENAI_MODEL, n_chunks=len(chunks),
331
+ error=f'LLM call failed on segment {i + 1}/{len(chunks)}: {e}',
332
+ )
333
+
334
+ results.append(ChunkTransliteration(
335
+ chunk_index = i,
336
+ gardiner_codes = c_codes,
337
+ transliteration = str(parsed.get('transliteration', '')),
338
+ english_gloss = str(parsed.get('english_gloss', '')),
339
+ linguistic_notes = str(parsed.get('linguistic_notes', '')),
340
+ confidence = parsed.get('confidence', 'LOW')
341
+ if parsed.get('confidence') in ('HIGH', 'MEDIUM', 'LOW')
342
+ else 'LOW',
343
+ period_note = str(parsed.get('period_note', '')),
344
+ ))
345
+
346
+ return TransliterationOut(
347
+ chunks = results,
348
+ full_transliteration = ' | '.join(r.transliteration for r in results),
349
+ full_translation = ' '.join(r.english_gloss for r in results),
350
+ model = OPENAI_MODEL,
351
+ n_chunks = len(results),
352
+ )
353
+
354
+
355
+ # One client for the process lifetime — the FastAPI version built a new
356
+ # OpenAI client per request, which is wrong for a long-lived Gradio app.
357
+ SERVICE = TransliterationService()
src/pipeline.py ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import sys
7
+ from dataclasses import asdict
8
+ from pathlib import Path
9
+ from typing import Callable, Optional, Union
10
+
11
+ import cv2
12
+ import numpy as np
13
+
14
+ try: # HF Space ships the torch backend only;
15
+ import onnxruntime as ort # onnxruntime is a local-dev convenience.
16
+ except ImportError: # pragma: no cover
17
+ ort = None
18
+
19
+ import cartouche_matcher as CM
20
+ import enhance_img
21
+ import layout_detector
22
+ import spatial_logic as SL
23
+ import sphinx_corrector as SC
24
+ """
25
+ pipeline.py — end-to-end glue (V4).
26
+
27
+ bytes/path/ndarray
28
+ [optional enhance_img.enhance() — OFF by default; A/B on grand_glyphs
29
+ showed it deletes real signs and hallucinates fakes on clean images]
30
+ ONNX global pass (letterbox resize — matches Ultralytics V4 training)
31
+ postprocess_onnx (conf NMS top-3)
32
+ tag_cartouche_members
33
+ merge_duplicate_boxes
34
+ outer: cluster_quadrats + assemble_reading_order + sphinx_corrector.correct()
35
+ cartouches: per-cartouche RO (single_line=True)
36
+ + cartouche_matcher.match_cartouche + apply_panel_consensus
37
+
38
+ Smoke test:
39
+ python pipeline.py <image>
40
+ """
41
+
42
+ ROOT = Path(__file__).parent
43
+
44
+ # Drop cartouches whose bbox sits within this fraction of the image border.
45
+ # Egyptian cartouches always have both bracket ends visible; a clipped one
46
+ # is a photo-crop artifact and its interior is incomplete by definition.
47
+ EDGE_FRAC = 0.01
48
+
49
+
50
+ def _draw_detections(bgr: np.ndarray, detections) -> np.ndarray:
51
+ """
52
+ YOLO-style annotated copy of the image: one box per detection with
53
+ 'class conf' label. Cartouches gold and thicker; signs green;
54
+ unknowns grey. Label/line size scales with image resolution.
55
+ """
56
+ out = bgr.copy()
57
+
58
+ H, W = out.shape[:2]
59
+
60
+ thick = max(1, round(min(H, W) / 640))
61
+
62
+ font_scale = min(H, W) / 1600
63
+
64
+ font = cv2.FONT_HERSHEY_SIMPLEX
65
+
66
+ for d in detections:
67
+
68
+ x1, y1, x2, y2 = (int(round(v)) for v in d.bbox)
69
+
70
+ cls, score = d.top3[0]
71
+
72
+ if d.is_cartouche():
73
+
74
+ color, t = (0, 190, 255), thick * 2 # gold (BGR)
75
+
76
+ elif cls.lower() == 'unknown':
77
+
78
+ color, t = (160, 160, 160), thick # grey
79
+
80
+ else:
81
+
82
+ color, t = (80, 200, 60), thick # green
83
+
84
+ cv2.rectangle(out, (x1, y1), (x2, y2), color, t)
85
+
86
+ label = f'{cls} {min(score, 0.998):.2f}'
87
+
88
+ (tw, th), base = cv2.getTextSize(label, font, font_scale, thick)
89
+
90
+ ty = y1 - 4 if y1 - th - base - 4 >= 0 else y2 + th + base + 4
91
+
92
+ cv2.rectangle(out, (x1, ty - th - base),
93
+ (x1 + tw + 2, ty + base),
94
+ color, -1)
95
+ cv2.putText(out, label, (x1 + 1, ty),
96
+ font, font_scale,
97
+ (0, 0, 0), thick,
98
+ cv2.LINE_AA)
99
+
100
+ return out
101
+
102
+
103
+ def _filter_edge_cartouches(detections, img_w: int, img_h: int) -> list:
104
+ """Drop cartouche-class detections whose bbox touches any image edge."""
105
+ ex, ey = EDGE_FRAC * img_w, EDGE_FRAC * img_h #| EDGE_FRAC * img_h
106
+ kept = []
107
+ for d in detections:
108
+
109
+ if d.is_cartouche():
110
+
111
+ x1, y1, x2, y2 = d.bbox
112
+
113
+ if (x1 <= ex or y1 <= ey or x2 >= img_w - ex or y2 >= img_h - ey):
114
+ continue
115
+
116
+ kept.append(d)
117
+
118
+ return kept
119
+
120
+
121
+ class SphinxPipeline:
122
+ """Single-shot pipeline. Loads heavy artifacts once at construction."""
123
+
124
+ def __init__(
125
+ self,
126
+ onnx_path : Optional[Path] = None,
127
+ class_map : Path = ROOT / 'artifacts' / 'class_map50_v9.json',
128
+ trie_pkl : Path = ROOT / 'artifacts' / 'sphinx_trie_v4.pkl',
129
+ bbaw_parquet : Path = ROOT / 'artifacts' / 'bbaw_clean.parquet',
130
+ confusion_csv : Path = ROOT / 'artifacts' / 'confusion_matrix_v9_normalized.csv',
131
+ imgsz : int = 1024,
132
+ providers : Optional[list] = None,
133
+ infer_fn : Optional[Callable[[np.ndarray], list]] = None,
134
+ ):
135
+ """
136
+ Detection backend is injected, not hardcoded.
137
+
138
+ infer_fn -- a Callable[[bgr ndarray], list[Detection]]; on the HF Space
139
+ this is infer_torch.make_torch_infer_fn() (v10 .pt, ZeroGPU).
140
+ onnx_path -- local-dev alternative: builds the ONNX backend instead. The
141
+ two are interchangeable because both letterbox identically
142
+ and both end in SL.postprocess_onnx, so the top-3 slot
143
+ contract the corrector depends on is preserved either way.
144
+
145
+ Exactly one of infer_fn / onnx_path must be given.
146
+ """
147
+ if (infer_fn is None) == (onnx_path is None):
148
+ raise ValueError('pass exactly one of infer_fn= or onnx_path=')
149
+
150
+ self.class_names = list(json.load(open(class_map)).keys())
151
+
152
+ assert len(self.class_names) == 150, \
153
+ f'expected 150 classes, got {len(self.class_names)}'
154
+
155
+ conf = Path(confusion_csv) if Path(confusion_csv).exists() else None
156
+
157
+ self.trie, self.log_prob, self.unigrams, self.sub_cost = \
158
+ SC.load_corrector(trie_pkl, bbaw_parquet, confusion_csv=conf)
159
+
160
+ self.royal_names = CM.load_royal_names()
161
+
162
+ self.imgsz = imgsz
163
+
164
+ if infer_fn is not None:
165
+ self.session = None
166
+ self.infer_global = infer_fn
167
+ else:
168
+ if ort is None:
169
+ raise ImportError(
170
+ 'onnxruntime is not installed — pass infer_fn= instead '
171
+ '(the Space uses the torch/ZeroGPU backend).')
172
+ if not Path(onnx_path).exists():
173
+ raise FileNotFoundError(f'ONNX weights not found: {onnx_path}')
174
+
175
+ providers = providers or ['CPUExecutionProvider']
176
+ self.session = ort.InferenceSession(str(onnx_path), providers=providers)
177
+ self.infer_global = SL.make_onnx_infer_fn(
178
+ self.session, self.class_names,
179
+ conf_thresh=SL.CONF_THRESHOLD, imgsz=imgsz, mode='letterbox',
180
+ )
181
+
182
+
183
+ @staticmethod
184
+ def _load_image(image: Union[str, Path, bytes, bytearray, np.ndarray]) -> np.ndarray:
185
+ # TODO: use PIL
186
+ if isinstance(image, np.ndarray):
187
+
188
+ return image
189
+
190
+ if isinstance(image, (bytes, bytearray)):
191
+
192
+ arr = np.frombuffer(image, dtype=np.uint8)
193
+ bgr = cv2.imdecode(arr, cv2.IMREAD_COLOR)
194
+
195
+ else:
196
+ bgr = cv2.imread(str(image))
197
+
198
+ if bgr is None:
199
+
200
+ raise ValueError(f'could not decode image: {image!r}')
201
+
202
+ return bgr
203
+
204
+
205
+ def run(
206
+ self,
207
+ image : Union[str, Path, bytes, bytearray, np.ndarray],
208
+ *,
209
+ direction : str = 'rtl',
210
+ layout : Optional[str] = None, # 'rows' | 'columns' | None=auto
211
+ use_enhance : bool = False,
212
+ preset : str = 'default',
213
+ annotate : bool = False, # add 'annotated_bgr' ndarray to result
214
+ ) -> dict:
215
+ bgr = self._load_image(image)
216
+ if use_enhance:
217
+ bgr = enhance_img.enhance(bgr, preset=preset)
218
+
219
+ H, W = bgr.shape[:2]
220
+
221
+ # 1) Global detection (YOLO-driven)
222
+ dets = self.infer_global(bgr)
223
+
224
+ # 1a) Drop edge-clipped cartouches (partial bracket -> incomplete
225
+ # interior). Must run before layout vote so the cartouche-aspect
226
+ # signal isn't poisoned by tiny edge slivers.
227
+ dets = _filter_edge_cartouches(dets, W, H)
228
+
229
+ # 1a') Collapse twin cartouche boxes over the same physical cartouche
230
+ # (a low CARTOUCHE_CONF admits weak duplicates that the 0.50 NMS
231
+ # leaves alone). Must run before tagging so interior signs bind
232
+ # to the surviving box, and before the layout vote so duplicate
233
+ # cartouches don't skew the cartouche-aspect signal.
234
+ dets = SL.merge_duplicate_cartouches(dets)
235
+
236
+ # 1b) Layout should be supplied by the caller — the geometric
237
+ # auto-detector is UNRELIABLE on real walls (misvotes rows vs
238
+ # columns). Kept only as a last-resort fallback for callers
239
+ # that genuinely cannot know; the API makes layout mandatory.
240
+ if layout is None:
241
+
242
+ layout = layout_detector.detect_layout_from_detections(dets, W, H)
243
+ import logging
244
+ logging.getLogger('sphinxeyes.pipeline').warning(
245
+ f'layout not supplied — auto-detector guessed {layout!r}. '
246
+ f'This heuristic is unreliable; pass layout explicitly.')
247
+
248
+ if layout not in ('rows', 'columns'):
249
+
250
+ layout = 'rows'
251
+
252
+ # 2) Cartouche containment + duplicate merge
253
+ cart_idxs = SL.tag_cartouche_members(dets, img_w=W, img_h=H)
254
+ dets = SL.merge_duplicate_boxes(dets)
255
+
256
+ cart_idxs = [i for i, d in enumerate(dets) if d.is_cartouche()]
257
+
258
+ # 3) Outer text reading order + corrector
259
+ outer = [d for d in dets
260
+ if not d.inside_cartouche and not d.is_cartouche()]
261
+
262
+ outer_quads = SL.cluster_quadrats(outer, layout=layout)
263
+
264
+ outer_ro = SL.assemble_reading_order(
265
+ outer_quads, layout=layout, direction=direction)
266
+
267
+ canon_outer = self._canon_slots(outer_ro.slots)
268
+
269
+ correction = SC.correct(
270
+ canon_outer, self.trie, self.log_prob, self.unigrams,
271
+ sub_cost_matrix=self.sub_cost,
272
+ boundary_hints=outer_ro.boundary_hints,
273
+ )
274
+
275
+ # 4) Cartouches (interior reading + royal-name match + consensus)
276
+ cart_results : list[Optional[CM.RoyalMatch]] = []
277
+ cart_slots_all: list[list[list[tuple[str, float]]]] = []
278
+ cart_meta : list[dict] = []
279
+
280
+ for ci in cart_idxs:
281
+ members = [d for d in dets
282
+ if d.inside_cartouche and d.cartouche_id == ci]
283
+ if not members:
284
+ cart_results.append(None)
285
+ cart_slots_all.append([])
286
+ cart_meta.append({'bbox': dets[ci].bbox, 'n_members': 0})
287
+ continue
288
+ quads = SL.cluster_quadrats(members, layout=layout)
289
+ ro = SL.assemble_reading_order(
290
+ quads, layout=layout, direction=direction,
291
+ single_line=True, extent=dets[ci].bbox,
292
+ )
293
+ slots = self._canon_slots(ro.slots)
294
+ cart_slots_all.append(slots)
295
+ cart_results.append(
296
+ CM.match_cartouche(slots, self.royal_names, sub_cost=self.sub_cost)
297
+ )
298
+ cart_meta.append({'bbox': dets[ci].bbox, 'n_members': len(members)})
299
+
300
+ cart_final = CM.apply_panel_consensus(
301
+ cart_results, cart_slots_all, self.royal_names,
302
+ sub_cost=self.sub_cost,
303
+ )
304
+
305
+ result = {
306
+ 'layout' : layout,
307
+ 'direction' : direction,
308
+ 'image_shape' : (H, W),
309
+ 'n_detections' : len(dets),
310
+ 'n_cartouches' : len(cart_idxs),
311
+ 'outer': {
312
+ 'slots' : canon_outer,
313
+ 'boundary_hints' : outer_ro.boundary_hints,
314
+ 'n_synthetic' : outer_ro.n_synthetic,
315
+ 'correction' : correction.to_dict(),
316
+ },
317
+ 'cartouches': [
318
+ {
319
+ 'bbox' : meta['bbox'],
320
+ 'n_members' : meta['n_members'],
321
+ 'slots' : slots,
322
+ 'inferred' : inferred,
323
+ 'translit' : m.translit if m else None,
324
+ 'english' : m.english if m else None,
325
+ 'spelling' : m.spelling if m else None,
326
+ 'score' : m.score if m else None,
327
+ 'aligned_codes' : m.aligned_codes if m else None,
328
+ 'verified' : m.verified if m else None,
329
+ }
330
+ for (m, inferred), slots, meta in zip(
331
+ cart_final, cart_slots_all, cart_meta)
332
+ ],
333
+ }
334
+ if annotate:
335
+ # ndarray, not JSON-serializable — API layer encodes to JPEG.
336
+ result['annotated_bgr'] = _draw_detections(bgr, dets)
337
+ return result
338
+
339
+ @staticmethod
340
+ def _canon_slots(slots):
341
+ return [[(CM.normalize_code(c), float(s)) for c, s in slot]
342
+ for slot in slots]
343
+
344
+
345
+ # Thin CLI — prints a run summary; all tests live in tests/ (pytest)
346
+
347
+ def _summarize(result: dict) -> None:
348
+ print(f"layout={result['layout']} direction={result['direction']} "
349
+ f"shape={result['image_shape']}")
350
+ print(f"detections={result['n_detections']} "
351
+ f"cartouches={result['n_cartouches']}")
352
+ o = result['outer']
353
+ corr = o['correction']
354
+ print(f"\n--- OUTER TEXT ---")
355
+ print(f" slots={len(o['slots'])} synthetic={o['n_synthetic']} "
356
+ f"boundary_hints={o['boundary_hints']}")
357
+ print(f" corrected: {' '.join(corr.get('flat_corrected_seq', []))}")
358
+ print(f" translit : {corr.get('flat_translit', '')}")
359
+ print(f" score : {corr.get('score', 0):.2f} "
360
+ f"fallback={corr.get('had_fallback')}")
361
+ print(f"\n--- CARTOUCHES ---")
362
+ for k, c in enumerate(result['cartouches']):
363
+ tag = (f"{c['translit']} ({'inferred' if c['inferred'] else 'direct'}, "
364
+ f"score={c['score']:.2f})") if c['translit'] else "REFUSED"
365
+ print(f" #{k} members={c['n_members']:<2} -> {tag}")
366
+
367
+
368
+ def main():
369
+ """
370
+ Local-dev smoke CLI (ONNX backend — the Space itself never runs this).
371
+
372
+ python src/pipeline.py <image> [rows|columns]
373
+
374
+ Point SPHINX_ONNX at a v9 .onnx; defaults to the parent repo's copy so the
375
+ extraction can be verified without installing torch.
376
+ """
377
+ import os
378
+ # No default image: test_image_vn5.png is CONTAMINATED (CLAUDE.md
379
+ # fragile breakpoint #8) — always require an explicit path.
380
+ if len(sys.argv) < 2:
381
+ sys.exit('usage: python pipeline.py <image> [rows|columns] '
382
+ '(e.g. Unas1c.jpg, image_2_test.jpg)')
383
+ img = sys.argv[1]
384
+ layout = sys.argv[2] if len(sys.argv) > 2 else 'columns'
385
+ if not Path(img).exists():
386
+ sys.exit(f'image not found: {img}')
387
+ onnx = Path(os.getenv(
388
+ 'SPHINX_ONNX', ROOT.parents[1] / 'artifacts' / 'best_model_v9.onnx'))
389
+ print(f"Loading pipeline (onnx={onnx}) ...")
390
+ p = SphinxPipeline(onnx_path=onnx)
391
+ print(f"Running on {img} (layout={layout}) ...")
392
+ result = p.run(img, layout=layout)
393
+ _summarize(result)
394
+
395
+
396
+ if __name__ == '__main__':
397
+ main()
src/ratelimit.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ ratelimit.py — best-effort daily cap on the (paid) LLM transliteration stage.
4
+
5
+ Detection is always free; only transliteration is metered.
6
+
7
+ HONEST LIMITATIONS — this is cost control, not security:
8
+ * State is in-memory. A Space restart or sleep resets every counter.
9
+ * Identity is the client IP, which is shared behind NAT/VPN and rotatable.
10
+ HF Spaces have no per-user identity available to the app.
11
+ * GLOBAL_DAILY is the backstop that actually protects the API key: even if
12
+ one caller rotates IPs freely, total spend per UTC day is bounded.
13
+
14
+ Design note: check() does NOT consume quota. commit() is called only after a
15
+ successful LLM call, so an OpenAI outage or a missing key never burns a user's
16
+ three attempts.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import hashlib
22
+ import os
23
+ import threading
24
+ from datetime import datetime, timezone
25
+
26
+ PER_IP_DAILY = int(os.getenv('SPHINX_PER_IP_DAILY', '3'))
27
+ GLOBAL_DAILY = int(os.getenv('SPHINX_GLOBAL_DAILY', '100'))
28
+
29
+ _USAGE : dict[tuple[str, str], int] = {} # (ip_hash, utc_date) -> n
30
+ _GLOBAL : dict[str, int] = {} # utc_date -> n
31
+ _LOCK = threading.Lock() # Gradio serves requests threaded
32
+
33
+
34
+ def _today() -> str:
35
+ return datetime.now(timezone.utc).strftime('%Y-%m-%d')
36
+
37
+
38
+ def client_id(request) -> str:
39
+ """
40
+ Stable pseudonymous id for a caller. HF Spaces sit behind a proxy, so
41
+ x-forwarded-for holds the real client; its first entry is the origin.
42
+ Hashed — raw IPs are never stored.
43
+ """
44
+ ip = 'unknown'
45
+ if request is not None:
46
+ headers = getattr(request, 'headers', None) or {}
47
+ fwd = ''
48
+ try:
49
+ fwd = headers.get('x-forwarded-for', '') or ''
50
+ except Exception:
51
+ fwd = ''
52
+ if fwd:
53
+ ip = fwd.split(',')[0].strip()
54
+ else:
55
+ client = getattr(request, 'client', None)
56
+ ip = getattr(client, 'host', None) or 'unknown'
57
+ return hashlib.sha256(ip.encode('utf-8')).hexdigest()[:16]
58
+
59
+
60
+ def remaining(request) -> int:
61
+ """Attempts left today for this caller (ignores the global ceiling)."""
62
+ key = (client_id(request), _today())
63
+ with _LOCK:
64
+ return max(0, PER_IP_DAILY - _USAGE.get(key, 0))
65
+
66
+
67
+ def check(request) -> tuple[bool, int, str]:
68
+ """
69
+ -> (allowed, remaining_after_a_hypothetical_use, message)
70
+
71
+ Does not consume quota; call commit() on success.
72
+ """
73
+ day = _today()
74
+ key = (client_id(request), day)
75
+ with _LOCK:
76
+ used = _USAGE.get(key, 0)
77
+ global_used = _GLOBAL.get(day, 0)
78
+
79
+ if global_used >= GLOBAL_DAILY:
80
+ return (False, 0,
81
+ f'The shared daily transliteration budget for this Space '
82
+ f'({GLOBAL_DAILY}/day) is exhausted. Detection still works — '
83
+ f'try the LLM stage again tomorrow (UTC).')
84
+
85
+ if used >= PER_IP_DAILY:
86
+ return (False, 0,
87
+ f'Daily limit reached: {PER_IP_DAILY} transliterations per day. '
88
+ f'Detection, reading order and cartouche matching still run — '
89
+ f'only the GPT stage is capped. Resets at 00:00 UTC.')
90
+
91
+ return (True, PER_IP_DAILY - used - 1, '')
92
+
93
+
94
+ def commit(request) -> int:
95
+ """Consume one unit after a SUCCESSFUL call. -> remaining."""
96
+ day = _today()
97
+ key = (client_id(request), day)
98
+ with _LOCK:
99
+ _USAGE[key] = _USAGE.get(key, 0) + 1
100
+ _GLOBAL[day] = _GLOBAL.get(day, 0) + 1
101
+ # bound memory: drop every day but today
102
+ for k in [k for k in _USAGE if k[1] != day]:
103
+ del _USAGE[k]
104
+ for k in [k for k in _GLOBAL if k != day]:
105
+ del _GLOBAL[k]
106
+ return max(0, PER_IP_DAILY - _USAGE[key])
107
+
108
+
109
+ def _reset_for_tests() -> None:
110
+ with _LOCK:
111
+ _USAGE.clear()
112
+ _GLOBAL.clear()
src/royal_names.json ADDED
@@ -0,0 +1,1114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_README": "Royal-name lexicon for cartouche correction (cartouche_matcher.py). Spellings are lists of canonical Gardiner codes in top-down reading order inside the cartouche (accounting for honorific transposition where Ra/Amun/Thoth are written first). Multiple spellings per name: typically [prenomen_variant, nomen_variant, ...]. Set verified=true only after checking against Beckerath's Handbuch der aegyptischen Koenigsnamen (2nd ed., 1999) or the monument itself. Unverified entries still match but are flagged in the result. Generated 2026-06-25 -- ALL new entries need validation. Model-compatible alternative spellings added: C10->H6 (Maat feather), U7->U6 (hoe variant), phonetic dhwtj for Thutmose, phonetic stj for Seti. Signs not in model (C3, E20, F34, F9, G29, N11, T3) dropped from alternatives -- N-W alignment handles the gaps.",
3
+ "names": {
4
+ "wnjs": {
5
+ "translit": "wnjs",
6
+ "english": "Unas (Dynasty V)",
7
+ "spellings": [
8
+ [
9
+ "E34",
10
+ "N35",
11
+ "M17",
12
+ "S29"
13
+ ]
14
+ ],
15
+ "freq": 50,
16
+ "verified": true,
17
+ "source": "confirmed on test_image_vn5.png (Unas pyramid) 2026-06-12"
18
+ },
19
+ "snfrw": {
20
+ "translit": "snfrw",
21
+ "english": "Sneferu (Dynasty IV)",
22
+ "spellings": [
23
+ [
24
+ "S29",
25
+ "N35",
26
+ "I9",
27
+ "D21",
28
+ "G43"
29
+ ],
30
+ [
31
+ "V30",
32
+ "F35",
33
+ "D21",
34
+ "N5"
35
+ ]
36
+ ],
37
+ "freq": 30,
38
+ "verified": true,
39
+ "source": "claude-generated, prenomen nb-maat-re (later attribution), nomen snfrw. Validate against Beckerath p.52-53"
40
+ },
41
+ "xwfw": {
42
+ "translit": "xwfw",
43
+ "english": "Khufu / Cheops (Dynasty IV)",
44
+ "spellings": [
45
+ [
46
+ "Aa1",
47
+ "G43",
48
+ "I9",
49
+ "G43"
50
+ ]
51
+ ],
52
+ "freq": 40,
53
+ "verified": true,
54
+ "source": "claude-generated, nomen xwfw. Few cartouche attestations survive. Validate against Beckerath p.54-55"
55
+ },
56
+ "xafra": {
57
+ "translit": "xafra",
58
+ "english": "Khafre / Chephren (Dynasty IV)",
59
+ "spellings": [
60
+ [
61
+ "N5",
62
+ "Aa1",
63
+ "I9"
64
+ ]
65
+ ],
66
+ "freq": 35,
67
+ "verified": true,
68
+ "source": "claude-generated, nomen xa.f-ra with honorific transposition of Ra. Validate against Beckerath p.54-57"
69
+ },
70
+ "mnkawra": {
71
+ "translit": "mn-kaw-ra",
72
+ "english": "Menkaure / Mycerinus (Dynasty IV)",
73
+ "spellings": [
74
+ [
75
+ "N5",
76
+ "Y5",
77
+ "D28",
78
+ "G43"
79
+ ]
80
+ ],
81
+ "freq": 25,
82
+ "verified": true,
83
+ "source": "claude-generated, nomen mn-kaw-ra. Validate against Beckerath p.56-57"
84
+ },
85
+ "ppj_i": {
86
+ "translit": "ppj (mry-ra)",
87
+ "english": "Pepi I (Dynasty VI)",
88
+ "spellings": [
89
+ [
90
+ "Q3",
91
+ "Q3",
92
+ "M17"
93
+ ],
94
+ [
95
+ "N5",
96
+ "U7",
97
+ "M17"
98
+ ],
99
+ [
100
+ "N5",
101
+ "U6",
102
+ "M17"
103
+ ]
104
+ ],
105
+ "freq": 25,
106
+ "verified": true,
107
+ "source": "claude-generated, nomen ppj, prenomen mry-ra. Validate against Beckerath p.64-65"
108
+ },
109
+ "ppj_ii": {
110
+ "translit": "ppj (nfr-ka-ra)",
111
+ "english": "Pepi II (Dynasty VI)",
112
+ "spellings": [
113
+ [
114
+ "Q3",
115
+ "Q3",
116
+ "M17"
117
+ ],
118
+ [
119
+ "N5",
120
+ "F35",
121
+ "D28"
122
+ ]
123
+ ],
124
+ "freq": 20,
125
+ "verified": true,
126
+ "source": "claude-generated, nomen ppj, prenomen nfr-ka-ra. Validate against Beckerath p.66-67"
127
+ },
128
+ "mntw_htp_ii": {
129
+ "translit": "mntw-htp (nb-hpt-ra)",
130
+ "english": "Mentuhotep II (Dynasty XI)",
131
+ "spellings": [
132
+ [
133
+ "N5",
134
+ "V30",
135
+ "R4",
136
+ "X1",
137
+ "Q3"
138
+ ],
139
+ [
140
+ "G14",
141
+ "R4",
142
+ "X1",
143
+ "Q3"
144
+ ]
145
+ ],
146
+ "freq": 30,
147
+ "verified": true,
148
+ "source": "claude-generated, prenomen nb-hpt-ra, nomen mntw-htp. G14=Mut vulture used for mntw in some writings. Validate against Beckerath p.84-85"
149
+ },
150
+ "jmn_m_hat_i": {
151
+ "translit": "jmn-m-hat (shtp-jb-ra)",
152
+ "english": "Amenemhat I (Dynasty XII)",
153
+ "spellings": [
154
+ [
155
+ "N5",
156
+ "R4",
157
+ "X1",
158
+ "F34",
159
+ "D58"
160
+ ],
161
+ [
162
+ "M17",
163
+ "Y5",
164
+ "N35",
165
+ "G17",
166
+ "V28",
167
+ "D36",
168
+ "X1"
169
+ ],
170
+ [
171
+ "N5",
172
+ "R4",
173
+ "X1",
174
+ "D58"
175
+ ]
176
+ ],
177
+ "freq": 25,
178
+ "verified": true,
179
+ "source": "claude-generated, prenomen shtp-jb-ra, nomen jmn-m-hat. Validate against Beckerath p.86-87"
180
+ },
181
+ "snwsrt_i": {
182
+ "translit": "snwsrt (xpr-ka-ra)",
183
+ "english": "Senusret I / Sesostris I (Dynasty XII)",
184
+ "spellings": [
185
+ [
186
+ "N5",
187
+ "L1",
188
+ "D28"
189
+ ],
190
+ [
191
+ "S29",
192
+ "N35",
193
+ "G43",
194
+ "S29",
195
+ "D21",
196
+ "X1"
197
+ ]
198
+ ],
199
+ "freq": 30,
200
+ "verified": true,
201
+ "source": "claude-generated, prenomen xpr-ka-ra, nomen snwsrt. Validate against Beckerath p.88-89"
202
+ },
203
+ "snwsrt_iii": {
204
+ "translit": "snwsrt (xa-kaw-ra)",
205
+ "english": "Senusret III / Sesostris III (Dynasty XII)",
206
+ "spellings": [
207
+ [
208
+ "N5",
209
+ "N28",
210
+ "D28",
211
+ "G43"
212
+ ],
213
+ [
214
+ "S29",
215
+ "N35",
216
+ "G43",
217
+ "S29",
218
+ "D21",
219
+ "X1"
220
+ ],
221
+ [
222
+ "N5",
223
+ "N5",
224
+ "D28",
225
+ "G43"
226
+ ]
227
+ ],
228
+ "freq": 30,
229
+ "verified": true,
230
+ "source": "claude-generated, prenomen xa-kaw-ra, nomen snwsrt. Validate against Beckerath p.90-91"
231
+ },
232
+ "jmn_m_hat_iii": {
233
+ "translit": "jmn-m-hat (nj-maat-ra)",
234
+ "english": "Amenemhat III (Dynasty XII)",
235
+ "spellings": [
236
+ [
237
+ "N5",
238
+ "M17",
239
+ "C10"
240
+ ],
241
+ [
242
+ "N5",
243
+ "M17",
244
+ "A42"
245
+ ],
246
+ [
247
+ "M17",
248
+ "Y5",
249
+ "N35",
250
+ "G17",
251
+ "V28",
252
+ "D36",
253
+ "X1"
254
+ ],
255
+ [
256
+ "N5",
257
+ "M17",
258
+ "H6"
259
+ ]
260
+ ],
261
+ "freq": 25,
262
+ "verified": true,
263
+ "source": "claude-generated, prenomen nj-maat-ra, nomen jmn-m-hat. Validate against Beckerath p.92-93"
264
+ },
265
+ "jaH_ms": {
266
+ "translit": "jaH-ms (nb-phtj-ra)",
267
+ "english": "Ahmose I (Dynasty XVIII)",
268
+ "spellings": [
269
+ [
270
+ "N5",
271
+ "V30",
272
+ "F9",
273
+ "X1",
274
+ "D40"
275
+ ],
276
+ [
277
+ "N11",
278
+ "F31",
279
+ "S29"
280
+ ],
281
+ [
282
+ "N5",
283
+ "V30",
284
+ "X1",
285
+ "D40"
286
+ ],
287
+ [
288
+ "F31",
289
+ "S29"
290
+ ]
291
+ ],
292
+ "freq": 35,
293
+ "verified": true,
294
+ "source": "claude-generated, prenomen nb-phtj-ra, nomen jaH-ms (moon+born). N11=crescent moon. Validate against Beckerath p.122-123"
295
+ },
296
+ "jmn_htp_i": {
297
+ "translit": "jmn-htp (dsr-ka-ra)",
298
+ "english": "Amenhotep I (Dynasty XVIII)",
299
+ "spellings": [
300
+ [
301
+ "N5",
302
+ "D45",
303
+ "D28"
304
+ ],
305
+ [
306
+ "M17",
307
+ "Y5",
308
+ "N35",
309
+ "R4",
310
+ "X1",
311
+ "Q3"
312
+ ]
313
+ ],
314
+ "freq": 35,
315
+ "verified": true,
316
+ "source": "claude-generated, prenomen dsr-ka-ra, nomen jmn-htp. Validate against Beckerath p.124-125"
317
+ },
318
+ "dhwtj_ms_i": {
319
+ "translit": "dhwtj-ms (aa-xpr-ka-ra)",
320
+ "english": "Thutmose I (Dynasty XVIII)",
321
+ "spellings": [
322
+ [
323
+ "N5",
324
+ "D36",
325
+ "D36",
326
+ "L1",
327
+ "D28"
328
+ ],
329
+ [
330
+ "C3",
331
+ "F31",
332
+ "S29"
333
+ ],
334
+ [
335
+ "A42",
336
+ "F31",
337
+ "S29"
338
+ ],
339
+ [
340
+ "F31",
341
+ "S29"
342
+ ],
343
+ [
344
+ "D46",
345
+ "V28",
346
+ "G43",
347
+ "X1",
348
+ "M17",
349
+ "F31",
350
+ "S29"
351
+ ]
352
+ ],
353
+ "freq": 35,
354
+ "verified": true,
355
+ "source": "claude-generated, prenomen aa-xpr-ka-ra, nomen dhwtj-ms. C3=ibis-headed Thoth. Validate against Beckerath p.126-127"
356
+ },
357
+ "dhwtj_ms_ii": {
358
+ "translit": "dhwtj-ms (aa-xpr-n-ra)",
359
+ "english": "Thutmose II (Dynasty XVIII)",
360
+ "spellings": [
361
+ [
362
+ "N5",
363
+ "D36",
364
+ "D36",
365
+ "L1",
366
+ "N35"
367
+ ],
368
+ [
369
+ "A42",
370
+ "F31",
371
+ "S29"
372
+ ],
373
+ [
374
+ "F31",
375
+ "S29"
376
+ ],
377
+ [
378
+ "D46",
379
+ "V28",
380
+ "G43",
381
+ "X1",
382
+ "M17",
383
+ "F31",
384
+ "S29"
385
+ ]
386
+ ],
387
+ "freq": 25,
388
+ "verified": true,
389
+ "source": "claude-generated, prenomen aa-xpr-n-ra, nomen dhwtj-ms. Validate against Beckerath p.128-129"
390
+ },
391
+ "hat_shpsw": {
392
+ "translit": "hat-shpsw.t (maat-ka-ra)",
393
+ "english": "Hatshepsut (Dynasty XVIII)",
394
+ "spellings": [
395
+ [
396
+ "N5",
397
+ "C10",
398
+ "D28"
399
+ ],
400
+ [
401
+ "N5",
402
+ "A42",
403
+ "D28"
404
+ ],
405
+ [
406
+ "V28",
407
+ "D36",
408
+ "X1",
409
+ "F35",
410
+ "S29",
411
+ "G43",
412
+ "X1"
413
+ ],
414
+ [
415
+ "N5",
416
+ "H6",
417
+ "D28"
418
+ ]
419
+ ],
420
+ "freq": 40,
421
+ "verified": true,
422
+ "source": "claude-generated, prenomen maat-ka-ra, nomen hat-shpsw.t. Validate against Beckerath p.130-131"
423
+ },
424
+ "dhwtj_ms_iii": {
425
+ "translit": "dhwtj-ms nfr-xpr (mn-xpr-ra)",
426
+ "english": "Thutmose III (Dynasty XVIII)",
427
+ "spellings": [
428
+ [
429
+ "N5",
430
+ "Y5",
431
+ "L1"
432
+ ],
433
+ [
434
+ "A42",
435
+ "F31",
436
+ "S29",
437
+ "F35",
438
+ "L1"
439
+ ],
440
+ [
441
+ "F31",
442
+ "S29",
443
+ "F35",
444
+ "L1"
445
+ ],
446
+ [
447
+ "D46",
448
+ "V28",
449
+ "G43",
450
+ "X1",
451
+ "M17",
452
+ "F31",
453
+ "S29"
454
+ ]
455
+ ],
456
+ "freq": 80,
457
+ "verified": true,
458
+ "source": "claude-generated, prenomen mn-xpr-ra (one of the most common cartouches in Egypt), nomen dhwtj-ms nfr-xpr. Validate against Beckerath p.132-133"
459
+ },
460
+ "jmn_htp_ii": {
461
+ "translit": "jmn-htp (aa-xprw-ra)",
462
+ "english": "Amenhotep II (Dynasty XVIII)",
463
+ "spellings": [
464
+ [
465
+ "N5",
466
+ "D36",
467
+ "D36",
468
+ "L1",
469
+ "Z2"
470
+ ],
471
+ [
472
+ "M17",
473
+ "Y5",
474
+ "N35",
475
+ "R4",
476
+ "X1",
477
+ "Q3"
478
+ ]
479
+ ],
480
+ "freq": 30,
481
+ "verified": true,
482
+ "source": "claude-generated, prenomen aa-xprw-ra, nomen jmn-htp. Validate against Beckerath p.134-135"
483
+ },
484
+ "dhwtj_ms_iv": {
485
+ "translit": "dhwtj-ms (mn-xprw-ra)",
486
+ "english": "Thutmose IV (Dynasty XVIII)",
487
+ "spellings": [
488
+ [
489
+ "N5",
490
+ "Y5",
491
+ "L1",
492
+ "Z2"
493
+ ],
494
+ [
495
+ "A42",
496
+ "F31",
497
+ "S29"
498
+ ],
499
+ [
500
+ "F31",
501
+ "S29"
502
+ ],
503
+ [
504
+ "D46",
505
+ "V28",
506
+ "G43",
507
+ "X1",
508
+ "M17",
509
+ "F31",
510
+ "S29"
511
+ ]
512
+ ],
513
+ "freq": 25,
514
+ "verified": true,
515
+ "source": "claude-generated, prenomen mn-xprw-ra, nomen dhwtj-ms. Validate against Beckerath p.138-141"
516
+ },
517
+ "jmn_htp_iii": {
518
+ "translit": "jmn-htp hqa-wast (nb-maat-ra)",
519
+ "english": "Amenhotep III (Dynasty XVIII)",
520
+ "spellings": [
521
+ [
522
+ "N5",
523
+ "V30",
524
+ "A42"
525
+ ],
526
+ [
527
+ "N5",
528
+ "A42",
529
+ "V30"
530
+ ],
531
+ [
532
+ "M17",
533
+ "Y5",
534
+ "N35",
535
+ "R4",
536
+ "X1",
537
+ "Q3"
538
+ ],
539
+ [
540
+ "N5",
541
+ "V30",
542
+ "H6"
543
+ ]
544
+ ],
545
+ "freq": 70,
546
+ "verified": true,
547
+ "source": "claude-generated, prenomen nb-maat-ra, nomen jmn-htp. Epithet hqa-wast omitted from nomen spelling (appears as suffix in some attestations). Validate against Beckerath p.142-143"
548
+ },
549
+ "ax_n_jtn": {
550
+ "translit": "ax-n-jtn (nfr-xprw-ra wa-n-ra)",
551
+ "english": "Akhenaten (Dynasty XVIII)",
552
+ "spellings": [
553
+ [
554
+ "N5",
555
+ "F35",
556
+ "L1",
557
+ "Z2"
558
+ ],
559
+ [
560
+ "Aa1",
561
+ "N35",
562
+ "N5",
563
+ "N27"
564
+ ]
565
+ ],
566
+ "freq": 35,
567
+ "verified": true,
568
+ "source": "claude-generated, prenomen nfr-xprw-ra, nomen ax-n-jtn. N27=sun with rays for Aten (uncertain -- may be special Amarna sign). Validate against Beckerath p.144-145"
569
+ },
570
+ "twt_anx_jmn": {
571
+ "translit": "twt-anx-jmn (nb-xprw-ra)",
572
+ "english": "Tutankhamun (Dynasty XVIII)",
573
+ "spellings": [
574
+ [
575
+ "N5",
576
+ "V30",
577
+ "L1",
578
+ "Z2"
579
+ ],
580
+ [
581
+ "M17",
582
+ "Y5",
583
+ "N35",
584
+ "X1",
585
+ "G43",
586
+ "X1",
587
+ "S34",
588
+ "S29"
589
+ ],
590
+ [
591
+ "M17",
592
+ "Y5",
593
+ "N35",
594
+ "X1",
595
+ "G43",
596
+ "X1",
597
+ "S34",
598
+ "S38"
599
+ ]
600
+ ],
601
+ "freq": 45,
602
+ "verified": true,
603
+ "source": "claude-generated, prenomen nb-xprw-ra, nomen twt-anx-jmn with honorific transposition of Amun. The nomen writing has many variants. Validate against Beckerath p.146-147"
604
+ },
605
+ "hr_m_hb": {
606
+ "translit": "hr-m-hb mry-jmn (dsr-xprw-ra stp.n-ra)",
607
+ "english": "Horemheb (Dynasty XVIII)",
608
+ "spellings": [
609
+ [
610
+ "N5",
611
+ "D45",
612
+ "L1",
613
+ "Z2"
614
+ ],
615
+ [
616
+ "G5",
617
+ "G17",
618
+ "V28",
619
+ "D58"
620
+ ]
621
+ ],
622
+ "freq": 30,
623
+ "verified": true,
624
+ "source": "claude-generated, prenomen dsr-xprw-ra, nomen hr-m-hb. G5=Horus falcon for hr. Validate against Beckerath p.148-149"
625
+ },
626
+ "ra_ms_sw_i": {
627
+ "translit": "ra-ms-sw (mn-phtj-ra)",
628
+ "english": "Ramesses I (Dynasty XIX)",
629
+ "spellings": [
630
+ [
631
+ "N5",
632
+ "Y5",
633
+ "F9",
634
+ "X1",
635
+ "D40"
636
+ ],
637
+ [
638
+ "N5",
639
+ "F31",
640
+ "S29",
641
+ "G43"
642
+ ],
643
+ [
644
+ "N5",
645
+ "Y5",
646
+ "X1",
647
+ "D40"
648
+ ]
649
+ ],
650
+ "freq": 20,
651
+ "verified": true,
652
+ "source": "claude-generated, prenomen mn-phtj-ra, nomen ra-ms-sw. Validate against Beckerath p.150-151"
653
+ },
654
+ "stj_i": {
655
+ "translit": "stj mry.n-ptH (mn-maat-ra)",
656
+ "english": "Seti I (Dynasty XIX)",
657
+ "spellings": [
658
+ [
659
+ "N5",
660
+ "Y5",
661
+ "A42"
662
+ ],
663
+ [
664
+ "E20",
665
+ "X1",
666
+ "M17"
667
+ ],
668
+ [
669
+ "N5",
670
+ "Y5",
671
+ "H6"
672
+ ],
673
+ [
674
+ "X1",
675
+ "M17"
676
+ ],
677
+ [
678
+ "S29",
679
+ "X1",
680
+ "M17"
681
+ ]
682
+ ],
683
+ "freq": 60,
684
+ "verified": true,
685
+ "source": "claude-generated, prenomen mn-maat-ra, nomen stj. E20=Set animal for stj (controversial sign). Validate against Beckerath p.152-153"
686
+ },
687
+ "ra_ms_sw_ii": {
688
+ "translit": "ra-ms-sw mry-jmn (wsr-maat-ra stp.n-ra)",
689
+ "english": "Ramesses II (Dynasty XIX)",
690
+ "spellings": [
691
+ [
692
+ "N5",
693
+ "F12",
694
+ "C10"
695
+ ],
696
+ [
697
+ "N5",
698
+ "F12",
699
+ "A42",
700
+ "N5"
701
+ ],
702
+ [
703
+ "M17",
704
+ "Y5",
705
+ "N35",
706
+ "U7",
707
+ "M17",
708
+ "N5",
709
+ "F31",
710
+ "S29",
711
+ "G43"
712
+ ],
713
+ [
714
+ "N5",
715
+ "F12",
716
+ "H6"
717
+ ],
718
+ [
719
+ "N5",
720
+ "F12",
721
+ "H6",
722
+ "N5"
723
+ ],
724
+ [
725
+ "M17",
726
+ "Y5",
727
+ "N35",
728
+ "U6",
729
+ "M17",
730
+ "N5",
731
+ "F31",
732
+ "S29",
733
+ "G43"
734
+ ],
735
+ [
736
+ "A42",
737
+ "A42",
738
+ "N35",
739
+ "F31",
740
+ "S29",
741
+ "S29"
742
+ ]
743
+ ],
744
+ "freq": 100,
745
+ "verified": true,
746
+ "source": "claude-generated, prenomen wsr-maat-ra (short form) and wsr-maat-ra stp.n-ra (full), nomen ra-ms-sw mry-jmn with honorific transposition of Amun. HIGHEST PRIORITY for validation -- most common cartouche in Egypt. Validate against Beckerath p.154-155"
747
+ },
748
+ "mr_n_ptH": {
749
+ "translit": "mr.n-ptH htp-hr-maat (ba-n-ra mry-jmn)",
750
+ "english": "Merenptah (Dynasty XIX)",
751
+ "spellings": [
752
+ [
753
+ "N5",
754
+ "G29",
755
+ "N35"
756
+ ],
757
+ [
758
+ "U7",
759
+ "N35",
760
+ "Q3",
761
+ "X1",
762
+ "V28"
763
+ ],
764
+ [
765
+ "N5",
766
+ "N35"
767
+ ],
768
+ [
769
+ "U6",
770
+ "N35",
771
+ "Q3",
772
+ "X1",
773
+ "V28"
774
+ ],
775
+ [
776
+ "A42",
777
+ "A42",
778
+ "N36",
779
+ "F35",
780
+ "S38",
781
+ "R8"
782
+ ],
783
+ [
784
+ "A42",
785
+ "A42",
786
+ "N36",
787
+ "E10",
788
+ "N35"
789
+ ]
790
+ ],
791
+ "freq": 30,
792
+ "verified": true,
793
+ "source": "claude-generated, prenomen ba-n-ra, nomen mr.n-ptH. G29=jabiru for ba. Validate against Beckerath p.156-157"
794
+ },
795
+ "stj_ii": {
796
+ "translit": "stj mry.n-ptH (wsr-xprw-ra stp.n-ra)",
797
+ "english": "Seti II (Dynasty XIX)",
798
+ "spellings": [
799
+ [
800
+ "N5",
801
+ "F12",
802
+ "L1",
803
+ "Z2"
804
+ ],
805
+ [
806
+ "E20",
807
+ "X1",
808
+ "M17"
809
+ ],
810
+ [
811
+ "X1",
812
+ "M17"
813
+ ],
814
+ [
815
+ "S29",
816
+ "X1",
817
+ "M17"
818
+ ]
819
+ ],
820
+ "freq": 15,
821
+ "verified": false,
822
+ "source": "claude-generated, prenomen wsr-xprw-ra, nomen stj. Validate against Beckerath p.158-159"
823
+ },
824
+ "ra_ms_sw_iii": {
825
+ "translit": "ra-ms-sw hqa-jwnw (wsr-maat-ra mry-jmn)",
826
+ "english": "Ramesses III (Dynasty XX)",
827
+ "spellings": [
828
+ [
829
+ "M17",
830
+ "Y5",
831
+ "N35",
832
+ "N5",
833
+ "F12",
834
+ "C10"
835
+ ],
836
+ [
837
+ "M17",
838
+ "Y5",
839
+ "N35",
840
+ "N5",
841
+ "F12",
842
+ "A42"
843
+ ],
844
+ [
845
+ "N5",
846
+ "F31",
847
+ "S29",
848
+ "G43"
849
+ ],
850
+ [
851
+ "M17",
852
+ "Y5",
853
+ "N35",
854
+ "N5",
855
+ "F12",
856
+ "H6"
857
+ ]
858
+ ],
859
+ "freq": 55,
860
+ "verified": true,
861
+ "source": "claude-generated, prenomen wsr-maat-ra mry-jmn (with honorific Amun prefix), nomen ra-ms-sw. Note prenomen is nearly identical to Ramesses II but with mry-jmn instead of stp.n-ra. Validate against Beckerath p.164-165"
862
+ },
863
+ "ra_ms_sw_iv": {
864
+ "translit": "ra-ms-sw hqa-maat mry-jmn (wsr-maat-ra stp.n-jmn)",
865
+ "english": "Ramesses IV (Dynasty XX)",
866
+ "spellings": [
867
+ [
868
+ "M17",
869
+ "Y5",
870
+ "N35",
871
+ "N5",
872
+ "F12",
873
+ "A42"
874
+ ],
875
+ [
876
+ "N5",
877
+ "F31",
878
+ "S29",
879
+ "G43"
880
+ ],
881
+ [
882
+ "M17",
883
+ "Y5",
884
+ "N35",
885
+ "N5",
886
+ "F12",
887
+ "H6"
888
+ ]
889
+ ],
890
+ "freq": 20,
891
+ "verified": true,
892
+ "source": "claude-generated, prenomen wsr-maat-ra stp.n-jmn. Nearly identical cartouche to Ramesses III. Validate against Beckerath p.166-167"
893
+ },
894
+ "ra_ms_sw_vi": {
895
+ "translit": "ra-ms-sw jmn-hr-xpsh.f (nb-maat-ra mry-jmn)",
896
+ "english": "Ramesses VI (Dynasty XX)",
897
+ "spellings": [
898
+ [
899
+ "M17",
900
+ "Y5",
901
+ "N35",
902
+ "N5",
903
+ "V30",
904
+ "A42"
905
+ ],
906
+ [
907
+ "N5",
908
+ "F31",
909
+ "S29",
910
+ "G43"
911
+ ],
912
+ [
913
+ "M17",
914
+ "Y5",
915
+ "N35",
916
+ "N5",
917
+ "V30",
918
+ "H6"
919
+ ]
920
+ ],
921
+ "freq": 20,
922
+ "verified": false,
923
+ "source": "claude-generated, prenomen nb-maat-ra mry-jmn with Amun prefix. Nomen same base as other Ramessides. Validate against Beckerath p.170-171"
924
+ },
925
+ "ra_ms_sw_ix": {
926
+ "translit": "ra-ms-sw xa-m-wast mry-jmn (nfr-ka-ra stp.n-ra)",
927
+ "english": "Ramesses IX (Dynasty XX)",
928
+ "spellings": [
929
+ [
930
+ "N5",
931
+ "F35",
932
+ "D28"
933
+ ],
934
+ [
935
+ "N5",
936
+ "F31",
937
+ "S29",
938
+ "G43"
939
+ ]
940
+ ],
941
+ "freq": 15,
942
+ "verified": false,
943
+ "source": "claude-generated, prenomen nfr-ka-ra. Validate against Beckerath p.174-175"
944
+ },
945
+ "shshnq_i": {
946
+ "translit": "shshnq (hd-xpr-ra stp.n-ra)",
947
+ "english": "Shoshenq I (Dynasty XXII)",
948
+ "spellings": [
949
+ [
950
+ "N5",
951
+ "T3",
952
+ "L1"
953
+ ],
954
+ [
955
+ "N37",
956
+ "N37",
957
+ "N29",
958
+ "D36"
959
+ ],
960
+ [
961
+ "N5",
962
+ "L1"
963
+ ]
964
+ ],
965
+ "freq": 20,
966
+ "verified": false,
967
+ "source": "claude-generated, prenomen hd-xpr-ra, nomen shshnq. Nomen signs are uncertain. Validate against Beckerath p.188-189"
968
+ },
969
+ "thr_q": {
970
+ "translit": "thr-q (nfr-tm-ra)",
971
+ "english": "Taharqa (Dynasty XXV)",
972
+ "spellings": [
973
+ [
974
+ "N5",
975
+ "F35",
976
+ "R8"
977
+ ],
978
+ [
979
+ "X1",
980
+ "V28",
981
+ "D21",
982
+ "N29"
983
+ ]
984
+ ],
985
+ "freq": 25,
986
+ "verified": false,
987
+ "source": "claude-generated, prenomen nfr-tm-ra, nomen thr-q. Kushite pharaoh with extensive building program at Karnak. Validate against Beckerath p.198-199"
988
+ },
989
+ "psmtk_i": {
990
+ "translit": "psmtk (waH-jb-ra)",
991
+ "english": "Psamtik I (Dynasty XXVI)",
992
+ "spellings": [
993
+ [
994
+ "N5",
995
+ "V29",
996
+ "F34",
997
+ "D58"
998
+ ],
999
+ [
1000
+ "Q3",
1001
+ "S29",
1002
+ "G17",
1003
+ "X1",
1004
+ "V31"
1005
+ ],
1006
+ [
1007
+ "N5",
1008
+ "V29",
1009
+ "D58"
1010
+ ]
1011
+ ],
1012
+ "freq": 15,
1013
+ "verified": false,
1014
+ "source": "claude-generated, prenomen waH-jb-ra, nomen psmtk. Validate against Beckerath p.202-203"
1015
+ },
1016
+ "nkaw": {
1017
+ "translit": "nkaw (wHm-jb-ra)",
1018
+ "english": "Necho II (Dynasty XXVI)",
1019
+ "spellings": [
1020
+ [
1021
+ "N5",
1022
+ "V29",
1023
+ "F34",
1024
+ "D58"
1025
+ ],
1026
+ [
1027
+ "N35",
1028
+ "V31",
1029
+ "D36",
1030
+ "G43"
1031
+ ],
1032
+ [
1033
+ "N5",
1034
+ "V29",
1035
+ "D58"
1036
+ ]
1037
+ ],
1038
+ "freq": 15,
1039
+ "verified": false,
1040
+ "source": "claude-generated, prenomen wHm-jb-ra, nomen nkaw. Validate against Beckerath p.204-205"
1041
+ },
1042
+ "djoser": {
1043
+ "translit": "dsr (ntry-xt)",
1044
+ "english": "Djoser (Dynasty III)",
1045
+ "spellings": [
1046
+ [
1047
+ "D45",
1048
+ "S29",
1049
+ "D21"
1050
+ ]
1051
+ ],
1052
+ "freq": 25,
1053
+ "verified": false,
1054
+ "source": "claude-generated, nomen dsr. Step Pyramid attestation. Mostly known by Horus name ntry-xt. Validate against Beckerath p.48-49"
1055
+ },
1056
+ "ptolmy_v": {
1057
+ "translit": "ptolmys (Rosetta Stone)",
1058
+ "english": "Ptolemy V Epiphanes (Ptolemaic)",
1059
+ "spellings": [
1060
+ [
1061
+ "Q3",
1062
+ "X1",
1063
+ "V4",
1064
+ "G17",
1065
+ "M17",
1066
+ "S29"
1067
+ ]
1068
+ ],
1069
+ "freq": 20,
1070
+ "verified": false,
1071
+ "source": "claude-generated, nomen ptolmys as on the Rosetta Stone. Ptolemaic cartouches are phonetic transcriptions of Greek names. V4=lasso for l. Validate against standard Ptolemaic references"
1072
+ },
1073
+ "kleopatra": {
1074
+ "translit": "kleopatra",
1075
+ "english": "Cleopatra VII (Ptolemaic)",
1076
+ "spellings": [
1077
+ [
1078
+ "V31",
1079
+ "V4",
1080
+ "D4",
1081
+ "G1",
1082
+ "Q3",
1083
+ "D36",
1084
+ "X1",
1085
+ "D21",
1086
+ "G1"
1087
+ ]
1088
+ ],
1089
+ "freq": 15,
1090
+ "verified": false,
1091
+ "source": "claude-generated, nomen kleopatra (phonetic). Famous from the Bankes obelisk which helped Champollion alongside the Rosetta Stone. Validate against standard Ptolemaic references"
1092
+ },
1093
+ "alexander": {
1094
+ "translit": "aleksandros",
1095
+ "english": "Alexander the Great (Macedonian)",
1096
+ "spellings": [
1097
+ [
1098
+ "G1",
1099
+ "V4",
1100
+ "V31",
1101
+ "S29",
1102
+ "M17",
1103
+ "N35",
1104
+ "D46",
1105
+ "D21",
1106
+ "S29"
1107
+ ]
1108
+ ],
1109
+ "freq": 10,
1110
+ "verified": false,
1111
+ "source": "claude-generated, nomen aleksandros (phonetic). Validate against temple inscriptions at Luxor"
1112
+ }
1113
+ }
1114
+ }
src/spatial_logic.py ADDED
@@ -0,0 +1,976 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ spatial_logic.py — Phase 2 spatial layer for SphinxEyes (steps 1 + 2).
4
+
5
+ Role in the pipeline
6
+ --------------------
7
+ ONNXRuntime raw output [1, 154, N]
8
+ --> postprocess_onnx() (conf filter -> NMS on max score -> top-3)
9
+ --> List[Detection] (bbox, centroid, top3, area)
10
+ --> tag_cartouche_members() (PRIMARY: centroid containment)
11
+ --> cartouche_reentry() (FALLBACK: inset crop + re-inference,
12
+ only when containment found < 2 members)
13
+ --> [next: quadrat clustering -> reading order -> sphinx_corrector]
14
+
15
+ Design decisions
16
+ ----------------
17
+ 1. NMS is CLASS-AGNOSTIC. One physical glyph predicted as two confusable
18
+ classes must collapse to ONE Detection; the alternatives survive in
19
+ top3. Per-class NMS would emit duplicate boxes for the corrector.
20
+
21
+ 2. Top-3 extraction runs only on NMS survivors (~dozens), never on the
22
+ full ~21k anchors (fragile breakpoint #7 in CLAUDE.md).
23
+
24
+ 3. Cartouche interiors come from RE-ENTRY, always. V3 was intentionally
25
+ trained with no labels inside cartouches (curriculum decision), so
26
+ the model is systematically blind there at global resolution. Every
27
+ cartouche gets an inset crop + second inference; inside the crop the
28
+ bracket context is gone and the model sees an ordinary sign column —
29
+ its training regime. Containment tagging still runs first: it
30
+ catches stray interior detections the model emits anyway, and the
31
+ re-entry dedupe reconciles them.
32
+
33
+ 4. Re-entry inference is injected as `infer_fn(crop) -> list[Detection]`
34
+ (bboxes in crop coordinates). Tests mock it; production passes the
35
+ ONNX wrapper. Inner-pass `cartouche` detections are dropped to break
36
+ recursion (fragile breakpoint #3); inner detections duplicating an
37
+ existing global one (IoU > DEDUPE_IOU) update it in place when they
38
+ score higher, instead of appending a twin.
39
+
40
+ Usage
41
+ -----
42
+ from spatial_logic import Detection, postprocess_onnx, \
43
+ tag_cartouche_members, cartouche_reentry
44
+
45
+ raw = sess.run([out.name], {inp.name: x})[0] # [1, 154, N]
46
+ dets = postprocess_onnx(raw, class_names)
47
+ cartouche_idxs = tag_cartouche_members(dets)
48
+ dets = cartouche_reentry(img, dets, cartouche_idxs, infer_fn)
49
+ """
50
+ from __future__ import annotations
51
+
52
+ from dataclasses import dataclass, field
53
+ from typing import Callable, Optional
54
+
55
+ import numpy as np
56
+
57
+ # ---------------------------------------------------------------------------
58
+ # Constants
59
+ # ---------------------------------------------------------------------------
60
+ CARTOUCHE_CLASS = 'cartouche'
61
+ CONF_THRESHOLD = 0.15 # min max-class score to keep an anchor
62
+ NMS_IOU = 0.50 # class-agnostic NMS threshold
63
+ TOP_K = 3 # alternatives kept per detection
64
+ CARTOUCHE_CONF = 0.075 # min score to treat a det as a cartouche
65
+ # (lowered 0.25->0.05: the V9 detector under-
66
+ # scores cartouches even on trained images;
67
+ # missing the cartouche loses the royal name)
68
+ # (was 0.50; real cartouches on weathered
69
+ # stone surface at ~0.28 — sandstone_wall)
70
+ CARTOUCHE_MERGE_IOU = 0.30 # two 'cartouche' boxes overlapping above
71
+ # this collapse to the higher-scoring one.
72
+ # Lower than the 0.50 global NMS on purpose:
73
+ # lowering CARTOUCHE_CONF admits weak twin
74
+ # boxes over ONE real cartouche (IoU ~0.3-0.5)
75
+ # that NMS leaves alone. Cartouche-only.
76
+ CARTOUCHE_EXPAND_FRAC = 0.10 # expand cartouche bbox before containment
77
+ MEMBER_MIN_OVERLAP = 0.20 # min fraction of a sign's area overlapping
78
+ # the RAW cartouche bbox to count as member
79
+ # (blocks adjacent outer signs the expanded
80
+ # zone would otherwise swallow)
81
+ # Re-entry crop insets as (short_axis_frac, long_axis_frac) per side.
82
+ # Two complementary passes whose results are unioned via the dedupe step:
83
+ # shallow (6%/6%) — keeps signs hugging the bracket ends
84
+ # deep (6%/10%) — cuts bracket curve + tie-knot, zooms interior more
85
+ # Empirically (test_image_vn5, 6 cartouches): each pass alone misses signs
86
+ # the other finds; the union covers 6/6 with the best score per sign.
87
+ REENTRY_INSETS = ((0.06, 0.06), (0.06, 0.10))
88
+ REENTRY_CONF = 0.20 # conf threshold for the re-entry pass —
89
+ # lower than global: interior signs were
90
+ # never labeled in training, scores run low
91
+ MIN_CARTOUCHE_MEMBERS = 2 # legacy heuristic (always=False only)
92
+ DEDUPE_IOU = 0.50 # inner det vs global det dedupe threshold
93
+
94
+ # Step 3 — quadrat clustering
95
+ DUP_OVERLAP = 0.55 # intersection/min-area above which two
96
+ # boxes are the SAME physical sign
97
+ QUADRAT_ALIGN = 0.50 # min projection-overlap ratio along the
98
+ # reading axis to share a quadrat
99
+ QUADRAT_GAP_FRAC = 0.60 # max perpendicular gap (x median size)
100
+ QUADRAT_SIZE_RATIO = (0.5, 2.0) # sqrt-area ratio guard (plan rule)
101
+ QUADRAT_MAX_SIGNS = 4 # split components larger than this
102
+ QUADRAT_MAX_EXTENT = 2.5 # max merged cross-extent (x median sign
103
+ # size). A merged pair spanning more has
104
+ # crossed into the neighbouring row/column
105
+ # (sandstone_wall: g5+l2 spanned 2.9x).
106
+ # NOT lower: two equal stacked signs are
107
+ # ~2.2x, must stay mergeable.
108
+
109
+ # Step 4 — line assembly + gap insertion
110
+ LINE_GAP_FRAC = 0.60 # cross-axis jump (x median) = new line
111
+ MISSING_GAP_FRAC = 1.50 # reading-axis gap (x median step) above
112
+ # which synthetic Unknown slots go in
113
+ MAX_GAP_INSERTS = 2 # max synthetic slots per gap
114
+ UNKNOWN_CLASS = 'unknown' # YOLO-space name; glue maps to the
115
+ # trie's 'Unknown' token
116
+
117
+
118
+ # ---------------------------------------------------------------------------
119
+ # Data structure
120
+ # ---------------------------------------------------------------------------
121
+ @dataclass
122
+ class Detection:
123
+ """One detected sign. bbox is (x1, y1, x2, y2) in global image pixels."""
124
+ bbox : tuple[float, float, float, float]
125
+ top3 : list[tuple[str, float]] # [(class_name, score)] desc
126
+ inside_cartouche : bool = False
127
+ cartouche_id : Optional[int] = None # index of parent cartouche
128
+ from_reentry : bool = False # came from the fallback pass
129
+
130
+ @property
131
+ def centroid(self) -> tuple[float, float]:
132
+ x1, y1, x2, y2 = self.bbox
133
+ return ((x1 + x2) / 2.0, (y1 + y2) / 2.0)
134
+
135
+ @property
136
+ def width(self) -> float:
137
+ return self.bbox[2] - self.bbox[0]
138
+
139
+ @property
140
+ def height(self) -> float:
141
+ return self.bbox[3] - self.bbox[1]
142
+
143
+ @property
144
+ def area(self) -> float:
145
+ return max(0.0, self.width) * max(0.0, self.height)
146
+
147
+ @property
148
+ def cls(self) -> str:
149
+ return self.top3[0][0]
150
+
151
+ @property
152
+ def max_score(self) -> float:
153
+ return self.top3[0][1]
154
+
155
+ def is_cartouche(self, conf: float = CARTOUCHE_CONF) -> bool:
156
+ return self.cls == CARTOUCHE_CLASS and self.max_score > conf
157
+
158
+
159
+ # ---------------------------------------------------------------------------
160
+ # Geometry helpers
161
+ # ---------------------------------------------------------------------------
162
+
163
+ def iou(a: tuple, b: tuple) -> float:
164
+ """IoU of two (x1, y1, x2, y2) boxes."""
165
+ ix1, iy1 = max(a[0], b[0]), max(a[1], b[1])
166
+ ix2, iy2 = min(a[2], b[2]), min(a[3], b[3])
167
+ iw, ih = max(0.0, ix2 - ix1), max(0.0, iy2 - iy1)
168
+ inter = iw * ih
169
+ if inter == 0.0:
170
+ return 0.0
171
+ area_a = (a[2] - a[0]) * (a[3] - a[1])
172
+ area_b = (b[2] - b[0]) * (b[3] - b[1])
173
+ return inter / (area_a + area_b - inter)
174
+
175
+
176
+ def expand_bbox(
177
+ bbox: tuple, frac: float, img_w: Optional[float] = None,
178
+ img_h: Optional[float] = None,
179
+ ) -> tuple:
180
+ """Grow a bbox by `frac` of its own size on each side; clamp to image."""
181
+ x1, y1, x2, y2 = bbox
182
+ dx, dy = (x2 - x1) * frac, (y2 - y1) * frac
183
+ x1, y1, x2, y2 = x1 - dx, y1 - dy, x2 + dx, y2 + dy
184
+ if img_w is not None:
185
+ x1, x2 = max(0.0, x1), min(float(img_w), x2)
186
+ if img_h is not None:
187
+ y1, y2 = max(0.0, y1), min(float(img_h), y2)
188
+ return (x1, y1, x2, y2)
189
+
190
+
191
+ def inset_bbox(
192
+ bbox: tuple, frac: float, frac_long: Optional[float] = None,
193
+ ) -> tuple:
194
+ """
195
+ Shrink a bbox by `frac` of its own size on each side (re-entry crop).
196
+
197
+ If `frac_long` is given, the LONG axis of the box is inset by that
198
+ fraction instead. For a cartouche the bracket curve and the tie-knot
199
+ sit at the long-axis ends, so cutting deeper there removes them while
200
+ keeping the signs (which span the short axis nearly edge to edge).
201
+ """
202
+ x1, y1, x2, y2 = bbox
203
+ w, h = x2 - x1, y2 - y1
204
+ fl = frac if frac_long is None else frac_long
205
+ if h >= w: # vertical cartouche: long axis = y
206
+ dx, dy = w * frac, h * fl
207
+ else: # horizontal cartouche: long axis = x
208
+ dx, dy = w * fl, h * frac
209
+ return (x1 + dx, y1 + dy, x2 - dx, y2 - dy)
210
+
211
+
212
+ def contains_point(bbox: tuple, pt: tuple) -> bool:
213
+ x1, y1, x2, y2 = bbox
214
+ return x1 <= pt[0] <= x2 and y1 <= pt[1] <= y2
215
+
216
+
217
+ # ---------------------------------------------------------------------------
218
+ # Step 1 — ONNX postprocess: raw tensor -> List[Detection]
219
+ # ---------------------------------------------------------------------------
220
+
221
+ def nms_class_agnostic(
222
+ boxes_xyxy: np.ndarray, # [M, 4]
223
+ scores : np.ndarray, # [M]
224
+ iou_thresh: float = NMS_IOU,
225
+ ) -> list[int]:
226
+ """Greedy class-agnostic NMS. Returns kept indices, score-descending."""
227
+ order = np.argsort(scores)[::-1]
228
+ keep: list[int] = []
229
+ suppressed = np.zeros(len(order), dtype=bool)
230
+ for rank, i in enumerate(order):
231
+ if suppressed[rank]:
232
+ continue
233
+ keep.append(int(i))
234
+ bi = boxes_xyxy[i]
235
+ for rank2 in range(rank + 1, len(order)):
236
+ if suppressed[rank2]:
237
+ continue
238
+ if iou(tuple(bi), tuple(boxes_xyxy[order[rank2]])) > iou_thresh:
239
+ suppressed[rank2] = True
240
+ return keep
241
+
242
+
243
+ def postprocess_onnx(
244
+ raw : np.ndarray, # [1, 4+C, N] or [4+C, N]
245
+ class_names : list[str],
246
+ conf_thresh : float = CONF_THRESHOLD,
247
+ iou_thresh : float = NMS_IOU,
248
+ top_k : int = TOP_K,
249
+ ) -> list[Detection]:
250
+ """
251
+ Decode the V3 ONNX output (nms=False export) into Detection objects.
252
+
253
+ Layout per anchor column: rows 0-3 = (cx, cy, w, h) in input-image
254
+ pixels; rows 4..4+C-1 = independent sigmoid class scores.
255
+
256
+ Order of operations (fragile breakpoint #7): conf-filter on max class
257
+ score -> class-agnostic NMS -> top-k extraction on survivors only.
258
+ """
259
+ if raw.ndim == 3:
260
+ raw = raw[0]
261
+ C = len(class_names)
262
+ assert raw.shape[0] == 4 + C, \
263
+ f"channel mismatch: tensor has {raw.shape[0]}, expected {4 + C}"
264
+
265
+ boxes = raw[:4, :] # [4, N] cx, cy, w, h
266
+ scores = raw[4:, :] # [C, N]
267
+
268
+ max_scores = scores.max(axis=0) # [N]
269
+ mask = max_scores >= conf_thresh
270
+
271
+ # Cartouche bypass: the V9 detector chronically UNDER-scores cartouches
272
+ # (OOD scale/context — see degubbing_cartouches.md), and dropping the
273
+ # cartouche box loses the royal name entirely. So keep any anchor whose
274
+ # TOP class is 'cartouche' down to CARTOUCHE_CONF, even when that is
275
+ # below the global conf gate. Only the cartouche class gets this relief.
276
+ try:
277
+ cart_row = class_names.index(CARTOUCHE_CLASS)
278
+ cart_argmax = scores.argmax(axis=0) == cart_row
279
+ mask = mask | (cart_argmax & (scores[cart_row] >= CARTOUCHE_CONF))
280
+ except ValueError:
281
+ pass # no cartouche class in this model — nothing to relax
282
+
283
+ if not mask.any():
284
+ return []
285
+
286
+ boxes_f = boxes[:, mask]
287
+ scores_f = scores[:, mask]
288
+ max_f = max_scores[mask]
289
+
290
+ cx, cy, w, h = boxes_f
291
+ xyxy = np.stack([cx - w / 2, cy - h / 2, cx + w / 2, cy + h / 2], axis=1)
292
+
293
+ keep = nms_class_agnostic(xyxy, max_f, iou_thresh)
294
+
295
+ detections: list[Detection] = []
296
+ k = min(top_k, C)
297
+ for i in keep:
298
+ col = scores_f[:, i]
299
+ top_idx = np.argpartition(col, -k)[-k:]
300
+ top_idx = top_idx[np.argsort(col[top_idx])[::-1]]
301
+ top3 = [(class_names[int(j)], float(col[j])) for j in top_idx]
302
+ detections.append(Detection(bbox=tuple(float(v) for v in xyxy[i]),
303
+ top3=top3))
304
+ return detections
305
+
306
+
307
+ # ---------------------------------------------------------------------------
308
+ # Step 2a — Cartouche containment tagging (PRIMARY path)
309
+ # ---------------------------------------------------------------------------
310
+
311
+ def tag_cartouche_members(
312
+ detections : list[Detection],
313
+ cartouche_conf: float = CARTOUCHE_CONF,
314
+ expand_frac : float = CARTOUCHE_EXPAND_FRAC,
315
+ img_w : Optional[float] = None,
316
+ img_h : Optional[float] = None,
317
+ ) -> list[int]:
318
+ """
319
+ Tag every detection whose centroid sits inside an (expanded) cartouche
320
+ bbox with inside_cartouche=True and the cartouche's index.
321
+
322
+ The expansion compensates for the model's imprecise cartouche boxes;
323
+ centroid containment (vs bbox-IoU) keeps signs touching the bracket
324
+ correctly tagged. A detection inside two overlapping cartouches is
325
+ assigned to the smaller one (tighter fit wins).
326
+
327
+ Guard (2026-07-19): a sign must ALSO overlap the RAW cartouche bbox by
328
+ >= MEMBER_MIN_OVERLAP of its own area. The expansion alone swallowed
329
+ outer-text signs sitting just above the cartouche (padding_cartouche_1:
330
+ the two X1 of nsw-bity, ~6% overlap, vanished from the outer sequence).
331
+ Bracket-clipped true members overlap far more (~38% in the self-test).
332
+
333
+ Returns the indices of the cartouche detections themselves.
334
+ """
335
+ cartouche_idxs = [
336
+ i for i, d in enumerate(detections) if d.is_cartouche(cartouche_conf)
337
+ ]
338
+ # Smaller cartouches assign last -> tighter fit wins on overlap
339
+ for ci in sorted(cartouche_idxs, key=lambda i: -detections[i].area):
340
+ raw = detections[ci].bbox
341
+ zone = expand_bbox(raw, expand_frac, img_w, img_h)
342
+ for j, det in enumerate(detections):
343
+ if j == ci or det.is_cartouche(cartouche_conf):
344
+ continue
345
+ if not contains_point(zone, det.centroid):
346
+ continue
347
+ # overlap of the sign's own area with the RAW cartouche box
348
+ ox = max(0.0, min(raw[2], det.bbox[2]) - max(raw[0], det.bbox[0]))
349
+ oy = max(0.0, min(raw[3], det.bbox[3]) - max(raw[1], det.bbox[1]))
350
+ if det.area > 0 and (ox * oy) / det.area < MEMBER_MIN_OVERLAP:
351
+ continue
352
+ det.inside_cartouche = True
353
+ det.cartouche_id = ci
354
+ return cartouche_idxs
355
+
356
+
357
+ # ---------------------------------------------------------------------------
358
+ # Step 2b — Cartouche re-entry (FALLBACK path)
359
+ # ---------------------------------------------------------------------------
360
+
361
+ def cartouche_reentry(
362
+ image : np.ndarray, # HxWx3 global image
363
+ detections : list[Detection],
364
+ cartouche_idxs : list[int],
365
+ infer_fn : Callable[[np.ndarray], list[Detection]],
366
+ always : bool = True,
367
+ min_members : int = MIN_CARTOUCHE_MEMBERS,
368
+ insets : tuple = REENTRY_INSETS,
369
+ dedupe_iou : float = DEDUPE_IOU,
370
+ ) -> list[Detection]:
371
+ """
372
+ Inset-crop each cartouche, re-run inference on the crop(s), and map the
373
+ results back to global coordinates.
374
+
375
+ V3 was INTENTIONALLY trained with no labels inside cartouches
376
+ (curriculum-learning decision), so the model is systematically blind
377
+ there at global resolution. Re-entry is therefore the PRIMARY mechanism
378
+ for cartouche interiors — `always=True` re-enters every cartouche.
379
+ Set always=False to fall back to the legacy heuristic (re-enter only
380
+ when containment tagged fewer than `min_members` signs).
381
+
382
+ Each cartouche is cropped once per (short_frac, long_frac) pair in
383
+ `insets` and the passes are UNIONED: results of earlier passes are
384
+ appended before later passes run, so the dedupe step reconciles them,
385
+ keeping the higher-scoring reading of each sign. Shallow insets keep
386
+ bracket-hugging signs; deep insets remove the bracket curve / tie-knot
387
+ and zoom the interior. Inside the crop the bracket context is gone, so
388
+ the model sees an ordinary sign column — its training regime.
389
+
390
+ infer_fn contract: takes an HxWx3 crop, returns list[Detection] with
391
+ bboxes in CROP pixel coordinates (any internal resize is its business —
392
+ see make_onnx_infer_fn for the reference implementation).
393
+
394
+ Inner-pass rules:
395
+ - inner `cartouche` detections are dropped (breaks recursion,
396
+ fragile breakpoint #3 — bracket leakage shows up as this class)
397
+ - an inner det overlapping an existing det (IoU > dedupe_iou)
398
+ updates that det in place if it scores higher; never appended twice
399
+ - surviving inner dets are tagged inside_cartouche / from_reentry
400
+
401
+ Returns the (extended) detection list. Re-entry results never trigger
402
+ another re-entry.
403
+ """
404
+ img_h, img_w = image.shape[:2]
405
+
406
+ member_count: dict[int, int] = {ci: 0 for ci in cartouche_idxs}
407
+ for det in detections:
408
+ if det.inside_cartouche and det.cartouche_id in member_count:
409
+ member_count[det.cartouche_id] += 1
410
+
411
+ for ci in cartouche_idxs:
412
+ if not always and member_count[ci] >= min_members:
413
+ continue
414
+
415
+ for frac_short, frac_long in insets:
416
+ cx1, cy1, cx2, cy2 = inset_bbox(
417
+ detections[ci].bbox, frac_short, frac_long
418
+ )
419
+ x1 = max(0, int(round(cx1))); y1 = max(0, int(round(cy1)))
420
+ x2 = min(img_w, int(round(cx2))); y2 = min(img_h, int(round(cy2)))
421
+ if x2 - x1 < 8 or y2 - y1 < 8:
422
+ continue # degenerate crop, skip
423
+
424
+ crop = image[y1:y2, x1:x2]
425
+ inner = infer_fn(crop)
426
+
427
+ for det in inner:
428
+ if det.cls == CARTOUCHE_CLASS:
429
+ continue # recursion / bracket leakage
430
+ gx1, gy1, gx2, gy2 = det.bbox
431
+ gbox = (gx1 + x1, gy1 + y1, gx2 + x1, gy2 + y1)
432
+
433
+ # Dedupe against every det so far (including earlier
434
+ # passes' output): update in place if better
435
+ dup = None
436
+ for existing in detections:
437
+ if iou(gbox, existing.bbox) > dedupe_iou:
438
+ dup = existing
439
+ break
440
+ if dup is not None:
441
+ if det.max_score > dup.max_score:
442
+ dup.bbox = gbox
443
+ dup.top3 = det.top3
444
+ dup.inside_cartouche = True
445
+ dup.cartouche_id = ci
446
+ continue
447
+
448
+ detections.append(Detection(
449
+ bbox = gbox,
450
+ top3 = det.top3,
451
+ inside_cartouche = True,
452
+ cartouche_id = ci,
453
+ from_reentry = True,
454
+ ))
455
+
456
+ return detections
457
+
458
+
459
+ # ---------------------------------------------------------------------------
460
+ # Step 3 — DSU quadrat clustering
461
+ # ---------------------------------------------------------------------------
462
+
463
+ class DSU:
464
+ """Union-Find with path compression + union by rank."""
465
+
466
+ def __init__(self, n: int):
467
+ self.parent = list(range(n))
468
+ self.rank = [0] * n
469
+
470
+ def find(self, x: int) -> int:
471
+ while self.parent[x] != x:
472
+ self.parent[x] = self.parent[self.parent[x]]
473
+ x = self.parent[x]
474
+ return x
475
+
476
+ def union(self, a: int, b: int) -> None:
477
+ ra, rb = self.find(a), self.find(b)
478
+ if ra == rb:
479
+ return
480
+ if self.rank[ra] < self.rank[rb]:
481
+ ra, rb = rb, ra
482
+ self.parent[rb] = ra
483
+ if self.rank[ra] == self.rank[rb]:
484
+ self.rank[ra] += 1
485
+
486
+ def groups(self) -> dict[int, list[int]]:
487
+ out: dict[int, list[int]] = {}
488
+ for i in range(len(self.parent)):
489
+ out.setdefault(self.find(i), []).append(i)
490
+ return out
491
+
492
+
493
+ def overlap_ratio(a: tuple, b: tuple) -> float:
494
+ """Intersection / min(area). Better than IoU for the double-box case:
495
+ a thin box fully inside a taller box scores ~1.0 here but low IoU."""
496
+ ix1, iy1 = max(a[0], b[0]), max(a[1], b[1])
497
+ ix2, iy2 = min(a[2], b[2]), min(a[3], b[3])
498
+ inter = max(0.0, ix2 - ix1) * max(0.0, iy2 - iy1)
499
+ if inter == 0.0:
500
+ return 0.0
501
+ area_a = (a[2] - a[0]) * (a[3] - a[1])
502
+ area_b = (b[2] - b[0]) * (b[3] - b[1])
503
+ return inter / max(min(area_a, area_b), 1e-9)
504
+
505
+
506
+ def merge_duplicate_boxes(
507
+ detections : list[Detection],
508
+ overlap_thresh : float = DUP_OVERLAP,
509
+ ) -> list[Detection]:
510
+ """
511
+ Collapse multiple detections of the SAME physical sign into one slot
512
+ (fragile breakpoint #5). Survives NMS because the duplicate boxes have
513
+ IoU < 0.5 (e.g. a thin f31 box inside a taller s29 box on one stroke).
514
+
515
+ Two detections merge iff intersection/min-area > overlap_thresh, both
516
+ are non-cartouche, and they share the same cartouche context. DSU
517
+ handles transitivity. The highest-scoring member keeps its bbox and
518
+ identity; top-3s of the group are unioned (max score per code, top 3).
519
+
520
+ `cartouche_id` indices are remapped to the returned list's positions
521
+ (cartouche detections never merge, so they always survive).
522
+ """
523
+ n = len(detections)
524
+ dsu = DSU(n)
525
+ for i in range(n):
526
+ di = detections[i]
527
+ if di.cls == CARTOUCHE_CLASS:
528
+ continue
529
+ for j in range(i + 1, n):
530
+ dj = detections[j]
531
+ if dj.cls == CARTOUCHE_CLASS:
532
+ continue
533
+ if (di.inside_cartouche, di.cartouche_id) != \
534
+ (dj.inside_cartouche, dj.cartouche_id):
535
+ continue
536
+ if overlap_ratio(di.bbox, dj.bbox) > overlap_thresh:
537
+ dsu.union(i, j)
538
+
539
+ merged: list[Detection] = []
540
+ seen_root: set[int] = set()
541
+ for i in range(n): # preserve original order
542
+ root = dsu.find(i)
543
+ if root in seen_root:
544
+ continue
545
+ seen_root.add(root)
546
+ group = [detections[k] for k in range(n) if dsu.find(k) == root]
547
+ base = max(group, key=lambda d: d.max_score)
548
+ if len(group) > 1:
549
+ scores: dict[str, float] = {}
550
+ for d in group:
551
+ for c, s in d.top3:
552
+ scores[c] = max(scores.get(c, 0.0), s)
553
+ base.top3 = sorted(scores.items(),
554
+ key=lambda kv: kv[1], reverse=True)[:3]
555
+ merged.append(base)
556
+
557
+ # Remap cartouche_id (old index -> new index of the same object)
558
+ new_idx = {id(obj): k for k, obj in enumerate(merged)}
559
+ for d in merged:
560
+ if d.cartouche_id is not None:
561
+ d.cartouche_id = new_idx[id(detections[d.cartouche_id])]
562
+ return merged
563
+
564
+
565
+ def merge_duplicate_cartouches(
566
+ detections : list[Detection],
567
+ iou_thresh : float = CARTOUCHE_MERGE_IOU,
568
+ ) -> list[Detection]:
569
+ """
570
+ Collapse twin cartouche boxes over the SAME physical cartouche.
571
+
572
+ `merge_duplicate_boxes` deliberately never merges cartouches, and the
573
+ global class-agnostic NMS only fires above IoU 0.50 — so when a lowered
574
+ CARTOUCHE_CONF admits a second, weaker box over one real cartouche at
575
+ IoU ~0.3-0.5, both survive and the panel reads two cartouches where
576
+ there is one. This pass dedups cartouche-vs-cartouche only, at a lower
577
+ IoU, keeping the higher-scoring box. Non-cartouche detections pass
578
+ through untouched and in place.
579
+ """
580
+ carts = [(i, d) for i, d in enumerate(detections) if d.is_cartouche()]
581
+ if len(carts) < 2:
582
+ return detections
583
+
584
+ # Greedy: score-descending, suppress lower-scoring cartouches that
585
+ # overlap a kept one above the threshold.
586
+ carts.sort(key=lambda t: t[1].max_score, reverse=True)
587
+ drop: set[int] = set()
588
+ for a in range(len(carts)):
589
+ ia, da = carts[a]
590
+ if ia in drop:
591
+ continue
592
+ for b in range(a + 1, len(carts)):
593
+ ib, db = carts[b]
594
+ if ib in drop:
595
+ continue
596
+ if iou(da.bbox, db.bbox) > iou_thresh:
597
+ drop.add(ib)
598
+
599
+ return [d for i, d in enumerate(detections) if i not in drop]
600
+
601
+
602
+ @dataclass
603
+ class Quadrat:
604
+ """One visual block of 1-4 signs sharing a slot in the reading order."""
605
+ members: list[Detection]
606
+
607
+ @property
608
+ def bbox(self) -> tuple[float, float, float, float]:
609
+ return (min(d.bbox[0] for d in self.members),
610
+ min(d.bbox[1] for d in self.members),
611
+ max(d.bbox[2] for d in self.members),
612
+ max(d.bbox[3] for d in self.members))
613
+
614
+ @property
615
+ def centroid(self) -> tuple[float, float]:
616
+ x1, y1, x2, y2 = self.bbox
617
+ return ((x1 + x2) / 2.0, (y1 + y2) / 2.0)
618
+
619
+ def ordered(self, direction: str = 'rtl') -> list[Detection]:
620
+ """
621
+ Within-quadrat reading order: top-to-bottom bands, then ltr/rtl
622
+ inside each band. Band break = y-centroid jump > 0.5 x median
623
+ member height.
624
+ """
625
+ if len(self.members) <= 1:
626
+ return list(self.members)
627
+ med_h = float(np.median([d.height for d in self.members]))
628
+ by_y = sorted(self.members, key=lambda d: d.centroid[1])
629
+ bands: list[list[Detection]] = [[by_y[0]]]
630
+ for d in by_y[1:]:
631
+ band_y = np.mean([m.centroid[1] for m in bands[-1]])
632
+ if d.centroid[1] - band_y > 0.5 * med_h:
633
+ bands.append([d])
634
+ else:
635
+ bands[-1].append(d)
636
+ out: list[Detection] = []
637
+ for band in bands:
638
+ band.sort(key=lambda d: d.centroid[0], reverse=(direction == 'rtl'))
639
+ out.extend(band)
640
+ return out
641
+
642
+
643
+ def _axis_overlap(a: tuple, b: tuple, axis: int) -> float:
644
+ """Projection-overlap ratio of two bboxes on x (axis=0) or y (axis=1),
645
+ normalized by the smaller extent."""
646
+ lo, hi = (0, 2) if axis == 0 else (1, 3)
647
+ inter = min(a[hi], b[hi]) - max(a[lo], b[lo])
648
+ if inter <= 0:
649
+ return 0.0
650
+ return inter / max(min(a[hi] - a[lo], b[hi] - b[lo]), 1e-9)
651
+
652
+
653
+ def _split_component(
654
+ members : list[Detection],
655
+ stack_axis: int, # 0 = x (columns layout), 1 = y (rows)
656
+ max_signs : int,
657
+ ) -> list[list[Detection]]:
658
+ """Recursively split an oversized component at its largest gap along
659
+ the stack axis."""
660
+ if len(members) <= max_signs:
661
+ return [members]
662
+ members = sorted(members, key=lambda d: d.centroid[stack_axis])
663
+ gaps = [members[k + 1].centroid[stack_axis] - members[k].centroid[stack_axis]
664
+ for k in range(len(members) - 1)]
665
+ cut = int(np.argmax(gaps)) + 1
666
+ return (_split_component(members[:cut], stack_axis, max_signs)
667
+ + _split_component(members[cut:], stack_axis, max_signs))
668
+
669
+
670
+ def cluster_quadrats(
671
+ detections : list[Detection],
672
+ layout : str = 'columns', # 'rows' | 'columns'
673
+ align_overlap : float = QUADRAT_ALIGN,
674
+ gap_frac : float = QUADRAT_GAP_FRAC,
675
+ size_ratio : tuple = QUADRAT_SIZE_RATIO,
676
+ max_signs : int = QUADRAT_MAX_SIGNS,
677
+ ) -> list[Quadrat]:
678
+ """
679
+ Group detections into quadrats via DSU connected components.
680
+
681
+ ANTI-CHAINING RULE: two signs share a quadrat only if they stack
682
+ PERPENDICULAR to the reading axis —
683
+ layout='rows' (horizontal reading): vertically stacked signs
684
+ (x-projection overlap > align_overlap, y-gap small)
685
+ layout='columns' (vertical reading): side-by-side signs
686
+ (y-projection overlap > align_overlap, x-gap small)
687
+ Signs adjacent ALONG the reading axis never merge, so a crowded row
688
+ can't chain into one giant component (the failure mode of the naive
689
+ centroid-distance rule).
690
+
691
+ Additional guards: sqrt-area ratio within `size_ratio`; components
692
+ larger than `max_signs` split at their largest perpendicular gap.
693
+ Cartouche-class detections never merge (each is its own quadrat).
694
+ Caller chooses the subset: outer text = not inside_cartouche;
695
+ cartouche interiors = per-cartouche member lists.
696
+
697
+ Returns quadrats sorted by centroid (y, then x) for determinism;
698
+ line-level reading order is step 4's job.
699
+ """
700
+ if not detections:
701
+ return []
702
+ # axis along which quadrat-mates align = reading axis
703
+ read_axis = 0 if layout == 'rows' else 1 # x for rows, y for columns
704
+ stack_axis = 1 - read_axis
705
+
706
+ sign_dets = [d for d in detections if d.cls != CARTOUCHE_CLASS]
707
+ med_stack = (float(np.median([(d.width if stack_axis == 0 else d.height)
708
+ for d in sign_dets]))
709
+ if sign_dets else 1.0)
710
+
711
+ n = len(detections)
712
+ dsu = DSU(n)
713
+ for i in range(n):
714
+ di = detections[i]
715
+ if di.cls == CARTOUCHE_CLASS:
716
+ continue
717
+ for j in range(i + 1, n):
718
+ dj = detections[j]
719
+ if dj.cls == CARTOUCHE_CLASS:
720
+ continue
721
+ if _axis_overlap(di.bbox, dj.bbox, read_axis) < align_overlap:
722
+ continue
723
+ lo, hi = (0, 2) if stack_axis == 0 else (1, 3)
724
+ gap = max(di.bbox[lo], dj.bbox[lo]) - min(di.bbox[hi], dj.bbox[hi])
725
+ if gap > gap_frac * med_stack:
726
+ continue
727
+ # Cross-line guard: a merged pair spanning more than
728
+ # QUADRAT_MAX_EXTENT sign-sizes on the stack axis has leaked
729
+ # into the neighbouring row/column, even if the gap is tiny
730
+ # (adjacent rows can sit closer than intra-quadrat stacks).
731
+ extent = max(di.bbox[hi], dj.bbox[hi]) - min(di.bbox[lo], dj.bbox[lo])
732
+ if extent > QUADRAT_MAX_EXTENT * med_stack:
733
+ continue
734
+ r = (di.area / max(dj.area, 1e-9)) ** 0.5
735
+ if not (size_ratio[0] <= r <= size_ratio[1]):
736
+ continue
737
+ dsu.union(i, j)
738
+
739
+ quadrats: list[Quadrat] = []
740
+ for idxs in dsu.groups().values():
741
+ members = [detections[k] for k in idxs]
742
+ for part in _split_component(members, stack_axis, max_signs):
743
+ quadrats.append(Quadrat(members=part))
744
+ quadrats.sort(key=lambda q: (q.centroid[1], q.centroid[0]))
745
+ return quadrats
746
+
747
+
748
+ # ---------------------------------------------------------------------------
749
+ # Step 4 — line assembly: quadrats -> reading order + boundary hints
750
+ # ---------------------------------------------------------------------------
751
+
752
+ @dataclass
753
+ class ReadingOrder:
754
+ """Final spatial-layer output, ready for sphinx_corrector.correct()."""
755
+ slots : list[list[tuple[str, float]]] # top-3 per slot
756
+ boundary_hints : list[int] # slot indices where a line ends
757
+ # (exclusive end — matches the j
758
+ # convention in viterbi_segment)
759
+ slot_detections : list[Optional[Detection]] # None = synthetic Unknown
760
+ lines : list[list[Quadrat]]
761
+
762
+ @property
763
+ def n_synthetic(self) -> int:
764
+ return sum(1 for d in self.slot_detections if d is None)
765
+
766
+
767
+ def _group_lines(
768
+ quadrats : list[Quadrat],
769
+ cross : int, # cross axis: 0=x (columns), 1=y (rows)
770
+ gap_frac : float,
771
+ ) -> list[list[Quadrat]]:
772
+ """1-D cluster quadrats on the cross axis using a RUNNING-MEAN center
773
+ (comparing to the last element drifts on slanted photos — the bug in
774
+ the old order_signs.py)."""
775
+ med = float(np.median([(q.bbox[2] - q.bbox[0]) if cross == 0
776
+ else (q.bbox[3] - q.bbox[1]) for q in quadrats]))
777
+ qs = sorted(quadrats, key=lambda q: q.centroid[cross])
778
+ lines: list[list[Quadrat]] = [[qs[0]]]
779
+ for q in qs[1:]:
780
+ mean_c = float(np.mean([m.centroid[cross] for m in lines[-1]]))
781
+ if abs(q.centroid[cross] - mean_c) > gap_frac * med:
782
+ lines.append([q])
783
+ else:
784
+ lines[-1].append(q)
785
+ return lines
786
+
787
+
788
+ def assemble_reading_order(
789
+ quadrats : list[Quadrat],
790
+ layout : str = 'columns', # 'rows' | 'columns'
791
+ direction : str = 'rtl', # 'ltr' | 'rtl'
792
+ line_gap_frac : float = LINE_GAP_FRAC,
793
+ missing_gap_frac : float = MISSING_GAP_FRAC,
794
+ max_inserts : int = MAX_GAP_INSERTS,
795
+ extent : Optional[tuple] = None,
796
+ single_line : bool = False,
797
+ ) -> ReadingOrder:
798
+ """
799
+ Assemble quadrats into final reading order.
800
+
801
+ 1. Group quadrats into lines on the cross axis (columns: x; rows: y).
802
+ 2. Order lines: columns follow `direction` (rtl = rightmost column
803
+ first); rows always read top-down.
804
+ 3. Walk each line along the reading axis (columns: top-down; rows:
805
+ per `direction`), emitting each quadrat's members via
806
+ Quadrat.ordered(direction) — one slot (top-3) per sign.
807
+ 4. SYNTHETIC UNKNOWN INSERTION (fragile breakpoint #1): when the
808
+ edge-gap between consecutive quadrats in a line exceeds
809
+ `missing_gap_frac` x median quadrat step, YOLO probably dropped
810
+ sign(s) there — insert round(gap/step) Unknown slots (capped at
811
+ `max_inserts`) so the Unknown-resolver / royal-name matcher can
812
+ fill them. With `extent` (e.g. the inset cartouche bbox), leading
813
+ and trailing gaps are checked too — a missing FIRST sign (the
814
+ Unas e34 case) is only detectable against a known extent.
815
+ 5. After each line, append len(slots) to boundary_hints (exclusive
816
+ end index — the corrector's LAYOUT_BONUS convention).
817
+
818
+ `single_line=True` skips line grouping and treats every quadrat as
819
+ one line. REQUIRED for cartouche interiors: narrow signs are not
820
+ x-aligned, so line grouping splits the interior into fake columns and
821
+ the per-line extent checks then flood it with spurious Unknowns.
822
+
823
+ Returns a ReadingOrder. Slots use YOLO-space class names; the glue
824
+ layer normalizes via cartouche_matcher.normalize_code.
825
+ """
826
+ if not quadrats:
827
+ return ReadingOrder([], [], [], [])
828
+
829
+ read_axis = 0 if layout == 'rows' else 1
830
+ cross = 1 - read_axis
831
+ lo, hi = (0, 2) if read_axis == 0 else (1, 3)
832
+
833
+ med_step = float(np.median(
834
+ [q.bbox[hi] - q.bbox[lo] for q in quadrats]))
835
+
836
+ lines = ([list(quadrats)] if single_line
837
+ else _group_lines(quadrats, cross, line_gap_frac))
838
+ # Line order: columns follow direction; rows always top-down
839
+ if layout == 'columns' and direction == 'rtl':
840
+ lines.sort(key=lambda ln: -float(np.mean([q.centroid[0] for q in ln])))
841
+ elif layout == 'columns':
842
+ lines.sort(key=lambda ln: float(np.mean([q.centroid[0] for q in ln])))
843
+ else:
844
+ lines.sort(key=lambda ln: float(np.mean([q.centroid[1] for q in ln])))
845
+
846
+ descending = (layout == 'rows' and direction == 'rtl')
847
+
848
+ slots : list[list[tuple[str, float]]] = []
849
+ slot_detections : list[Optional[Detection]] = []
850
+ boundary_hints : list[int] = []
851
+
852
+ def emit_unknowns(gap: float) -> None:
853
+ if gap <= missing_gap_frac * med_step:
854
+ return
855
+ # one missing sign ≈ one med_step of empty space
856
+ n = min(max_inserts, max(1, int(gap // med_step)))
857
+ for _ in range(n):
858
+ slots.append([(UNKNOWN_CLASS, 0.0)])
859
+ slot_detections.append(None)
860
+
861
+ for line in lines:
862
+ line.sort(key=lambda q: q.centroid[read_axis], reverse=descending)
863
+
864
+ for k, q in enumerate(line):
865
+ if k == 0:
866
+ if extent is not None:
867
+ lead = (extent[hi] - q.bbox[hi] if descending
868
+ else q.bbox[lo] - extent[lo])
869
+ emit_unknowns(lead)
870
+ else:
871
+ prev = line[k - 1]
872
+ gap = (prev.bbox[lo] - q.bbox[hi] if descending
873
+ else q.bbox[lo] - prev.bbox[hi])
874
+ emit_unknowns(gap)
875
+ for d in q.ordered(direction):
876
+ slots.append(list(d.top3))
877
+ slot_detections.append(d)
878
+
879
+ if extent is not None and line:
880
+ last = line[-1]
881
+ trail = (last.bbox[lo] - extent[lo] if descending
882
+ else extent[hi] - last.bbox[hi])
883
+ emit_unknowns(trail)
884
+
885
+ boundary_hints.append(len(slots))
886
+
887
+ return ReadingOrder(
888
+ slots = slots,
889
+ boundary_hints = boundary_hints,
890
+ slot_detections = slot_detections,
891
+ lines = lines,
892
+ )
893
+
894
+
895
+ # ---------------------------------------------------------------------------
896
+ # Reference infer_fn for production / re-entry (ONNXRuntime + letterbox)
897
+ # ---------------------------------------------------------------------------
898
+
899
+ def letterbox(
900
+ bgr: np.ndarray, imgsz: int = 1024, pad_value: int = 114,
901
+ ) -> tuple[np.ndarray, float, int, int]:
902
+ """
903
+ Aspect-preserving resize onto a square canvas (Ultralytics-style).
904
+ Returns (canvas, scale, dx, dy) where original = (model - d) / scale.
905
+
906
+ NOTE: for THIS model, plain stretch outperforms letterbox on re-entry
907
+ crops (6/6 vs 3-5/6 cartouches covered on test_image_vn5). The training
908
+ data went through ETL/batch_resize.py's in-place 224x224 squash, so the
909
+ model learned aspect-distorted signs — stretch matches that
910
+ distribution. Letterbox is kept for experiments and future models
911
+ trained on aspect-preserved data.
912
+ """
913
+ import cv2
914
+ h, w = bgr.shape[:2]
915
+ scale = min(imgsz / w, imgsz / h)
916
+ nw, nh = max(1, round(w * scale)), max(1, round(h * scale))
917
+ resized = cv2.resize(bgr, (nw, nh))
918
+ canvas = np.full((imgsz, imgsz, 3), pad_value, dtype=np.uint8)
919
+ dx, dy = (imgsz - nw) // 2, (imgsz - nh) // 2
920
+ canvas[dy:dy + nh, dx:dx + nw] = resized
921
+ return canvas, scale, dx, dy
922
+
923
+
924
+ def make_onnx_infer_fn(
925
+ session, # onnxruntime.InferenceSession
926
+ class_names : list[str],
927
+ conf_thresh : float = REENTRY_CONF,
928
+ iou_thresh : float = NMS_IOU,
929
+ imgsz : int = 1024,
930
+ mode : str = 'letterbox', # 'letterbox' | 'stretch'
931
+ ) -> Callable[[np.ndarray], list[Detection]]:
932
+ """
933
+ Build an infer_fn satisfying the cartouche_reentry contract: BGR crop
934
+ in -> list[Detection] with bboxes in crop pixel coordinates out.
935
+ Also usable for the global pass (pass conf_thresh=CONF_THRESHOLD).
936
+
937
+ mode='letterbox' matches the V4 training distribution (Ultralytics
938
+ trained at 1024 with letterbox) and reproduces Colab raw-YOLO output
939
+ exactly (A/B on grand_glyphs.jpeg: 0 missing / 0 extra vs 5 extra
940
+ for stretch). Use it for the global pass. mode='stretch' kept for
941
+ legacy callers; the old 224x224-squash rationale is obsolete.
942
+ """
943
+ import cv2
944
+ inp_name = session.get_inputs()[0].name
945
+ out_name = session.get_outputs()[0].name
946
+
947
+ def _run(canvas: np.ndarray) -> list[Detection]:
948
+ x = cv2.cvtColor(canvas, cv2.COLOR_BGR2RGB).astype(np.float32) / 255.0
949
+ x = np.transpose(x, (2, 0, 1))[None]
950
+ raw = session.run([out_name], {inp_name: x})[0]
951
+ return postprocess_onnx(raw, class_names, conf_thresh, iou_thresh)
952
+
953
+ def infer_stretch(bgr: np.ndarray) -> list[Detection]:
954
+ h, w = bgr.shape[:2]
955
+ dets = _run(cv2.resize(bgr, (imgsz, imgsz)))
956
+ sx, sy = w / imgsz, h / imgsz
957
+ for d in dets:
958
+ x1, y1, x2, y2 = d.bbox
959
+ d.bbox = (x1 * sx, y1 * sy, x2 * sx, y2 * sy)
960
+ return dets
961
+
962
+ def infer_letterbox(bgr: np.ndarray) -> list[Detection]:
963
+ canvas, scale, dx, dy = letterbox(bgr, imgsz)
964
+ dets = _run(canvas)
965
+ for d in dets:
966
+ x1, y1, x2, y2 = d.bbox
967
+ d.bbox = ((x1 - dx) / scale, (y1 - dy) / scale,
968
+ (x2 - dx) / scale, (y2 - dy) / scale)
969
+ return dets
970
+
971
+ if mode == 'stretch':
972
+ return infer_stretch
973
+ if mode == 'letterbox':
974
+ return infer_letterbox
975
+ raise ValueError(f"mode must be 'stretch' or 'letterbox', got {mode!r}")
976
+
src/sphinx_corrector.py ADDED
@@ -0,0 +1,1040 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ NLP pre-transformer correction layer for SphinxEyes.
4
+
5
+ Role in the pipeline
6
+ YOLOv11 (top-3 per slot)
7
+ BigramModel (Markov chain built from BBAW corpus)
8
+ ViterbiSegmenter (dynamic programming over SphinxTrie)
9
+ ConfidenceGate (Naive Bayes: respect high-conf YOLO predictions)
10
+ UnknownResolver (enumerate trie children at Unknown slots)
11
+ correct() (single entry point for FastAPI)
12
+ CorrectionResult (JSON-ready dict for GPT prompt)
13
+
14
+ Algorithms used
15
+ 1. Bigram language model (Markov chain, order 1)
16
+ Built from BBAW gardiner_seq column.
17
+ P(code_B | code_A) = count(A->B) / count(A)
18
+ Stored as log-probabilities to avoid float underflow.
19
+
20
+ 2. Viterbi segmenter
21
+ Dynamic programming over the flat YOLO sequence.
22
+ At each position i, tries all segments codes[i:j] (j-i <= MAX_WORD_LEN).
23
+ Scores each candidate segment with:
24
+ freq_score = log(total_record_freq + 1)
25
+ trans_score = log P(segment[0] | prev_last_code) [bigram]
26
+ edit_penalty = 0.0 (exact) | -1.0 (fuzzy dist=1) | -2.5 (dist=2)
27
+ Backtracks from dp[N] to recover the optimal word sequence.
28
+ Fallback: if dp[N] == -inf, segments sign-by-sign (graceful degradation).
29
+
30
+ 3. Beam search over top-3 YOLO candidates
31
+ At each slot, YOLO supplies up to 3 (code, confidence) pairs.
32
+ The beam keeps the top-B partial sequences, expanding each with all
33
+ 3 candidates. At the end, the highest-scoring complete path wins.
34
+ This replaces the single-best assumption and lets the corrector
35
+ recover from YOLO's first-choice errors.
36
+
37
+ 4. Naive Bayes confidence gate
38
+ Prevents the corrector from overriding a high-confidence YOLO prediction.
39
+ P(correction_correct | yolo_conf, edit_dist) ~ (1-yolo_conf)/(edit_dist+1)
40
+ If this probability is below a threshold, the original YOLO code is kept.
41
+
42
+ 5. Unknown-slot resolution
43
+ When YOLO outputs 'Unknown' for a slot, the trie enumerates all child
44
+ edges at that depth in surviving beam nodes and proposes the most
45
+ frequent real Gardiner code as a replacement. gardiner_orig on the
46
+ SourceRecord provides the ground-truth code the Unknown was substituted for.
47
+
48
+ Usage
49
+ from sphinx_corrector import build_bigram_model, correct, CorrectionResult
50
+ from sphinx_trie import SphinxTrie
51
+
52
+ trie = SphinxTrie.from_pickle('sphinx_trie_v4.pkl')
53
+ log_prob, unigrams = build_bigram_model('bbaw_clean.parquet')
54
+
55
+ # yolo_topk: list of slots, each slot is list of (code, confidence)
56
+ yolo_topk = [
57
+ [('G17', 0.97), ('G18', 0.02), ('Unknown', 0.01)],
58
+ [('N35', 0.91), ('N36', 0.06), ('Z7', 0.03)],
59
+ [('D21', 0.88), ('D22', 0.08), ('D19', 0.04)],
60
+ ]
61
+ result = correct(yolo_topk, trie, log_prob, unigrams)
62
+ print(result['flat_translit'])
63
+ """
64
+ from __future__ import annotations
65
+
66
+ import json
67
+ import math
68
+ import pickle
69
+ from collections import defaultdict, Counter
70
+ from dataclasses import dataclass, field, asdict
71
+ from pathlib import Path
72
+ from typing import Optional
73
+
74
+
75
+ # Public re-export so callers only need to import this module
76
+
77
+ try:
78
+ from sphinx_trie import SphinxTrie, SourceRecord, UNKNOWN_TOKEN
79
+ except ImportError:
80
+ # Allow the module to be imported standalone for unit tests
81
+ SphinxTrie = None # type: ignore
82
+ SourceRecord = None # type: ignore
83
+ UNKNOWN_TOKEN = 'Unknown'
84
+
85
+ # Constants
86
+
87
+ MAX_WORD_LEN = 12 # max Gardiner codes in a single dictionary entry
88
+ BEAM_WIDTH = 8 # number of partial paths kept during beam search
89
+ FUZZY_MAX_DIST = 2 # max Levenshtein distance for trie fuzzy lookup
90
+ NEG_INF = float('-inf')
91
+ YOLO_TRUST_THRESHOLD = 0.75
92
+ # Edit penalty table indexed by Levenshtein distance.
93
+ # Used when sub_cost_matrix is unavailable, or when the trie's fuzzy hit
94
+ # changed segment length (insertions/deletions — no per-pair lookup possible).
95
+ EDIT_PENALTY = {0: 0.0, 1: -1.0, 2: -2.5}
96
+
97
+
98
+ def _compute_edit_penalty(
99
+ orig_seg : list[str],
100
+ eff_seg : list[str],
101
+ edit_dist: int,
102
+ sub_cost : Optional[dict],
103
+ ) -> float:
104
+ """
105
+ Score contribution (negative, i.e. a penalty) for an edited segment.
106
+
107
+ When `sub_cost` is None, or the original and effective lengths differ
108
+ (insert/delete), fall back to the coarse `EDIT_PENALTY` table.
109
+
110
+ When lengths match and `sub_cost` is provided, sum per-pair
111
+ `-(-log P(truth|pred))` = `log P(truth|pred)` over the substituted
112
+ positions. Frequently-confused pairs (high P) → small penalty;
113
+ rarely-confused pairs (low P) → large penalty.
114
+ """
115
+ if edit_dist == 0:
116
+ return 0.0
117
+
118
+ if sub_cost is None or len(orig_seg) != len(eff_seg):
119
+ return EDIT_PENALTY.get(edit_dist, -5.0)
120
+ total = 0.0
121
+
122
+ for o, e in zip(orig_seg, eff_seg):
123
+ if o == e:
124
+ continue
125
+
126
+ c = sub_cost.get((o, e))
127
+
128
+ if c is None:
129
+ total += EDIT_PENALTY.get(1, -1.0) # per-pair fallback
130
+ else:
131
+ total += -c
132
+ # cost ≥ 0; penalty ≤ 0
133
+ return total
134
+
135
+ # Soft linguistic priors added to the Viterbi segment score.
136
+ # Tuned conservatively so corpus frequency still dominates; raise these
137
+ # if the segmenter under-uses determinatives / particles in practice.
138
+ DETERMINATIVE_BONUS = 0.5 # last code of segment is a determinative
139
+ PARTICLE_BONUS = 1.0 # segment exactly matches a phrase-initial particle
140
+ LAYOUT_BONUS = 1.5 # segment ends at an image-derived row/col break
141
+
142
+ # Lazy-loaded prior artifacts. Populated from determinatives.json and
143
+ # initial_particles.json on first use. Set to None to disable.
144
+ _DETERMINATIVES_CACHE: Optional[set] = None
145
+ _PARTICLES_CACHE: Optional[list] = None
146
+ _PRIORS_DIR = Path(__file__).parent
147
+
148
+ # Data Structures
149
+
150
+ @dataclass
151
+ class SegmentedWord:
152
+ codes : list[str]
153
+ translit : str
154
+ translation : str
155
+ freq : int
156
+ edit_dist : int # 0 = exact match, 1-2 = fuzzy corrected
157
+ confidence : float # mean YOLO confidence over the slot range
158
+ source : str # "dickson" | "bbaw" | "fallback"
159
+
160
+
161
+ @dataclass
162
+ class ResolvedUnknown:
163
+ slot : int # index in the flat yolo sequence
164
+ proposed : str # the Gardiner code we propose
165
+ reason : str # human-readable justification
166
+ freq : int # corpus frequency of the proposal
167
+
168
+
169
+ @dataclass
170
+ class CorrectionResult:
171
+ segmented_words : list[SegmentedWord]
172
+ unknowns_resolved : list[ResolvedUnknown]
173
+ flat_corrected_seq : list[str] # for GPT prompt
174
+ flat_translit : str # for GPT prompt
175
+ flat_translation : str # for GPT prompt (Dickson English)
176
+ score : float # total Viterbi score
177
+ had_fallback : bool # True if graceful degradation used
178
+
179
+ def to_dict(self) -> dict:
180
+ return {
181
+ 'segmented_words' : [asdict(w) for w in self.segmented_words],
182
+ 'unknowns_resolved' : [asdict(u) for u in self.unknowns_resolved],
183
+ 'flat_corrected_seq': self.flat_corrected_seq,
184
+ 'flat_translit' : self.flat_translit,
185
+ 'flat_translation' : self.flat_translation,
186
+ 'score' : self.score,
187
+ 'had_fallback' : self.had_fallback,
188
+ }
189
+
190
+ # Linguistic prior loaders (determinatives, initial particles)
191
+
192
+
193
+ def load_determinatives(path: Optional[Path] = None) -> set:
194
+ """
195
+ Load the set of Gardiner codes flagged as determinatives. Cached.
196
+ Falls back to an empty set if determinatives.json is absent.
197
+ """
198
+ global _DETERMINATIVES_CACHE
199
+
200
+ if _DETERMINATIVES_CACHE is not None:
201
+
202
+ return _DETERMINATIVES_CACHE
203
+
204
+ p = Path(path) if path else _PRIORS_DIR / 'determinatives.json'
205
+
206
+ if not p.exists():
207
+
208
+ _DETERMINATIVES_CACHE = set()
209
+
210
+ return _DETERMINATIVES_CACHE
211
+
212
+ with open(p, encoding='utf-8') as f:
213
+
214
+ data = json.load(f)
215
+
216
+ _DETERMINATIVES_CACHE = set(data.get('codes', {}).keys())
217
+
218
+ return _DETERMINATIVES_CACHE
219
+
220
+
221
+ def load_initial_particles(path: Optional[Path] = None) -> list:
222
+ """
223
+ Load phrase-initial particles as a list of (gardiner_spelling, meta)
224
+ tuples, sorted by spelling length descending so longer matches are
225
+ tested first. Cached. Returns [] if initial_particles.json is absent.
226
+ """
227
+ global _PARTICLES_CACHE
228
+
229
+ if _PARTICLES_CACHE is not None:
230
+
231
+ return _PARTICLES_CACHE
232
+
233
+ p = Path(path) if path else _PRIORS_DIR / 'initial_particles.json'
234
+
235
+ if not p.exists():
236
+
237
+ _PARTICLES_CACHE = []
238
+
239
+ return _PARTICLES_CACHE
240
+
241
+ with open(p, encoding='utf-8') as f:
242
+
243
+ data = json.load(f)
244
+
245
+ out: list = []
246
+
247
+ for name, meta in data.get('particles', {}).items():
248
+
249
+ spellings = [meta.get('gardiner', [])]
250
+
251
+ spellings.extend(meta.get('alt_spellings', []))
252
+
253
+ for spelling in spellings:
254
+
255
+ if spelling:
256
+
257
+ out.append((tuple(spelling),
258
+
259
+ {'name': name, 'meaning': meta.get('meaning', '')}))
260
+
261
+ out.sort(key=lambda kv: -len(kv[0]))
262
+
263
+ _PARTICLES_CACHE = out
264
+
265
+ return _PARTICLES_CACHE
266
+
267
+
268
+ # Bigram language model (Markov chain, order 1)
269
+
270
+
271
+ def build_bigram_model(
272
+ bbaw_source, # str | Path to parquet, OR pandas DataFrame
273
+ gardiner_col: str = 'gardiner_seq',
274
+ smoothing: float = 1e-6,
275
+ ) -> tuple[dict, Counter]:
276
+ """
277
+ Build a bigram language model from the BBAW corpus.
278
+
279
+ Parameters:
280
+ bbaw_source : path to bbaw_clean.parquet OR a pandas DataFrame
281
+ gardiner_col : column containing space-separated Gardiner codes
282
+ smoothing : additive (Laplace) smoothing for unseen transitions.
283
+ Small positive float avoids log(0).
284
+
285
+ Returns
286
+ log_prob : dict[str, dict[str, float]]
287
+ log_prob[A][B] = log P(B | A)
288
+ unigrams : Counter
289
+ Raw unigram counts, used for vocabulary size in the Viterbi.
290
+ """
291
+ try:
292
+ import pandas as pd
293
+ except ImportError:
294
+ raise ImportError("pandas is required: pip install pandas")
295
+
296
+ if isinstance(bbaw_source, (str, Path)):
297
+ df = pd.read_parquet(bbaw_source)
298
+ else:
299
+ df = bbaw_source
300
+
301
+ bigrams = defaultdict(Counter)
302
+ unigrams = Counter()
303
+
304
+ for seq_str in df[gardiner_col].dropna():
305
+
306
+ codes = seq_str.strip().split()
307
+
308
+ if not codes:
309
+ continue
310
+ for c in codes:
311
+
312
+ unigrams[c] += 1
313
+
314
+ for a, b in zip(codes, codes[1:]):
315
+
316
+ bigrams[a][b] += 1
317
+
318
+ # Convert to log-probabilities with smoothing
319
+ vocab_size = len(unigrams)
320
+ log_prob: dict[str, dict[str, float]] = {}
321
+
322
+ for a, followers in bigrams.items():
323
+
324
+ total = sum(followers.values()) + smoothing * vocab_size
325
+
326
+ log_prob[a] = {
327
+
328
+ b: math.log((cnt + smoothing) / total)
329
+
330
+ for b, cnt in followers.items()
331
+ }
332
+
333
+ return log_prob, unigrams
334
+
335
+
336
+ def transition_log_prob(
337
+ prev_code : str,
338
+ next_code : str,
339
+ log_prob : dict,
340
+ unigrams : Counter,
341
+ smoothing : float = 1e-6,
342
+ ) -> float:
343
+ """
344
+ Return log P(next_code | prev_code) with fallback to unigram smoothing.
345
+ """
346
+ if prev_code in log_prob and next_code in log_prob[prev_code]:
347
+
348
+ return log_prob[prev_code][next_code]
349
+
350
+ # Unigram fallback with smoothing
351
+ vocab_size = len(unigrams)
352
+ total = sum(unigrams.values()) + smoothing * vocab_size
353
+ count = unigrams.get(next_code, 0) + smoothing
354
+
355
+ return math.log(count / total)
356
+
357
+
358
+
359
+ # Viterbi segmenter
360
+
361
+
362
+ def viterbi_segment(
363
+ codes : list[str],
364
+ trie : 'SphinxTrie',
365
+ log_prob : dict,
366
+ unigrams : Counter,
367
+ sub_cost_matrix : Optional[dict] = None,
368
+ max_word_len : int = MAX_WORD_LEN,
369
+ fuzzy_max_dist : int = FUZZY_MAX_DIST,
370
+ boundary_hints : Optional[list] = None,
371
+ determinatives : Optional[set] = None,
372
+ particles : Optional[list] = None,
373
+ ) -> tuple[list[tuple[list[str], list, int]], bool]:
374
+ """
375
+ Segment a flat sequence of Gardiner codes into the most probable
376
+ sequence of words using dynamic programming over the trie.
377
+
378
+ Parameters
379
+ ----------
380
+ codes : flat list of Gardiner IDs from YOLO
381
+ trie : SphinxTrie with Dickson + BBAW entries
382
+ log_prob : bigram log-probability table
383
+ unigrams : unigram counts (for smoothing)
384
+ sub_cost_matrix : optional dict[(a,b)] -> float substitution cost.
385
+ If None, uses uniform cost 1.0 for all substitutions.
386
+ max_word_len : maximum number of signs in a single dictionary word
387
+ fuzzy_max_dist : maximum Levenshtein distance for fuzzy trie lookup
388
+ boundary_hints : optional list[int] of slot indices where the image
389
+ breaks (end of row/column). Ending a segment at one
390
+ of these positions earns LAYOUT_BONUS.
391
+ determinatives : optional set of Gardiner codes treated as
392
+ determinatives. Defaults to lazy-load from
393
+ determinatives.json.
394
+ particles : optional list of (gardiner_spelling_tuple, meta)
395
+ pairs for phrase-initial particles. Defaults to
396
+ lazy-load from initial_particles.json.
397
+
398
+ Returns
399
+ -------
400
+ path : list of (segment_codes, records, edit_dist)
401
+ segment_codes is the post-fuzzy-correction segment when
402
+ a fuzzy hit fired; cursor accounting uses the original
403
+ span length internally so backtrack stays correct.
404
+ had_fallback: True if graceful sign-by-sign fallback was used
405
+ """
406
+ N = len(codes)
407
+ if N == 0:
408
+ return [], False
409
+
410
+ if determinatives is None:
411
+
412
+ determinatives = load_determinatives()
413
+
414
+ if particles is None:
415
+
416
+ particles = load_initial_particles()
417
+
418
+ boundary_set = set(boundary_hints) if boundary_hints else set()
419
+
420
+ # dp[i] = best total score for the prefix codes[0:i]
421
+ # back[i] = (effective_segment, records, edit_dist, span)
422
+ # effective_segment : codes used for translit/transition (post-fuzzy)
423
+ # span : original-input length consumed (= j-i at insert)
424
+ # The cursor walks `span`, never `len(effective_segment)`. This is the
425
+ # fix for the off-by-one when fuzzy returns a different-length match.
426
+ dp = [NEG_INF] * (N + 1)
427
+ back = [None] * (N + 1)
428
+ dp[0] = 0.0
429
+
430
+ for i in range(N):
431
+ if dp[i] == NEG_INF:
432
+ continue
433
+ # dp[i] = best total score for the prefix codes[0:i]
434
+ # back[i] = (effective_segment, records, edit_dist, span)
435
+ # effective_segment : codes used for translit/transition (post-fuzzy)
436
+ for j in range(i + 1, min(i + max_word_len + 1, N + 1)):
437
+
438
+ original_segment = codes[i:j]
439
+ span = j - i
440
+ edit_dist = 0
441
+ effective_segment = original_segment
442
+
443
+ # Exact trie lookup --
444
+ records = trie.search(original_segment)
445
+
446
+ # Fuzzy trie lookup (Levenshtein)
447
+ if records is None and fuzzy_max_dist > 0:
448
+
449
+ candidates = trie.fuzzy_search(
450
+ original_segment,
451
+ max_distance=fuzzy_max_dist,
452
+ max_results=1
453
+ )
454
+ if candidates:
455
+ best = candidates[0]
456
+ edit_dist = best['distance']
457
+ records = best['records']
458
+ effective_segment = best['gardiner_seq'].split()
459
+
460
+ if records is None:
461
+ continue
462
+
463
+ # --- Score components ---
464
+ total_freq = sum(r.freq for r in records)
465
+ freq_score = math.log(total_freq + 1)
466
+ edit_pen = _compute_edit_penalty(
467
+ original_segment, effective_segment, edit_dist, sub_cost_matrix
468
+ )
469
+
470
+ # Bigram transition from previous word's last code
471
+ if back[i] is not None and effective_segment:
472
+
473
+ prev_eff_seg = back[i][0]
474
+
475
+ if prev_eff_seg:
476
+
477
+ trans_score = transition_log_prob(
478
+ prev_eff_seg[-1], effective_segment[0],
479
+ log_prob, unigrams
480
+ )
481
+ else:
482
+ trans_score = 0.0
483
+ else:
484
+ trans_score = 0.0
485
+
486
+ # --- Linguistic priors ---
487
+ # Determinative bonus: last sign of segment is a determinative
488
+ det_bonus = (DETERMINATIVE_BONUS
489
+ if (determinatives
490
+ and effective_segment
491
+ and effective_segment[-1] in determinatives)
492
+ else 0.0)
493
+
494
+ # Particle bonus: this exact span matches a phrase-initial
495
+ # particle's Gardiner spelling
496
+ part_bonus = 0.0
497
+ if particles:
498
+
499
+ seg_tuple = tuple(original_segment)
500
+
501
+ for spelling, _meta in particles:
502
+
503
+ if len(spelling) == span and seg_tuple == spelling:
504
+
505
+ part_bonus = PARTICLE_BONUS
506
+ break
507
+
508
+ # Layout bonus: segment ends at an image-derived break
509
+ layout_bonus = LAYOUT_BONUS if j in boundary_set else 0.0
510
+
511
+ score = (dp[i] + freq_score + trans_score + edit_pen
512
+ + det_bonus + part_bonus + layout_bonus)
513
+
514
+ if score > dp[j]:
515
+ dp[j] = score
516
+ back[j] = (effective_segment, records, edit_dist, span)
517
+
518
+ # --- Reconstruct path ---
519
+ if dp[N] == NEG_INF:
520
+ # Graceful fallback: one sign per segment, no trie records
521
+ fallback = [([c], [], 0) for c in codes]
522
+ return fallback, True
523
+
524
+ path, pos = [], N
525
+ while pos > 0 and back[pos] is not None:
526
+ _eff_seg, recs, ed, span = back[pos]
527
+ # Emit ORIGINAL codes consumed (the YOLO span), so downstream
528
+ # cursor accounting in correct() stays simple. The trie's corrected
529
+ # reading is conveyed via records (record.translit, record.gardiner_orig).
530
+ original_seg = codes[pos - span:pos]
531
+ path.append((original_seg, recs, ed))
532
+ pos -= span
533
+
534
+ # Handle any remaining prefix not covered (partial match)
535
+ if pos > 0:
536
+ for c in reversed(codes[:pos]):
537
+ path.append(([c], [], 0))
538
+
539
+ path.reverse()
540
+ return path, False
541
+
542
+
543
+
544
+ # Beam search over top-3 YOLO candidates
545
+
546
+
547
+ @dataclass
548
+ class BeamState:
549
+ codes : list[str] = field(default_factory=list)
550
+ confs : list[float] = field(default_factory=list)
551
+ score : float = 0.0
552
+
553
+ def extend(self, code: str, conf: float, trans_score: float) -> 'BeamState':
554
+ return BeamState(
555
+ codes = self.codes + [code],
556
+ confs = self.confs + [conf],
557
+ score = self.score + math.log(conf + 1e-9) + trans_score,
558
+ )
559
+
560
+
561
+ def beam_decode_topk(
562
+ slots : list[list[tuple[str, float]]],
563
+ log_prob : dict,
564
+ unigrams : Counter,
565
+ beam_width: int = BEAM_WIDTH,
566
+ trust_threshold: float = YOLO_TRUST_THRESHOLD,
567
+ ) -> tuple[list[str], list[float]]:
568
+ """
569
+ Given a list of slots where each slot is [(code, conf), ...],
570
+ return the single best flat code sequence using beam search
571
+ with bigram language model scoring.
572
+
573
+ Parameters
574
+ ----------
575
+ slots : list of slots, each slot is a list of (code, confidence)
576
+ sorted by confidence descending (as YOLO produces them)
577
+ log_prob : bigram log-prob table
578
+ unigrams : unigram counts
579
+ beam_width : number of partial hypotheses to keep at each step
580
+
581
+ Returns
582
+ -------
583
+ best_codes : list[str] the single best code sequence
584
+ """
585
+ if not slots:
586
+ return [], []
587
+
588
+ # Initialize beam with empty state
589
+ beam: list[BeamState] = [BeamState()]
590
+
591
+ for slot_candidates in slots:
592
+ new_beam: list[BeamState] = []
593
+
594
+ for state in beam:
595
+ for code, conf in slot_candidates:
596
+
597
+ trans = (transition_log_prob(state.codes[-1], code, log_prob, unigrams) if state.codes else 0.0)
598
+
599
+ new_beam.append( state.extend(code, conf, trans) )
600
+
601
+ new_beam.sort(key=lambda s: s.score, reverse=True)
602
+
603
+ beam = new_beam[:beam_width]
604
+
605
+ best = beam[0] if beam else BeamState()
606
+
607
+ # Compare best codes to YOLO's top-1 per slot and revert if YOLO was more confident
608
+ overridden = []
609
+
610
+ for i, chosen in enumerate(best.codes):
611
+
612
+ top1_code, top1_conf = slots[i][0]
613
+
614
+ deviated = (chosen != top1_code)
615
+
616
+ if deviated and top1_conf >= trust_threshold:
617
+
618
+ best.codes[i] = top1_code # revertir: YOLO manda
619
+ overridden.append(False)
620
+ else:
621
+ overridden.append(deviated)
622
+
623
+ return best.codes, overridden
624
+
625
+ # 4. Naive Bayes confidence gate
626
+
627
+
628
+ def should_correct(
629
+ yolo_conf : float,
630
+ edit_dist : int,
631
+ threshold : float = 0.30,
632
+ ) -> bool:
633
+ """
634
+ Decide whether to apply the trie correction or keep the YOLO prediction.
635
+
636
+ Uses a simple Bayesian estimate:
637
+ P(correction_correct | yolo_conf, edit_dist)
638
+ ~ (1 - yolo_conf) / (edit_dist + 1)
639
+
640
+ If this probability is below `threshold`, the original YOLO code is kept
641
+ (YOLO is probably right and the trie correction is risky).
642
+
643
+ Parameters
644
+ ----------
645
+ yolo_conf : YOLO's confidence for this prediction (0.0 to 1.0)
646
+ edit_dist : Levenshtein distance of the trie correction (0 = exact)
647
+ threshold : minimum probability required to apply correction
648
+
649
+ Returns
650
+ -------
651
+ True = apply the trie correction
652
+ False = keep the original YOLO prediction
653
+ """
654
+ if edit_dist == 0:
655
+ return True # exact match: always accept
656
+ p_correction = (1.0 - yolo_conf) / (edit_dist + 1)
657
+ return p_correction >= threshold
658
+
659
+
660
+ # 5. Unknown-slot resolution
661
+
662
+ def resolve_unknowns(
663
+ path : list[tuple[list[str], list, int]],
664
+ trie : 'SphinxTrie',
665
+ yolo_topk : list[ list[ tuple[ str, float]]],
666
+ slot_offset: int = 0,
667
+ trust_threshold: float = YOLO_TRUST_THRESHOLD,
668
+ ) -> list[ResolvedUnknown]:
669
+ """
670
+ For each segment that contains the UNKNOWN_TOKEN edge, enumerate the
671
+ trie's terminal records to find the most frequent real Gardiner code
672
+ that was originally substituted.
673
+
674
+ Uses the gardiner_orig field stored on SourceRecord during ingestion
675
+ with oov_strategy='unknown'.
676
+
677
+ Parameters
678
+
679
+ path : output of viterbi_segment
680
+ trie : SphinxTrie (needed for context; records are already in path)
681
+ slot_offset : global offset of this path in the full YOLO sequence
682
+
683
+ Returns
684
+
685
+ list of ResolvedUnknown, one per Unknown slot that could be resolved
686
+ """
687
+ resolved = []
688
+ current_slot = slot_offset
689
+
690
+ for seg_codes, records, _ in path:
691
+
692
+ for idx, code in enumerate(seg_codes):
693
+
694
+ if code != UNKNOWN_TOKEN or not records:
695
+ continue
696
+
697
+ global_idx = current_slot + idx
698
+ slot_candidates = (yolo_topk[global_idx]
699
+ if global_idx < len(yolo_topk) else [])
700
+ yolo_alt_codes = {c for c, _ in slot_candidates
701
+ if c != UNKNOWN_TOKEN}
702
+
703
+ # Tally the ground-truth codes this Unknown stood in for.
704
+ orig_counter: Counter = Counter()
705
+ for rec in records:
706
+ if rec.gardiner_orig:
707
+ orig_codes = rec.gardiner_orig.split()
708
+ if idx < len(orig_codes):
709
+ orig_counter[orig_codes[idx]] += rec.freq
710
+
711
+ if not orig_counter:
712
+ continue
713
+
714
+ overlap = [c for c in orig_counter if c in yolo_alt_codes]
715
+
716
+ if overlap:
717
+ # Best case: corpus proposal is also one of YOLO's top-3.
718
+ best_code = max(overlap, key=lambda c: orig_counter[c])
719
+ best_freq = orig_counter[best_code]
720
+ reason = (f"corpus proposal '{best_code}' confirmed by a "
721
+ f"YOLO top-3 candidate at this slot")
722
+ else:
723
+ # No overlap: prefer a decent YOLO alternative, else corpus.
724
+ decent_yolo_alt = next(
725
+ (c for c, conf in slot_candidates
726
+ if c != UNKNOWN_TOKEN and conf >= 0.2),
727
+ None,
728
+ )
729
+ if decent_yolo_alt is not None:
730
+ best_code = decent_yolo_alt
731
+ best_freq = 0
732
+ reason = (f"no corpus/YOLO overlap; falling back to "
733
+ f"YOLO's own alternative '{decent_yolo_alt}'")
734
+ else:
735
+ best_code, best_freq = orig_counter.most_common(1)[0]
736
+ reason = (f"no usable YOLO alternative; corpus frequency "
737
+ f"proposal '{best_code}' (freq={best_freq})")
738
+
739
+ resolved.append(ResolvedUnknown(
740
+ slot=global_idx, proposed=best_code,
741
+ reason=reason, freq=best_freq,
742
+ ))
743
+
744
+ current_slot += len(seg_codes)
745
+
746
+ return resolved
747
+
748
+
749
+ # 6. correct() — single entry point for FastAPI
750
+
751
+ def correct(
752
+ yolo_topk : list[list[tuple[str, float]]],
753
+ trie : 'SphinxTrie',
754
+ log_prob : dict,
755
+ unigrams : Counter,
756
+ sub_cost_matrix : Optional[dict] = None,
757
+ conf_threshold : float = 0.30,
758
+ beam_width : int = BEAM_WIDTH,
759
+ max_word_len : int = MAX_WORD_LEN,
760
+ fuzzy_max_dist : int = FUZZY_MAX_DIST,
761
+ boundary_hints : Optional[list] = None,
762
+ ) -> CorrectionResult:
763
+ """
764
+ Main entry point. Takes YOLO's top-K predictions per slot and returns
765
+ a fully corrected, segmented, transliterated result ready for GPT.
766
+
767
+ Parameters
768
+ ----------
769
+ yolo_topk : list of slots. Each slot is a list of (code, confidence)
770
+ tuples sorted by confidence descending.
771
+ Minimum: 1 tuple per slot. Maximum recommended: 3.
772
+
773
+ trie : SphinxTrie loaded from sphinx_trie_v4.pkl
774
+ log_prob : bigram log-prob table from build_bigram_model()
775
+ unigrams : unigram counter from build_bigram_model()
776
+ sub_cost_matrix : optional dict[(a,b)] -> float.
777
+ If provided, overrides uniform substitution cost.
778
+ Load from confusion_matrix.csv after V2 training.
779
+ conf_threshold : Naive Bayes threshold (default 0.30).
780
+ Lower = more aggressive correction.
781
+ Higher = more conservative, trust YOLO more.
782
+ beam_width : beam search width (default 8)
783
+ max_word_len : max signs per dictionary entry (default 12)
784
+ fuzzy_max_dist : max Levenshtein distance for trie fuzzy lookup (default 2)
785
+
786
+ Returns
787
+ -------
788
+ CorrectionResult dataclass. Call .to_dict() for JSON serialization.
789
+ """
790
+ if not yolo_topk:
791
+ return CorrectionResult(
792
+ segmented_words = [],
793
+ unknowns_resolved = [],
794
+ flat_corrected_seq = [],
795
+ flat_translit = '',
796
+ flat_translation = '',
797
+ score = NEG_INF,
798
+ had_fallback = False,
799
+ )
800
+
801
+ # Beam search over top-3 candidates to get best flat sequence
802
+
803
+ best_codes, beam_overrides = beam_decode_topk(
804
+ yolo_topk, log_prob, unigrams, beam_width=beam_width
805
+ )
806
+
807
+ # Mean confidence per slot (for the confidence gate)
808
+ slot_confs = [
809
+ candidates[0][1] if candidates else 0.5
810
+ for candidates in yolo_topk
811
+ ]
812
+ # Viterbi segmentation over best_codes
813
+
814
+ path, had_fallback = viterbi_segment(
815
+ best_codes, trie, log_prob, unigrams,
816
+ sub_cost_matrix = sub_cost_matrix,
817
+ max_word_len = max_word_len,
818
+ fuzzy_max_dist = fuzzy_max_dist,
819
+ boundary_hints = boundary_hints,
820
+ )
821
+
822
+
823
+ # Apply confidence gate — revert corrections where YOLO was
824
+ # more reliable than the trie correction
825
+
826
+ gated_path = []
827
+ cursor = 0
828
+ for seg_codes, records, edit_dist in path:
829
+ seg_len = len(seg_codes)
830
+ mean_conf = (
831
+ sum(slot_confs[cursor:cursor + seg_len]) / seg_len
832
+ if seg_len > 0 else 0.5
833
+ )
834
+
835
+ if edit_dist > 0 and not should_correct(mean_conf, edit_dist, conf_threshold):
836
+ # Revert: keep original YOLO codes for this segment
837
+ orig_codes = best_codes[cursor:cursor + seg_len]
838
+ gated_path.append((orig_codes, [], 0))
839
+ else:
840
+ gated_path.append((seg_codes, records, edit_dist))
841
+
842
+ cursor += seg_len
843
+
844
+ # Resolve Unknown slots
845
+
846
+ unknowns_resolved = resolve_unknowns(
847
+ gated_path, trie, yolo_topk, slot_offset=0
848
+ )
849
+
850
+ # Apply Unknown resolutions to the corrected sequence
851
+ flat_corrected = []
852
+ for seg_codes, records, _ in gated_path:
853
+ flat_corrected.extend(seg_codes)
854
+
855
+ for resolution in unknowns_resolved:
856
+ if resolution.slot < len(flat_corrected):
857
+ flat_corrected[resolution.slot] = resolution.proposed
858
+
859
+
860
+ # Build SegmentedWord list and flat strings
861
+
862
+ segmented_words : list[SegmentedWord] = []
863
+ total_score = 0.0
864
+ cursor = 0
865
+
866
+ for seg_codes, records, edit_dist in gated_path:
867
+ seg_len = len(seg_codes)
868
+ mean_conf = (
869
+ sum(slot_confs[cursor:cursor + seg_len]) / seg_len
870
+ if seg_len > 0 else 0.5
871
+ )
872
+
873
+ # Pick best record by frequency
874
+ if records:
875
+ best_rec = max(records, key=lambda r: r.freq)
876
+ translit = best_rec.translit
877
+ translation = best_rec.translation
878
+ source = best_rec.source
879
+ freq = best_rec.freq
880
+ else:
881
+ translit = ' '.join(seg_codes)
882
+ translation = ''
883
+ source = 'fallback'
884
+ freq = 0
885
+
886
+ total_score += math.log(freq + 1) + EDIT_PENALTY.get(edit_dist, -5.0)
887
+
888
+ segmented_words.append(SegmentedWord(
889
+ codes = seg_codes,
890
+ translit = translit,
891
+ translation = translation,
892
+ freq = freq,
893
+ edit_dist = edit_dist,
894
+ confidence = round(mean_conf, 4),
895
+ source = source,
896
+ ))
897
+
898
+ cursor += seg_len
899
+
900
+ flat_translit = ' '.join(w.translit for w in segmented_words if w.translit)
901
+ flat_translation = ' | '.join(
902
+ w.translation for w in segmented_words
903
+ if w.translation and w.source != 'fallback'
904
+ )
905
+
906
+ return CorrectionResult(
907
+ segmented_words = segmented_words,
908
+ unknowns_resolved = unknowns_resolved,
909
+ flat_corrected_seq = flat_corrected,
910
+ flat_translit = flat_translit,
911
+ flat_translation = flat_translation,
912
+ score = total_score,
913
+ had_fallback = had_fallback,
914
+ )
915
+
916
+
917
+ # ---------------------------------------------------------------------------
918
+ # Convenience: load artifacts from disk
919
+ # ---------------------------------------------------------------------------
920
+
921
+ def load_corrector(
922
+ trie_pkl : str | Path,
923
+ bbaw_parquet : str | Path,
924
+ confusion_csv: Optional[str | Path] = None,
925
+ gardiner_col : str = 'gardiner_seq',
926
+ ) -> tuple['SphinxTrie', dict, Counter, Optional[dict]]:
927
+ """
928
+ Load every artifact needed by correct() in one call.
929
+
930
+ Parameters
931
+ ----------
932
+ trie_pkl : path to sphinx_trie_v4.pkl
933
+ bbaw_parquet : path to bbaw_clean.parquet (for the bigram LM)
934
+ confusion_csv : optional path to a YOLO confusion-matrix CSV
935
+ (e.g. confusion_matrix_v2_on_v3val_normalized.csv).
936
+ When provided, a per-pair substitution-cost dict is
937
+ built and returned; otherwise the 4th return is None
938
+ and the corrector falls back to coarse EDIT_PENALTY.
939
+ gardiner_col : column name inside bbaw_parquet
940
+
941
+ Returns
942
+ -------
943
+ trie : SphinxTrie
944
+ log_prob : bigram log-probability table
945
+ unigrams : unigram Counter
946
+ sub_cost : dict[(pred, truth) -> -log P(truth|pred)] or None
947
+ """
948
+ if SphinxTrie is None:
949
+ raise ImportError("sphinx_trie.py must be on the Python path")
950
+
951
+ trie = SphinxTrie.from_pickle(trie_pkl)
952
+ log_prob, unigrams = build_bigram_model(bbaw_parquet, gardiner_col)
953
+ sub_cost = load_sub_cost_matrix(confusion_csv) if confusion_csv else None
954
+ return trie, log_prob, unigrams, sub_cost
955
+
956
+
957
+ # ---------------------------------------------------------------------------
958
+ # Cost matrix loader (stub — activate after V2 training)
959
+ # ---------------------------------------------------------------------------
960
+
961
+ def load_sub_cost_matrix(
962
+ confusion_csv: str | Path,
963
+ classes : Optional[list[str]] = None,
964
+ epsilon : float = 1e-4,
965
+ ) -> dict:
966
+ """
967
+ Build a per-pair substitution cost dict from a YOLO confusion matrix CSV.
968
+
969
+ CSV orientation (Ultralytics `ConfusionMatrix.matrix` convention, after
970
+ the V3 notebook's `axis=1` row-normalization):
971
+ rows = predicted class
972
+ columns = truth class
973
+ cell[pred, truth] = P(truth | pred)
974
+
975
+ The extra `background` row/column that Ultralytics adds (index nc) is
976
+ dropped — substituting against background is never a valid Gardiner edit.
977
+
978
+ Cost convention
979
+ ---------------
980
+ cost(pred, truth) = -log( P(truth | pred) + epsilon ) # ≥ 0
981
+ ~0 for frequently-confused pairs (cheap to substitute)
982
+ ~9.2 for never-observed pairs (expensive to substitute,
983
+ epsilon=1e-4 caps -log here)
984
+
985
+ The caller's score adds `-cost` so the penalty contribution is ≤ 0,
986
+ matching the sign convention of `EDIT_PENALTY`. See `_compute_edit_penalty`.
987
+
988
+ Parameters
989
+ ----------
990
+ confusion_csv : path to e.g. `confusion_matrix_v2_on_v3val_normalized.csv`
991
+ classes : optional whitelist of Gardiner codes to keep. If None,
992
+ keeps everything in the CSV except `background`.
993
+ epsilon : Laplace floor (1e-4 → -log caps near 9.2 instead of inf)
994
+
995
+ Returns
996
+ -------
997
+ dict[(pred_code, truth_code)] -> float cost (non-negative).
998
+ Pairs absent from the matrix are silently absent from the dict;
999
+ `_compute_edit_penalty` then falls back to `EDIT_PENALTY[1]`.
1000
+
1001
+ Usage
1002
+ -----
1003
+ sub_cost = load_sub_cost_matrix(
1004
+ 'confusion_matrix_v2_on_v3val_normalized.csv'
1005
+ )
1006
+ result = correct(yolo_topk, trie, log_prob, unigrams,
1007
+ sub_cost_matrix=sub_cost)
1008
+ """
1009
+ try:
1010
+ import pandas as pd
1011
+ except ImportError:
1012
+ raise ImportError("pandas required: pip install pandas")
1013
+
1014
+ df = pd.read_csv(confusion_csv, index_col=0)
1015
+
1016
+ # Drop Ultralytics' nc+1 "background" axis on both ends if present.
1017
+ for label in ('background', 'Background'):
1018
+ if label in df.index:
1019
+ df = df.drop(index=label)
1020
+ if label in df.columns:
1021
+ df = df.drop(columns=label)
1022
+
1023
+ # Optional whitelist
1024
+ if classes is not None:
1025
+ keep_idx = [c for c in classes if c in df.index]
1026
+ keep_col = [c for c in classes if c in df.columns]
1027
+ df = df.loc[keep_idx, keep_col]
1028
+
1029
+ # The CSV is already row-normalized (per V3 notebook cell 121:
1030
+ # `cm_norm = cm / cm.sum(axis=1)`). Read rows directly as P(truth|pred).
1031
+ cost = {}
1032
+ rows, cols = list(df.index), list(df.columns)
1033
+ mat = df.values.astype(float)
1034
+ for i, pred in enumerate(rows):
1035
+ for j, truth in enumerate(cols):
1036
+ p = float(mat[i, j])
1037
+ cost[(pred, truth)] = -math.log(p + epsilon)
1038
+
1039
+ return cost
1040
+
src/sphinx_trie.py ADDED
@@ -0,0 +1,391 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ sphinx_trie.py — Gardiner-keyed prefix trie for the SphinxEyes inference
4
+ pipeline.
5
+
6
+ Role: validate / correct YOLOv11 hieroglyph predictions before passing the
7
+ phonetic transliteration to GPT for translation.
8
+
9
+ Edges = single Gardiner codes (your 148 trained classes + 'Unknown').
10
+ Terminal nodes carry a list of SourceRecord, one per observation in the
11
+ source corpora (Dickson dictionary, BBAW corpus, TLA corpus).
12
+
13
+ Module-level class so pickled tries are loadable from FastAPI without
14
+ __main__-shenanigans.
15
+ """
16
+ from __future__ import annotations
17
+
18
+ import csv
19
+ import json
20
+ import pickle
21
+ from dataclasses import dataclass, asdict
22
+ from pathlib import Path
23
+ from typing import Optional
24
+
25
+
26
+ UNKNOWN_TOKEN = 'Unknown'
27
+
28
+
29
+ @dataclass
30
+ class SourceRecord:
31
+ source: str # "dickson" | "bbaw" | "tla"
32
+ translit: str
33
+ translation: str
34
+ freq: int = 1
35
+ # The canonical Gardiner sequence as it was in the source corpus,
36
+ # BEFORE any OOV->Unknown substitution. Useful when several real
37
+ # sequences collapse onto the same trie path through Unknown.
38
+ gardiner_orig: Optional[str] = None
39
+
40
+
41
+ class TrieNode:
42
+ __slots__ = ('children', 'is_end', 'records')
43
+
44
+ def __init__(self):
45
+ self.children: dict[str, 'TrieNode'] = {}
46
+ self.is_end: bool = False
47
+ self.records: list[SourceRecord] = []
48
+
49
+
50
+ class SphinxTrie:
51
+ """Gardiner-sequence prefix trie."""
52
+
53
+ def __init__(self, allowed_codes: Optional[set[str]] = None):
54
+ self.root = TrieNode()
55
+ self.total_entries = 0
56
+ self.allowed_codes = set(allowed_codes) if allowed_codes else None
57
+
58
+ # ── Insertion ──────────────────────────────────────────────────────
59
+ def insert(self, codes: list[str], record: SourceRecord) -> bool:
60
+ if not codes:
61
+ return False
62
+ if self.allowed_codes is not None:
63
+ if any(c not in self.allowed_codes for c in codes):
64
+ return False
65
+ node = self.root
66
+ for c in codes:
67
+ if c not in node.children:
68
+ node.children[c] = TrieNode()
69
+ node = node.children[c]
70
+ if not node.is_end:
71
+ self.total_entries += 1
72
+ node.is_end = True
73
+ node.records.append(record)
74
+ return True
75
+
76
+ # ── Lookup ─────────────────────────────────────────────────────────
77
+ def _walk(self, codes: list[str]) -> Optional[TrieNode]:
78
+ node = self.root
79
+ for c in codes:
80
+ child = node.children.get(c)
81
+ if child is None:
82
+ return None
83
+ node = child
84
+ return node
85
+
86
+ def search(self, codes: list[str]) -> Optional[list[SourceRecord]]:
87
+ node = self._walk(codes)
88
+ return list(node.records) if (node and node.is_end) else None
89
+
90
+ def starts_with(self, codes: list[str]) -> bool:
91
+ return self._walk(codes) is not None
92
+
93
+ def autocomplete(self, prefix: list[str], max_results: int = 10) -> list[dict]:
94
+ node = self._walk(prefix)
95
+ if node is None:
96
+ return []
97
+ out: list[dict] = []
98
+ self._dfs(node, list(prefix), out, max_results)
99
+ return out
100
+
101
+ def _dfs(self, node, path, out, max_results):
102
+ if len(out) >= max_results:
103
+ return
104
+ if node.is_end:
105
+ out.append({
106
+ 'gardiner_seq': ' '.join(path),
107
+ 'records' : [asdict(r) for r in node.records],
108
+ })
109
+ for c, child in node.children.items():
110
+ self._dfs(child, path + [c], out, max_results)
111
+ if len(out) >= max_results:
112
+ return
113
+
114
+ # ── Bounded Levenshtein over the trie ──────────────────────────────
115
+ def fuzzy_search(self,
116
+ codes: list[str],
117
+ max_distance: int = 2,
118
+ max_results: int = 5) -> list[dict]:
119
+ """
120
+ Bounded edit distance over Gardiner-code sequences, traversing the
121
+ trie and pruning branches whose minimum row > max_distance.
122
+
123
+ Ranking: distance asc, total record freq desc.
124
+ """
125
+ n = len(codes)
126
+ if n == 0:
127
+ return []
128
+ candidates: list[tuple[int, int, list[str], TrieNode]] = []
129
+ first_row = list(range(n + 1))
130
+ for c, child in self.root.children.items():
131
+ self._fuzzy_walk(child, c, codes, first_row, [c],
132
+ max_distance, candidates)
133
+ candidates.sort(key=lambda x: (x[0], -x[1]))
134
+ return [
135
+ {
136
+ 'gardiner_seq': ' '.join(path),
137
+ 'distance' : dist,
138
+ 'freq' : freq,
139
+ 'records' : list(node.records), # SourceRecord instances
140
+ }
141
+ for dist, freq, path, node in candidates[:max_results]
142
+ ]
143
+
144
+ def _fuzzy_walk(self, node, edge, target, prev_row, path,
145
+ max_dist, candidates):
146
+ n = len(target)
147
+ cur_row = [prev_row[0] + 1]
148
+ for i in range(1, n + 1):
149
+ ins = cur_row[i - 1] + 1
150
+ dele = prev_row[i] + 1
151
+ sub = prev_row[i - 1] + (0 if target[i - 1] == edge else 1)
152
+ cur_row.append(min(ins, dele, sub))
153
+ if node.is_end and cur_row[-1] <= max_dist:
154
+ freq = sum(r.freq for r in node.records)
155
+ candidates.append((cur_row[-1], freq, list(path), node))
156
+ if min(cur_row) <= max_dist:
157
+ for c, child in node.children.items():
158
+ self._fuzzy_walk(child, c, target, cur_row, path + [c],
159
+ max_dist, candidates)
160
+
161
+ # ── Build from CSV ─────────────────────────────────────────────────
162
+ def _ingest_row(self, row, source, oov_strategy,
163
+ gardiner_col, translit_col, translation_col, freq_col,
164
+ counters):
165
+ """
166
+ Process one row dict. Mutates `counters` and inserts on success.
167
+ """
168
+ seq_str = (row.get(gardiner_col) or '').strip()
169
+ if not seq_str:
170
+ counters['empty_skipped'] += 1
171
+ return
172
+ codes = seq_str.split()
173
+ gardiner_orig = None
174
+ if self.allowed_codes is not None:
175
+ has_oov = any(c not in self.allowed_codes for c in codes)
176
+ if has_oov:
177
+ if oov_strategy == 'skip':
178
+ counters['oov_dropped'] += 1
179
+ return
180
+ gardiner_orig = ' '.join(codes)
181
+ new_codes = []
182
+ for c in codes:
183
+ if c in self.allowed_codes:
184
+ new_codes.append(c)
185
+ else:
186
+ new_codes.append(UNKNOWN_TOKEN)
187
+ counters['codes_subbed'] += 1
188
+ codes = new_codes
189
+ counters['oov_substituted'] += 1
190
+ translit = (row.get(translit_col) or '').strip() if translit_col else ''
191
+ translation = (row.get(translation_col) or '').strip() if translation_col else ''
192
+ if freq_col and row.get(freq_col):
193
+ try:
194
+ freq = int(row[freq_col])
195
+ except (ValueError, TypeError):
196
+ freq = 1
197
+ else:
198
+ freq = 1
199
+ rec = SourceRecord(
200
+ source=source,
201
+ translit=translit,
202
+ translation=translation,
203
+ freq=freq,
204
+ gardiner_orig=gardiner_orig,
205
+ )
206
+ if self.insert(codes, rec):
207
+ counters['inserted'] += 1
208
+ else:
209
+ counters['empty_skipped'] += 1
210
+
211
+ def build_from_csv(self,
212
+ csv_path: str | Path,
213
+ source: str,
214
+ gardiner_col: str = 'gardiner_seq',
215
+ translit_col: str = 'translit',
216
+ translation_col: str = 'translation',
217
+ freq_col: Optional[str] = None,
218
+ oov_strategy: str = 'skip') -> dict:
219
+ """
220
+ Insert every row of csv_path into the trie. Returns build stats.
221
+
222
+ oov_strategy
223
+ 'skip' : drop the entire row if any code is outside
224
+ allowed_codes (default).
225
+ 'unknown' : replace each OOV code with the literal 'Unknown'
226
+ token; row is still inserted. The original
227
+ sequence is preserved on the record as
228
+ record.gardiner_orig.
229
+ """
230
+ if oov_strategy not in ('skip', 'unknown'):
231
+ raise ValueError(f"oov_strategy must be 'skip' or 'unknown', got {oov_strategy!r}")
232
+ counters = {'inserted': 0, 'oov_dropped': 0, 'oov_substituted': 0,
233
+ 'codes_subbed': 0, 'empty_skipped': 0}
234
+ path = Path(csv_path)
235
+ with open(path, newline='', encoding='utf-8') as f:
236
+ for row in csv.DictReader(f):
237
+ self._ingest_row(row, source, oov_strategy,
238
+ gardiner_col, translit_col, translation_col, freq_col,
239
+ counters)
240
+ return {'csv': str(path), 'source': source,
241
+ 'oov_strategy': oov_strategy,
242
+ **counters,
243
+ 'total_entries': self.total_entries}
244
+
245
+ def build_from_dataframe(self,
246
+ df,
247
+ source: str,
248
+ gardiner_col: str = 'gardiner_seq',
249
+ translit_col: Optional[str] = 'translit',
250
+ translation_col: Optional[str] = 'translation',
251
+ freq_col: Optional[str] = None,
252
+ oov_strategy: str = 'skip') -> dict:
253
+ """
254
+ Same as build_from_csv but takes a pandas DataFrame.
255
+ translit_col / translation_col may be None when the source has
256
+ no such column.
257
+ """
258
+ if oov_strategy not in ('skip', 'unknown'):
259
+ raise ValueError(f"oov_strategy must be 'skip' or 'unknown', got {oov_strategy!r}")
260
+ counters = {'inserted': 0, 'oov_dropped': 0, 'oov_substituted': 0,
261
+ 'codes_subbed': 0, 'empty_skipped': 0}
262
+ wanted_cols = [c for c in (gardiner_col, translit_col, translation_col, freq_col) if c]
263
+ records = df[wanted_cols].to_dict(orient='records') if wanted_cols else df.to_dict(orient='records')
264
+ for row in records:
265
+ self._ingest_row(row, source, oov_strategy,
266
+ gardiner_col, translit_col, translation_col, freq_col,
267
+ counters)
268
+ return {'dataframe_rows': len(df), 'source': source,
269
+ 'oov_strategy': oov_strategy,
270
+ **counters,
271
+ 'total_entries': self.total_entries}
272
+
273
+ # ── Persistence ────────────────────────────────────────────────────
274
+ def to_pickle(self, path: str | Path) -> None:
275
+ with open(path, 'wb') as f:
276
+ pickle.dump(self, f, protocol=pickle.HIGHEST_PROTOCOL)
277
+
278
+ @classmethod
279
+ def from_pickle(cls, path: str | Path) -> 'SphinxTrie':
280
+ with open(path, 'rb') as f:
281
+ obj = pickle.load(f)
282
+ if not isinstance(obj, cls):
283
+ raise TypeError(f'Not a SphinxTrie: {type(obj)}')
284
+ return obj
285
+
286
+ def to_json(self, path: str | Path) -> None:
287
+ """For human inspection only — not for runtime.
288
+
289
+ Bumps recursion limit since some real corpora (BBAW passages)
290
+ produce trie paths well past Python's default 1000.
291
+ """
292
+ import sys as _sys
293
+ def enc(node):
294
+ return {
295
+ 'is_end' : node.is_end,
296
+ 'records': [asdict(r) for r in node.records],
297
+ 'children': {k: enc(v) for k, v in node.children.items()},
298
+ }
299
+ data = {
300
+ 'total_entries': self.total_entries,
301
+ 'allowed_codes': sorted(self.allowed_codes) if self.allowed_codes else None,
302
+ 'root': enc(self.root),
303
+ }
304
+ prev_limit = _sys.getrecursionlimit()
305
+ # need ~3x max_depth headroom for json's iterencode internals
306
+ _sys.setrecursionlimit(max(prev_limit, 5000))
307
+ try:
308
+ with open(path, 'w', encoding='utf-8') as f:
309
+ json.dump(data, f, ensure_ascii=False, indent=2)
310
+ finally:
311
+ _sys.setrecursionlimit(prev_limit)
312
+
313
+ def to_summary_json(self, path: str | Path,
314
+ sample_per_source: int = 20) -> None:
315
+ """
316
+ Compact, depth-bounded inspection artifact: stats plus a small
317
+ sample of entries per source. Use this instead of to_json() when
318
+ the trie is large.
319
+ """
320
+ n_nodes = max_depth = 0
321
+ per_source: dict[str, int] = {}
322
+ samples: dict[str, list] = {}
323
+ terminal_paths_by_depth: dict[int, int] = {}
324
+
325
+ def visit(node, path):
326
+ nonlocal n_nodes, max_depth
327
+ n_nodes += 1
328
+ d = len(path)
329
+ if d > max_depth:
330
+ max_depth = d
331
+ if node.is_end:
332
+ terminal_paths_by_depth[d] = terminal_paths_by_depth.get(d, 0) + 1
333
+ for r in node.records:
334
+ per_source[r.source] = per_source.get(r.source, 0) + 1
335
+ bucket = samples.setdefault(r.source, [])
336
+ if len(bucket) < sample_per_source:
337
+ bucket.append({
338
+ 'gardiner_seq': ' '.join(path),
339
+ **asdict(r),
340
+ })
341
+ for c, child in node.children.items():
342
+ visit(child, path + [c])
343
+
344
+ visit(self.root, [])
345
+
346
+ # depth histogram (binned)
347
+ bins = [(1, 5), (6, 10), (11, 20), (21, 30), (31, 50), (51, 100), (101, 200), (201, 1000)]
348
+ depth_hist = []
349
+ for lo, hi in bins:
350
+ cnt = sum(v for d, v in terminal_paths_by_depth.items() if lo <= d <= hi)
351
+ depth_hist.append({'range': f'{lo}..{hi}', 'count': cnt})
352
+
353
+ data = {
354
+ 'total_entries' : self.total_entries,
355
+ 'total_nodes' : n_nodes,
356
+ 'max_depth' : max_depth,
357
+ 'records_per_source': per_source,
358
+ 'terminal_depth_histogram': depth_hist,
359
+ 'allowed_codes' : sorted(self.allowed_codes) if self.allowed_codes else None,
360
+ 'samples_per_source': samples,
361
+ }
362
+ with open(path, 'w', encoding='utf-8') as f:
363
+ json.dump(data, f, ensure_ascii=False, indent=2)
364
+
365
+ # ── Stats / introspection ─────────────────���────────────────────────
366
+ def stats(self) -> dict:
367
+ n_nodes = 0
368
+ max_depth = 0
369
+ per_source: dict[str, int] = {}
370
+
371
+ def visit(node, d):
372
+ nonlocal n_nodes, max_depth
373
+ n_nodes += 1
374
+ if d > max_depth:
375
+ max_depth = d
376
+ for r in node.records:
377
+ per_source[r.source] = per_source.get(r.source, 0) + 1
378
+ for child in node.children.values():
379
+ visit(child, d + 1)
380
+
381
+ visit(self.root, 0)
382
+ return {
383
+ 'total_entries' : self.total_entries,
384
+ 'total_nodes' : n_nodes,
385
+ 'max_depth' : max_depth,
386
+ 'records_per_source': per_source,
387
+ }
388
+
389
+ def __repr__(self) -> str:
390
+ return (f'SphinxTrie(entries={self.total_entries}, '
391
+ f'allowed={len(self.allowed_codes) if self.allowed_codes else "any"})')