correlator: a radio code is not a location

A 09-22 replay stop was titled "Traffic Stop at 96 times 5" — a disposition
code read aloud, extracted as the location (server-26#170). clean_location
now rejects "N times N", ten-codes, "signal N", "code N", "condition N".

c2-core: 476 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Logan Cusano
2026-09-27 11:32:09 -04:00
co-authored by Claude Opus 5.5
parent e90a73ff09
commit 20c5799a8d
2 changed files with 19 additions and 0 deletions
@@ -343,9 +343,21 @@ def clean_location(value) -> Optional[str]:
s = str(value).strip()
if not s or not _LOCATION_WORD_RE.search(s):
return None
if _RADIO_CODE_RE.match(s):
return None
return s
# Status/disposition codes the extractor sometimes returns as a location:
# "96 times 5" (a disposition code read aloud) titled a 09-22 replay stop
# "Traffic Stop at 96 times 5" (server-26#170); "10-8", "signal 99", "code 4"
# are the same shape.
_RADIO_CODE_RE = re.compile(
r"^\s*(?:\d{1,3}\s*(?:times|x)\s*\d{1,3}|10[\s-]?\d{1,3}|(?:signal|code|condition)\s+\d{1,3})\s*$",
re.IGNORECASE,
)
def location_is_unit(location, units) -> bool:
"""
True when a location label is really one of the incident's own unit