Class HeadFeaturedGrammar
java.lang.Object
java.util.AbstractMap
java.util.HashMap
Grammar
AugmentedGrammar
HeadFeaturedGrammar
- All Implemented Interfaces:
- java.lang.Cloneable, java.util.Map, java.io.Serializable
- Direct Known Subclasses:
- GapFeaturedGrammar
- public class HeadFeaturedGrammar
- extends AugmentedGrammar
An HeadFeaturedGrammar is one whose rules are HeadFeaturedGrammarRules (ie,
whose rules have constituents that are HeadFeaturedConstituents, ie.,
they can be marked as head constituents).
The only difference from an AugmentedGrammar is that (a) the grammar
can specify the head features for syntactic categories, and (b) the
HeadFeaturedGrammarRules will have these head features automatically
added (and properly connected to the head daughter constituent).
- See Also:
- Serialized Form
Nested classes inherited from class java.util.HashMap |
|
Nested classes inherited from class java.util.AbstractMap |
|
Fields inherited from class java.util.HashMap |
|
Fields inherited from class java.util.AbstractMap |
|
Method Summary |
void |
add(GrammarRule rule)
Adds the given HeadFeaturedGrammarRule to this HeadFeaturedGrammar. |
(package private) void |
addHeadFeatures(HeadFeaturedGrammarRule rule)
Adds the features from the head daughter of the given rule to its
mother. |
java.util.List |
getHeadFeatures(Symbol category)
Returns the list of features that are head features for the
given syntactic category (or null if none are defined). |
void |
readFile(java.lang.String filename)
Read the given filename and augment this HeadFeaturedGrammar. |
void |
setHeadFeatures(Symbol category,
java.util.List names)
Sets the list of features that are head features for the
given syntactic category. |
Methods inherited from class java.util.HashMap |
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
headFeatures
AssociationList headFeatures
- The set of head features defined for various categories.
HeadFeaturedGrammar
public HeadFeaturedGrammar()
setHeadFeatures
public void setHeadFeatures(Symbol category,
java.util.List names)
- Sets the list of features that are head features for the
given syntactic category.
getHeadFeatures
public java.util.List getHeadFeatures(Symbol category)
- Returns the list of features that are head features for the
given syntactic category (or null if none are defined).
add
public void add(GrammarRule rule)
- Adds the given HeadFeaturedGrammarRule to this HeadFeaturedGrammar.
As with AugmentedGrammarRule, we override our parent's method for this operation in order to
ensure that only HeadFeaturedGrammarRules are added to HeadFeaturedGrammars.
We will throw a ClassCastException if the given object is not
a HeadFeaturedGrammarRule. This is better than having it come up later
when we try to use the rule.
Also, for the HeadFeaturedGrammar, we have to add the head features from
the head constituent of the lhs of the rule to the rhs. After this has
been done, no further specialization is needed for the AugmentedChartParser
code to work properly.
- Overrides:
add
in class AugmentedGrammar
addHeadFeatures
void addHeadFeatures(HeadFeaturedGrammarRule rule)
- Adds the features from the head daughter of the given rule to its
mother.
We must check both the mother and head to see if these features
already are defined.
Note that the features are inserted into both the mother and the
head daughter if they're not already there.
readFile
public void readFile(java.lang.String filename)
throws java.io.IOException
- Read the given filename and augment this HeadFeaturedGrammar.
- Overrides:
readFile
in class AugmentedGrammar
- Throws:
java.io.IOException
- See Also:
HeadFeaturedGrammarFileHandler