Copyright © 1998, 2001 by Ian Horswill, see comment within this file.
New Page 1
The role-passing parser
The role-passing parser is a finite-state parser that interoperates with the
role-passing system. It is defined in the parser
package.
General structure
The parser consists of a set of signals (both stateless signals and finite-state
machines) that act together to modify the short term memory of the role-passing system to
reflect whatever utterance is read by the system.
- parser
- This is a global variable exported by the parser package that contains a list of all
signals used by the basic parser infrastructure. By passing it to the compiler, you
can insure that all the parts of the parse get compiled. Note that it does not
contain the processors for any special binders that you may define.
The lexicon
Although the parser itself is a distributed system, the lexicon is represented at
compile time with a single, centralized data structure. The lexicon is then
processed at compile time to form the finite-state machines used by the parser.
The lexicon consists of a list of lexical entries. Each lexical
entry is a list consisting of the word itself, followed by any properties it has.
Properties can either be in the format:
- (property-name value)
- Asserts that the word has the specified value for the property.
- property-name
- Asserts that the word has the value #t for the property.
The lexicon is specified with the define-lexicon form,
which takes a list as an argument. You will generally want to use a backquote for
its argument so that you can conveniently mix lists and symbols with other non-quoted data
objects. For example:
(define-lexicon `((get (activates-frame ,get-frame)
(roles ((patient)))
(go (activates-frame ,go-frame))
(to (roles ((destination)))
(what wh-word
(wh-type ,thing))
(who wh-word
(wh-type ,person))
(where wh-word
(wh-type ,location))))
Lexical entry properties
The following lexical entry properties are currently understood by basic parser.
- (roles roleset1 roleset2 ...)
- Specifies that the word is a phrase head and that the constituents of the phrase should
be bound to the specified roles.
Compile-time lexicon manipulation
Top-level forms
- (define-lexicon lexicon)
- Declares that lexicon, a list of lexical entries, is to be used as the new lexicon.
Signal procedures
- (lexicon-size)
- Returns the number of lexical entries in the current lexicon
- (lexicon-position word)
- Returns the index of the lexical entry for word within the current lexicon.
See word-mentions.
Scheme procedures
- (lexical-entry-has-property? lexical-entry
property-name)
- Returns true if the lexical-entry has a specification for the named property.
- (lexical-entry-property lexical-entry
property-name &optional default-value)
- Returns true if the lexical-entry has a specification for the named property.
- (lexical-entries-with-property lexical-entry
property-name)
- Returns a list of the lexical entries that have specifications for the named property.
Variables
- all-lexicon-words
- A list-valued signal containing all the words in the lexicon as symbols (but not their
lexical entries).
Run-time parser components
Signals
- current-word
- Symbol-valued signal holding the current word being parsed, or #f
if the input buffer is empty. A new word is shifted into this signal on each clock
tick.
- word-mentions
- A vector oof Booleans indicating which words have been seen in the utterance currently
being parsed. It is index by position of the word within the lexicon, see lexicon-position. I'm
assuming this will turn out to be useful, but right now it's just being used for
debugging.
- role-buffer
- Hold the list of upcoming roles for constituents of the current phrase. This is a
case where we've cheated GRL and used the underlying Scheme lists, rather than trying to
implement the role buffer as a shift-register build from a vector (pain). This is
automatically loaded when the lexical entry for the current word is a head (something that
can take arguments). Headness is signaled in the lexicon by specifying a value for
the roles property. The actual loading is done by head-role-handler.
- next-role
- The role (technically roleset) of the next constituent of the current phrase, i.e. the
car of role-buffer.
Other
- parser
- A variable bound to a list of all the signals needed for the basic parser.
Including this in the compiler call which cause the basic parser to be included in
the program.