Spaces:
Running on Zero
Running on Zero
Commit ·
fb935de
1
Parent(s): f440fba
Gate precision: stop false-positives on art movements / events / starters
Browse filesWith landmarks now allowed, the remaining narration rejections were pure
false-positives: capitalized non-places the gate mistook for venues —
"Impressionism"/"Impressionist", "French Revolution", "Remember". Add art
movements, historical events/periods, and more sentence-starters to
_COMMON so grounded prose passes. A real invented venue (Cafe des
Mensonges) and the planted Eiffel Tower still fail.
Test: test_gate_ignores_art_movements_and_events.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
src/discoverroute/narrate/grounding.py
CHANGED
|
@@ -91,6 +91,22 @@ _COMMON = {
|
|
| 91 |
"monument", "memorial", "library", "theatre", "theater", "cinema", "hall",
|
| 92 |
"station", "court", "fountain", "statue", "tower", "gate", "house", "centre",
|
| 93 |
"center", "city", "town", "village", "waterfront",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
}
|
| 95 |
|
| 96 |
_TOKEN_RE = re.compile(r"[A-Za-zÀ-ÖØ-öø-ÿ][A-Za-zÀ-ÖØ-öø-ÿ0-9'’.\-]*")
|
|
|
|
| 91 |
"monument", "memorial", "library", "theatre", "theater", "cinema", "hall",
|
| 92 |
"station", "court", "fountain", "statue", "tower", "gate", "house", "centre",
|
| 93 |
"center", "city", "town", "village", "waterfront",
|
| 94 |
+
# art movements / styles a guide invokes — capitalized but NOT venues (the
|
| 95 |
+
# gate was rejecting whole narrations over "Impressionism"/"Impressionist").
|
| 96 |
+
"impressionism", "impressionist", "impressionists", "cubism", "cubist",
|
| 97 |
+
"surrealism", "surrealist", "expressionism", "expressionist", "romanticism",
|
| 98 |
+
"modernism", "minimalism", "realism", "symbolism", "futurism", "dadaism",
|
| 99 |
+
"fauvism", "pointillism", "abstraction", "bauhaus",
|
| 100 |
+
# historical events / periods / eras (capitalized, not places): "French
|
| 101 |
+
# Revolution", "the Belle Époque" etc.
|
| 102 |
+
"revolution", "revolutions", "empire", "republic", "monarchy", "reign",
|
| 103 |
+
"dynasty", "era", "age", "antiquity", "enlightenment", "reformation",
|
| 104 |
+
"belle", "époque", "epoque", "renaissance", "restoration", "occupation",
|
| 105 |
+
"war", "wars",
|
| 106 |
+
# more sentence-starters / imperatives the model opens clauses with
|
| 107 |
+
"remember", "consider", "watch", "listen", "recall", "observe", "sense",
|
| 108 |
+
"perhaps", "maybe", "indeed", "history", "culture", "tradition", "legend",
|
| 109 |
+
"myth", "legends", "myths", "everywhere", "somewhere", "anywhere",
|
| 110 |
}
|
| 111 |
|
| 112 |
_TOKEN_RE = re.compile(r"[A-Za-zÀ-ÖØ-öø-ÿ][A-Za-zÀ-ÖØ-öø-ÿ0-9'’.\-]*")
|
tests/test_narration.py
CHANGED
|
@@ -101,6 +101,21 @@ def test_geo_gazetteer_allows_landmarks_but_not_eiffel():
|
|
| 101 |
assert not ok2 and any("Eiffel" in o for o in off2)
|
| 102 |
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
def test_geo_gazetteer_still_blocks_invented_venue():
|
| 105 |
"""Loosening for districts must NOT let an invented venue through."""
|
| 106 |
from discoverroute.narrate import gazetteer
|
|
|
|
| 101 |
assert not ok2 and any("Eiffel" in o for o in off2)
|
| 102 |
|
| 103 |
|
| 104 |
+
def test_gate_ignores_art_movements_and_events():
|
| 105 |
+
"""Capitalized non-places (art movements, historical events, sentence-starters)
|
| 106 |
+
must not trip the gate — they were sinking whole narrations live
|
| 107 |
+
('Impressionism', 'French Revolution', 'Remember')."""
|
| 108 |
+
text = ("Remember the French Revolution as you pass Jardin des Plantes; the "
|
| 109 |
+
"Impressionism and Impressionist spirit lingers here.")
|
| 110 |
+
ok, off = grounding.verify_grounded(text, POIS, start_label="Bastille")
|
| 111 |
+
assert ok, off
|
| 112 |
+
# but a genuinely invented venue in the same prose still fails
|
| 113 |
+
ok2, off2 = grounding.verify_grounded(
|
| 114 |
+
"Remember the Impressionists at Café des Mensonges near Jardin des Plantes.",
|
| 115 |
+
POIS, start_label="Bastille")
|
| 116 |
+
assert not ok2 and any("Mensonges" in o for o in off2)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
def test_geo_gazetteer_still_blocks_invented_venue():
|
| 120 |
"""Loosening for districts must NOT let an invented venue through."""
|
| 121 |
from discoverroute.narrate import gazetteer
|