Grammar String
A Grammar String is an expression that tells the
Grammar module how to relate words in the user command.
To illustrate the linking requirements, the following diagram shows a simple
dictionary. The linking requirement of each word is represented by the
diagram above the word.
Each shaped label box is a connector. Exactly one and only one of the
connector attached to a given black dot must be satisfied. Thus, cat
requires a D connector to its left, and either an O connector
to its left or an S connector to its right.
The following diagram shows how the linking requirements are satisfied in
the sentence The cat chased a snake.
** The unused connectors have been suppressed here **
It is easy to see that Mary chased the cat and The cat ran
are sentences of this grammar. The sequence of words The Mary chased
cat is not in this grammar, as shown by this diagram.
For succinctness, the following notation to represent links.
The grammar that follows is equivalent to the above
pictorial representation of the grammar.
a, the | D+ |
snake, cat | D- & (O- | S+) |
Mary | O- | S+ |
ran | S- |
chased | S- & O+ |
The linking requirement for each word is expressed in a expression involving
the following operators:
& | the left and right expressions must evaluate true |
| | either left or right expressions must evaluate true,
but not both |
@ | indicates the link may accept multiple connections |
( ) | group expressions |
[ ] | makes the expression optional |
The + or - suffix
on a connector name indicates the direction (relative to the word being
defined) in which the matching connector (if any) must lie. The order
of the expressions of an & is significant. The farther left a connector
is in the expression, the nearer the word to which it connects must be.
Thus, when using cat as an object (using an O- connector), its
determiner (using a D- connector) must be closer than the verb.
|