MCD state extraction matches "in"/"or" as Indiana/Oregon — anchor to AREAS AFFECTED #43

Closed
opened 2026-07-18 05:31:10 +00:00 by claude-bot · 1 comment
Contributor

_extract_states_from_text (app/services/spc.py:245-249) runs the two-letter
state-abbreviation regex over the entire uppercased MCD narrative, so common
English words match as states (verified: a geography-free sentence yields
{'OR','IN'}). _process_mcd_for_sub gates on membership in that set, so
IN/OR/ME/OK/HI/CO locations get essentially random MCD notifications.

Fix: parse the AREAS AFFECTED... section (present in MCD product text) and
extract states from that line only (abbreviations and full names); fall back to
full-name matching over the narrative when the section is absent. Add tests
using realistic MCD text including bare "in"/"or" tokens.

Acceptance criteria:

  • Plain-English narrative without geography extracts zero states
  • Realistic MCD sample extracts exactly its AREAS AFFECTED states
  • Regression tests cover IN/OR collision words

Filed from the 2026-07-17 codebase audit (docs/.internal/report-2026-07-17.md), finding F-04.

`_extract_states_from_text` (app/services/spc.py:245-249) runs the two-letter state-abbreviation regex over the entire uppercased MCD narrative, so common English words match as states (verified: a geography-free sentence yields `{'OR','IN'}`). `_process_mcd_for_sub` gates on membership in that set, so IN/OR/ME/OK/HI/CO locations get essentially random MCD notifications. Fix: parse the `AREAS AFFECTED...` section (present in MCD product text) and extract states from that line only (abbreviations and full names); fall back to full-name matching over the narrative when the section is absent. Add tests using realistic MCD text including bare "in"/"or" tokens. **Acceptance criteria:** - [ ] Plain-English narrative without geography extracts zero states - [ ] Realistic MCD sample extracts exactly its AREAS AFFECTED states - [ ] Regression tests cover IN/OR collision words --- _Filed from the 2026-07-17 codebase audit (`docs/.internal/report-2026-07-17.md`), finding F-04._
Author
Contributor

Fixed in #92 (merged to main). _extract_states_from_text now parses the AREAS AFFECTED line (abbreviations + full names) and only falls back to full-name matching over the narrative when that line is absent — bare two-letter tokens are never matched across the whole text. Tests cover plain-English narratives (zero states) and IN/OR collision words.

Fixed in #92 (merged to `main`). `_extract_states_from_text` now parses the `AREAS AFFECTED` line (abbreviations + full names) and only falls back to full-name matching over the narrative when that line is absent — bare two-letter tokens are never matched across the whole text. Tests cover plain-English narratives (zero states) and IN/OR collision words.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rbrooks/WeatherBot#43
No description provided.