Identify core and filler
A grammar typically consists of a core portion that contains the most important information-bearing words—like cities, dates, and times—and a filler portion that contains additional expressions such as “I’d like to...” or “please”.
At the beginning of the grammar design process, you identify the main information slots needed, and this is a good first indication of the words to include in the core of the grammar. For additional core words (that are not immediately obvious during design), review the anticipated caller responses.
Core
The core portion of a grammar is often highly reusable, so it makes sense to define a rule describing just that core portion of a grammar. Other rules and grammars can then refer to the core rule, while accounting for the likely filler words that are particular to each context.
For example, in the flight application you could create a single “City” rule to recognize a city name. You could then refer to this same rule from within both the “Origin” and the “Destination” grammar rules:
<rule id="origin">
from <ruleref uri="#city"/>
</rule>
<rule id="destination"
to <ruleref uri="#city"/>
</rule>
<rule id="city">
<one-of>
<item>San_Francisco</item>
<item>New York</item>
<item>Los_Angeles</item>
</one-of>
</rule>
Filler
Once you’ve identified the core portions of the grammar, you can use the anticipated responses to figure out possible filler portions of the grammar. Simply replace the core parts with the name of the core grammars:
- “{CITY}”
- “I’m leaving from {CITY}”
- “I’d like to leave from {CITY}”
- “Uh, {CITY}”
- “{CITY}, please”
- “I’m flying from {CITY}”
- “Departing from {CITY}”
The filler depends on the prompts, and a good prompt design minimizes the filler portions of your grammar. Still, there may be a much wider variation of possible filler words than of core words. There are several ways to address this problem when you actually write the grammar. Your analysis of the anticipated responses can help determine which approach is best (see Predicting caller responses).