Spaces:
Sleeping
Sleeping
Upload Code_files/uslap.py with huggingface_hub
Browse files- Code_files/uslap.py +6 -43
Code_files/uslap.py
CHANGED
|
@@ -171,8 +171,7 @@ def query(text):
|
|
| 171 |
Fixed 2026-04-02: tasrif now routes through dhakaa pipeline
|
| 172 |
(perceive β reason β articulate) instead of bypass.
|
| 173 |
|
| 174 |
-
Fixed 2026-04-15: DB hits no longer trigger hypothesis append.
|
| 175 |
-
Transliterated AA queries route to root lookup, not hypothesis.
|
| 176 |
"""
|
| 177 |
from uslap_handler import search
|
| 178 |
|
|
@@ -204,49 +203,13 @@ def query(text):
|
|
| 204 |
lines.append("β" + "β" * 58 + "β")
|
| 205 |
return '\n'.join(lines)
|
| 206 |
|
| 207 |
-
#
|
| 208 |
-
#
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
'tasrif', 'intel ', 'explain ', 'compare ', '--state',
|
| 212 |
-
'--quf', '--batch', 'bitig tasrif',
|
| 213 |
-
)
|
| 214 |
-
is_structural = any(stripped.startswith(p) for p in structural_prefixes)
|
| 215 |
-
|
| 216 |
-
if is_structural:
|
| 217 |
-
from amr_dhakaa import think
|
| 218 |
-
result = think(text)
|
| 219 |
-
return result.get('output', '')
|
| 220 |
-
|
| 221 |
-
# Step 3: plain word lookup β check entries table directly before running
|
| 222 |
-
# the full hypothesis engine. If the word has no confirmed entry, stop here.
|
| 223 |
-
# Hypothesis mode is for local development only, not public output.
|
| 224 |
-
import sqlite3
|
| 225 |
-
db_path = os.path.join(os.path.dirname(__file__), 'uslap_database_v3.db')
|
| 226 |
-
word = stripped.replace('trace ', '').strip()
|
| 227 |
-
try:
|
| 228 |
-
conn = sqlite3.connect(db_path)
|
| 229 |
-
hit = conn.execute(
|
| 230 |
-
"SELECT entry_id FROM entries WHERE LOWER(en_term) = ? LIMIT 1",
|
| 231 |
-
(word,)
|
| 232 |
-
).fetchone()
|
| 233 |
-
conn.close()
|
| 234 |
-
if not hit:
|
| 235 |
-
return f"Not found in DB: '{word}'"
|
| 236 |
-
except Exception:
|
| 237 |
-
pass
|
| 238 |
-
|
| 239 |
from amr_dhakaa import think
|
| 240 |
result = think(text)
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
# Final safety: block any hypothesis that slipped through.
|
| 244 |
-
output_lines = output.splitlines()
|
| 245 |
-
for line in output_lines[:4]:
|
| 246 |
-
if 'HYPOTHESIS:' in line:
|
| 247 |
-
return f"Not found in DB: '{word}'"
|
| 248 |
-
|
| 249 |
-
return output
|
| 250 |
|
| 251 |
|
| 252 |
def full_report(text):
|
|
|
|
| 171 |
Fixed 2026-04-02: tasrif now routes through dhakaa pipeline
|
| 172 |
(perceive β reason β articulate) instead of bypass.
|
| 173 |
|
| 174 |
+
Fixed 2026-04-15: DB hits no longer trigger hypothesis append after result.
|
|
|
|
| 175 |
"""
|
| 176 |
from uslap_handler import search
|
| 177 |
|
|
|
|
| 203 |
lines.append("β" + "β" * 58 + "β")
|
| 204 |
return '\n'.join(lines)
|
| 205 |
|
| 206 |
+
# Not found in DB index β run full AMR pipeline (hypothesis/candidate engine).
|
| 207 |
+
# amr_dhakaa.think() handles all intent routing: trace_word β hypothesise()
|
| 208 |
+
# finds phonetic candidate roots, scores them, applies QUF gate.
|
| 209 |
+
# This IS the core feature for unconfirmed downstream words.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
from amr_dhakaa import think
|
| 211 |
result = think(text)
|
| 212 |
+
return result.get('output', '')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
|
| 215 |
def full_report(text):
|