Correction: reject lost numbers and growth; place verifier anchors from the talkgroup name (server-26#162, server-26#160)
transcript_correction now also discards a correction that drops or changes a bare number the recogniser heard (the live "7" -> "ShotSpotter" case) or grows the transcript past max(4 words, 25%). place_verifier.verify() derives an anchor from the talkgroup's own name plus the receiving node's state when no area is configured; no state means no anchor, and a configured place without an anchor keeps the load-bearing skip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f4d78aba77
commit
7ecfca7648
@@ -260,7 +260,10 @@ async def test_segment_code_change_discards_segments_only():
|
||||
"segments": ["Headquarters, 10-13.", "Show it out to Ossining.", "360 north, back to Route 9."],
|
||||
}
|
||||
with _system(), _gemini(payload):
|
||||
text, segs, _ = await tc.correct("c1", "x y z w", SEGS, system_id="sys-1", talkgroup_id=9048)
|
||||
# A realistic joined original (code-free, like the correction): a
|
||||
# placeholder like "x y z w" now trips the server-26#162 growth guard.
|
||||
text, segs, _ = await tc.correct("c1", "Shout out to Optum, back to Rose.", SEGS,
|
||||
system_id="sys-1", talkgroup_id=9048)
|
||||
assert segs is None
|
||||
assert text == "Show it out to Ossining, back to Route 9."
|
||||
|
||||
@@ -279,3 +282,30 @@ async def test_reference_data_reaches_the_prompt():
|
||||
assert "Sing Sing — state prison" in p, "a term without its meaning is half the information"
|
||||
assert "Ossining, Westchester, New York" in p, "state must reach the prompt (server-26#36)"
|
||||
assert "10-13=officer needs assistance" in p
|
||||
|
||||
|
||||
# ── server-26#162, the rest: bare numbers and invented words ────────────────
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_bare_number_turned_into_a_word_is_rejected():
|
||||
"""The live case: a bare "7" came back as "ShotSpotter"."""
|
||||
payload = {"corrected": "Car ShotSpotter on Home Street and Forest Ave."}
|
||||
with _system(), _gemini(payload):
|
||||
text, _, _ = await tc.correct("c1", "Car 7 on Holmes Street and 4th and Rowe.", None, system_id="sys-1")
|
||||
assert text is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_place_fix_that_keeps_its_numbers_still_passes():
|
||||
payload = {"corrected": "Car 7 on Home Street and Forest Ave."}
|
||||
with _system(), _gemini(payload):
|
||||
text, _, _ = await tc.correct("c1", "Car 7 on Holmes Street and 4th and Rowe.", None, system_id="sys-1")
|
||||
assert text == "Car 7 on Home Street and Forest Ave."
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_correction_that_writes_new_sentences_is_rejected():
|
||||
payload = {"corrected": "Car 7 on Main Street. Suspect is armed and fled northbound in a red sedan."}
|
||||
with _system(), _gemini(payload):
|
||||
text, _, _ = await tc.correct("c1", "Car 7 on Mane Street.", None, system_id="sys-1")
|
||||
assert text is None
|
||||
|
||||
Reference in New Issue
Block a user