Skip to main content

Working with lex rules

Advanced users with some knowledge of grammar and parse trees can use an alternative to ATL known as lex rules (short for "lexicalization rules"). By using lex rules you can plan an entire sentence in one step and you can even plan how multiple sentences relate to each other. You can achieve fluency and sophistication in the reports you generate.

Lex rules files are optional extras that can be added to JSON projects.

Lex_rules.png

Requirements

Please make sure that you are thoroughly familiar with the contents of the Describing a JSON object tutorial before you attempt this tutorial. Some basic knowledge of grammar and sentence structure would also be helpful.

Why use Lex Rules?

Lex rules handle many linguistic tasks automatically; for example:

To plan an entire sentence in one step

  • Automatic subject-verb agreement. In English sentences, the subject and verb must agree (e.g. "he eats" versus "they eat"). When you write a lex rule, you plan an entire sentence so the system knows which part is the subject. It can then inflect the verb automatically to agree with the subject. If you design the subject of your sentence to vary according to the value of a variable, the verb inflection will automatically change too!

  • Automatic modifier-count noun agreement. Lex rules automatically pluralize nouns in numerical noun phrases (e.g. "one big red apple" versus "three big red apples").

To plan across multiple sentences

  • Automatic syntactic aggregation of sentences. Syntactic aggregation is the process of combining sentences with similar syntactic structures. For example, “James went for a walk.” and “Judy went for a walk.” will be combined into “James and Judy went for a walk.” Because the sentences are identical apart from their subjects, the subjects are joined into one sentence using "and".

  • Automatic subject elision. Subject elision combines two adjacent sentences when their subjects are identical. For example, “ABC Co. invents gadgets.” and “ABC Co. manufactures laptops.” will be combined into “ABC Co. invents gadgets and manufactures laptops.” The sentences are joined and, because both have the same subject, the subject of the second is elided (missed out).

Structure of this tutorial

 

Let's start by learning about subject-verb agreement.

Subject-verb agreement