Setting and getting values of grammatical and semantic "features"
during parsing with ASDParser
Copyright 2008
James A. Mason
To represent semantic values or syntactic features
(e.g., singular vs. plural of nouns or verbs, or the case of nouns)
during a parse, ASDParser provides a mechanism for the Java functions
which are named in semantic action
and semantic value
augmentations of an
ASD
grammar to set and access pairs of "features" and "values". A feature can be any string, and its
corresponding value can be any
Java object.. ASDParser provides the following instance functions
to set and access feature values and to access semantic values of nodes
in a phrase structure. At each stage in the parsing process, the
parser maintains a set of feature-value pairs for the current subphrase
being parsed at the top level of the phrase structure. That
subphrase corresponds to the current search path through a component of
the grammar.
void set(java.lang.String featureName,
java.lang.Object value) //
sets contents of a 'feature' with the
specified name to the specified value
java.lang.Object get(java.lang.String featureName)
//
returns the value of
'feature' with specified name
java.lang.Object valueOf(java.lang.String featureName)
//
returns the value of
'feature' with specified name
java.util.HashMap features() //
returns the feature-value pairs for
the current top level of the phrase structure
- ASDPraseNode currentNode() // returns the current
node at the top level of the phrase structure
The functions get and valueOf are identical; they just
provide alternative names for getting the current value of a
feature. In addition to the foregoing instance functions of
ASDParser, the class ASDPhraseNode provides a method
- java.lang.Object value() // returns the semantic
value for this node; null if none
to return the semantic value of a node in the phrase structure.
Illustrations of uses of these various instance functions are provided
in the example Numerals.java, in the
functions named in the semantic action and semantic value fields of its
associated ASD grammar cardinal.grm (shown
in graphical form in cardinal.jpg).
last modified 2008 Mar 17