A pattern-based approach makes a conversational system respond by matching predefined character, word-sequence, or higher-level language patterns. A match triggers a scripted response or extracts useful information. section 1.5.2 section 1.4.2
The method is practical when inputs are predictable: regular expressions can recognize greetings, identify a name, and select an appropriate reply. Its brittleness appears when wording contains typos or variations that do not match the rules. section 1.4 section 1.5.2
A pattern-based system can:
- Match character sequences with regular expressions. section 1.4
- Recognize word sequences, parts of speech, and other higher-level patterns. section 1.5.2
- Stay quiet or alter its response when rules detect who is being addressed. section 1.5.2
A greeting recognizer
A Python regular expression such as `(hi|hello|hey)[ ,:.!]*([a-z]*)` recognizes greetings and captures a following name. A more elaborate version handles phrases such as “Good morning Rosa,” “Good evening Rosa Parks,” and “yo Rosa,” while rejecting “Good Manning Rosa.”
