Why We Build Trees

As we saw in Chapter 2, Basic Parsing Patterns, being able to recognize an input phrase means being able to identify and extract key input elements. For example, recognizing the English phrase “Rebecca runs to the park” means we know “Rebecca” is the subject, “runs” is the verb, and “to the park” is the object. Language recognition is more complicated than simply picking out the parts of speech, though. The order of those elements counts. In a modern English sentence, for example, the verb usually sits between the subject and the object. It sounds wrong (despite being intelligible) to say “Rebecca to the park runs.”[9]

Order is not the only important sentence recognition issue. Many languages have subphrases and nested structures. ...

Get Language Implementation Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.