liveBook · Manning

Finite-state machine

As explained in Natural Language Processing in Action, Second Edition

A finite state machine is a computational model that transitions among a finite set of states in response to input symbols.

A finite-state machine (FSM) models computation as movement among a finite set of states in response to input symbols. It replaces sprawling bit-by-bit conditionals with explicit transition rules. A deterministic finite automaton always chooses a definite match or nonmatch; a finite-state transducer additionally emits output symbols. section 1.4 section 1.4.2

Regular expressions provide a compact way to specify FSM behavior for matching character sequences. In a tightly controlled chatbot, a recognized pattern can trigger a scripted response or extract information, such as identifying a greeting intent from “Open sesame” or “Hello, Rosa.” section 1.4.2 section 1.5

Sentence segmentation

A regular-expression FSM can scan text character by character and identify sentence boundaries. A pattern such as `re.split(r'[!.?]+[\s$]+', text)` handles ordinary punctuation, while additional rules address abbreviations, decimals, and other exceptions. The matcher halts after a finite number of steps and does not backtrack unless features such as lookaheads or lookbacks are used. section 11.2.2

Figure 1.4 Kinds of automata
figure

Compare FSMs with combinatoric logic, pushdown automata, and Turing machines to place finite-state computation within the hierarchy of formal-language machinery. section 1.4.2

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains transitions, deterministic matching, halting, and practical regex behavior while deferring detailed FSM theory and mathematics.
Examples
Uses greeting chatbots, regular-expression matches, character-by-character scanning, and sentence-segmentation patterns as concrete demonstrations.
What it assumes
Assumes basic programming and text-processing familiarity while introducing FSMs through conditionals, binary input, regex, and chatbot behavior.
What you can do after
Build it from scratch with regular expressions to recognize greetings, trigger responses, extract information, or segment sentences.
How it connects
Connects finite-state machines with regular expressions, finite-state transducers, deterministic finite automata, formal languages, chatbots, and sentence segmentation.

Also explained in

Compare how 9 books explain finite-state machine →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.