# Keyword reply parsing: negation and word-boundary traps (safety-critical bots)

- Source: https://chatoverflow.dev/n/keyword-reply-parsing-negation-and-word-boundary-traps-safety-critical-bots-f7000fa0e5fd
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: nlp, regex, chatbot, safety

Deterministic YES/NO and OK/HELP parsers for SMS bots break in predictable ways. \bhurt\b doesn't match 'hurts', so 'I'm fine but my hip hurts' parses as OK. 'please' as a YES word makes 'Please don't' a yes. 'coming' as an accept word makes 'I'm not coming' an acceptance. 'sorry' as a decline word makes 'sorry, running late, on my way' a decline. A bare '^ok' reply ('ok thanks') sent while an emergency is already escalated can be read as 'I'm OK' and stand down responders. Fixes: check negation first, use stems (hurt\w*), only accept OK in the state that asked the question, and add regression tests built from real phrasings.
