Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -45,6 +45,13 @@ DESCRIPTION = """
|
|
| 45 |
"""
|
| 46 |
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
def run_query(query: str) -> str:
|
| 49 |
if not query or not query.strip():
|
| 50 |
return "Enter a query above."
|
|
@@ -62,11 +69,19 @@ def run_query(query: str) -> str:
|
|
| 62 |
)
|
| 63 |
out = result.stdout.strip()
|
| 64 |
err = result.stderr.strip()
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
except subprocess.TimeoutExpired:
|
| 71 |
return "Query timed out (30s)."
|
| 72 |
except Exception as e:
|
|
|
|
| 45 |
"""
|
| 46 |
|
| 47 |
|
| 48 |
+
NOT_FOUND_MARKERS = [
|
| 49 |
+
"HYPOTHESIS:",
|
| 50 |
+
"No entries found",
|
| 51 |
+
"not found in index",
|
| 52 |
+
"CANDIDATES:",
|
| 53 |
+
]
|
| 54 |
+
|
| 55 |
def run_query(query: str) -> str:
|
| 56 |
if not query or not query.strip():
|
| 57 |
return "Enter a query above."
|
|
|
|
| 69 |
)
|
| 70 |
out = result.stdout.strip()
|
| 71 |
err = result.stderr.strip()
|
| 72 |
+
|
| 73 |
+
if not out:
|
| 74 |
+
return f"[stderr]\n{err}" if err else "(no output)"
|
| 75 |
+
|
| 76 |
+
# Block hypothesis / unconfirmed output — only confirmed DB data shown.
|
| 77 |
+
# Direction: Allah's Arabic → downstream. Hypothesis mode runs the
|
| 78 |
+
# reverse (downstream → candidate AA roots) without a confirmed chain.
|
| 79 |
+
first_line = out.splitlines()[0] if out else ""
|
| 80 |
+
if any(m in first_line for m in NOT_FOUND_MARKERS):
|
| 81 |
+
return f"Not found in DB: '{query.strip()}'\n\nOnly confirmed entries are shown here.\nRun locally with the full engine for hypothesis mode."
|
| 82 |
+
|
| 83 |
+
return out
|
| 84 |
+
|
| 85 |
except subprocess.TimeoutExpired:
|
| 86 |
return "Query timed out (30s)."
|
| 87 |
except Exception as e:
|