December 2009
Intermediate to advanced
380 pages
9h 2m
English
| Pattern 30 | Rule-Based Translator |
A rule-based translator expresses a translation with a set of “x becomes y” rules, written in the DSL of a pattern-matching engine.
To use a rule-based system, we have to feed it two things: a grammar that describes input sentences and a set of translation rules. The reason we need the grammar is to get a Pattern 8, Parse Tree. The parse tree concretely defines what the various phrases and subphrases are. That’s how they can avoid applying transformations inside comments in the input stream, for example. Although it looks like we’re doing text-to-text transformations, the underlying engine is actually doing tree rewrites.
For complicated translators, we need to build a lot of ancillary data ...