Class GapFeaturedGrammar

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended byGrammar
              extended byAugmentedGrammar
                  extended byHeadFeaturedGrammar
                      extended byGapFeaturedGrammar
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class GapFeaturedGrammar
extends HeadFeaturedGrammar

An GapFeaturedGrammar is one whose rules are HeadFeaturedGrammarRules whose constituents can contain a GAP feature.

The difference between this and a HeadFeaturedGrammar is the special expansion of rules that have a constituent with a GAP feature (and the necessity to specify what constitute lexical categories).

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.HashMap
 
Nested classes inherited from class java.util.AbstractMap
 
Field Summary
(package private)  java.util.List lexicalCategories
          The list of lexical categories (could be a set but...).
(package private)  Symbol SYMBOL_GAP
          The Symbol ``GAP'', used for indicating the GAP feature.
(package private)  Symbol SYMBOL_PLUS
          The Symbol ``+'', used for indicating the GAP feature's value.
 
Fields inherited from class HeadFeaturedGrammar
headFeatures
 
Fields inherited from class Grammar
description
 
Fields inherited from class java.util.HashMap
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
GapFeaturedGrammar()
           
 
Method Summary
 void add(GrammarRule rule)
          Adds the given HeadFeaturedGrammarRule to this GapFeaturedGrammar.
(package private)  void addGapForHead(HeadFeaturedGrammarRule rule)
          Step 2 of the GAP feature algorithm (Figure 5.5 in NLU2).
(package private)  java.util.List addGapsForNonLexicalConstits(HeadFeaturedGrammarRule rule)
          Step 3 of the GAP feature algorithm (Figure 5.5 in NLU2).
(package private)  java.util.List expandGapFeatures(HeadFeaturedGrammarRule rule)
          Returns a list of rules resulting from expanding the the GAP features of the given HeadFeaturedGrammarRule.
(package private)  boolean hasGap(AugmentedConstituent constit)
          Returns true if the given constituent specifies a GAP feature.
(package private)  boolean hasGap(HeadFeaturedGrammarRule rule)
          Returns true if any constituent of the given rule specifies a GAP feature.
 boolean isLexicalCategory(Symbol category)
          Returns the list of features that are head features for the given syntactic category (or null if none are defined).
(package private)  HeadFeaturedGrammarRule makeGapRule(HeadFeaturedGrammarRule rule, int i)
          Returns a copy of the given rule but with a GAP feature added connecting the mother and the i'th child.
 void readFile(java.lang.String filename)
          Read the given filename and augment this GapFeaturedGrammar.
 void setLexicalCategories(java.util.List cats)
          Sets the list of lexical categories for this GapFeaturedGrammar.
 
Methods inherited from class HeadFeaturedGrammar
addHeadFeatures, getHeadFeatures, setHeadFeatures
 
Methods inherited from class AugmentedGrammar
getRulesForConstituent
 
Methods inherited from class Grammar
dump, dump, getDescription, setDescription
 
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
 

Field Detail

lexicalCategories

java.util.List lexicalCategories
The list of lexical categories (could be a set but...).


SYMBOL_GAP

final Symbol SYMBOL_GAP
The Symbol ``GAP'', used for indicating the GAP feature.


SYMBOL_PLUS

final Symbol SYMBOL_PLUS
The Symbol ``+'', used for indicating the GAP feature's value.

Constructor Detail

GapFeaturedGrammar

public GapFeaturedGrammar()
Method Detail

setLexicalCategories

public void setLexicalCategories(java.util.List cats)
Sets the list of lexical categories for this GapFeaturedGrammar.


isLexicalCategory

public boolean isLexicalCategory(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 GapFeaturedGrammar. For the GapFeaturedGrammar, we have to expand the rule using the algorithm for handling GAP features (Figure 5.5 in NLU2), in addition to the normal processing of head features for a HeadFeaturedGrammar.

Overrides:
add in class HeadFeaturedGrammar

expandGapFeatures

java.util.List expandGapFeatures(HeadFeaturedGrammarRule rule)
Returns a list of rules resulting from expanding the the GAP features of the given HeadFeaturedGrammarRule. The algorithm (Figure 5.5 in NLU2) is:

For each rule Y -> X1 ... Hi ... Xn with head constituent Hi

  1. If the rule specifies a GAP feature in some constituent already, then skip.
  2. If the head Hi is not a lexical category, then add a GAP feature to the head and the mother, and (GAP -) to the other subconstituents, producing a rule of the form:
     (Y GAP ?g) -> (X1 GAP -) ... (Hi GAP ?g) ... (Xn GAP -)
     
  3. If the head Hi is a lexical category, then for each non-lexical subconstituent Xj, add a rule of the form:
     (Y GAP ?g) -> (X1 GAP -) ... (Xj GAP ?g) ... (Xn GAP -)
     


hasGap

boolean hasGap(HeadFeaturedGrammarRule rule)
Returns true if any constituent of the given rule specifies a GAP feature.


hasGap

boolean hasGap(AugmentedConstituent constit)
Returns true if the given constituent specifies a GAP feature.


addGapForHead

void addGapForHead(HeadFeaturedGrammarRule rule)
Step 2 of the GAP feature algorithm (Figure 5.5 in NLU2). If the head Hi is not a lexical category, then add a GAP feature to the head and the mother, and (GAP -) to the other subconstituents, producing a rule of the form:
 (Y GAP ?g) -> (X1 GAP -) ... (Hi GAP ?g) ... (Xn GAP -)
 
Note that (GAP -) is implied, so we don't have to add it explicitly.


addGapsForNonLexicalConstits

java.util.List addGapsForNonLexicalConstits(HeadFeaturedGrammarRule rule)
Step 3 of the GAP feature algorithm (Figure 5.5 in NLU2).
  • If the head Hi is a lexical category, then for each non-lexical subconstituent Xj, add a rule of the form:
     (Y GAP ?g) -> (X1 GAP -) ... (Xj GAP ?g) ... (Xn GAP -)
     


  • makeGapRule

    HeadFeaturedGrammarRule makeGapRule(HeadFeaturedGrammarRule rule,
                                        int i)
    Returns a copy of the given rule but with a GAP feature added connecting the mother and the i'th child.


    readFile

    public void readFile(java.lang.String filename)
                  throws java.io.IOException
    Read the given filename and augment this GapFeaturedGrammar.

    Overrides:
    readFile in class HeadFeaturedGrammar
    Throws:
    java.io.IOException
    See Also:
    GapFeaturedGrammarFileHandler