Book contents
- Frontmatter
- Contents
- Preface
- Part I Formal Background
- Part II From Theory to Practice
- 7 The C(M) language
- 8 C(M) Implementation of Finite-State Devices
- 9 The Aho–Corasick Algorithm
- 10 The Minimal Deterministic Finite-State Automaton for a Finite Language
- 11 Constructing Finite-State Devices for Text Rewriting
- References
- Index
11 - Constructing Finite-State Devices for Text Rewriting
from Part II - From Theory to Practice
Published online by Cambridge University Press: 29 July 2019
- Frontmatter
- Contents
- Preface
- Part I Formal Background
- Part II From Theory to Practice
- 7 The C(M) language
- 8 C(M) Implementation of Finite-State Devices
- 9 The Aho–Corasick Algorithm
- 10 The Minimal Deterministic Finite-State Automaton for a Finite Language
- 11 Constructing Finite-State Devices for Text Rewriting
- References
- Index
Summary
A common task arising in many contexts is rewriting parts of a given input string to another form. Subparts of the input that match specific conditions are replaced by other output parts. In this way, the complete input string is translated to a new output form. Due to the importance of text rewriting, many programming languages offer matching/rewriting operations for subexpressions of strings, also called replace rules. When using strictly regular relations and functions for representing replace rules, a cascade of replace rules can be composed into a single transducer. If the transducer is functional, an equivalent bimachine or (in some cases) a subsequential transducer can be built, thus achieving theoretically and practically optimal text processing speed. In this chapter we introduce basic constructions for building text rewriting transducers and bimachines from replace rules and provide implementations. A first simple version in general leads to an ambiguous form of text rewriting with several outputs. A second more sophisticated construction solves conflicts using the leftmost-longest match strategy and leads to functional devices.
Keywords
- Type
- Chapter
- Information
- Finite-State TechniquesAutomata, Transducers and Bimachines, pp. 279 - 297Publisher: Cambridge University PressPrint publication year: 2019