edu.stanford.nlp.parser.lexparser
Class UnaryGrammar

java.lang.Object
  extended by edu.stanford.nlp.parser.lexparser.UnaryGrammar
All Implemented Interfaces:
Serializable, Iterable<UnaryRule>

public class UnaryGrammar
extends Object
implements Serializable, Iterable<UnaryRule>

Maintains efficient indexing of unary grammar rules.

Author:
Dan Klein, Christopher Manning
See Also:
Serialized Form

Constructor Summary
UnaryGrammar(int numStates)
           
UnaryGrammar(int numStates, String stateSpace)
           
 
Method Summary
 void addRule(UnaryRule ur)
           
 Iterator<UnaryRule> closedRuleIterator()
           
 Iterator<UnaryRule> closedRuleIteratorByChild(int state)
           
 Iterator<UnaryRule> closedRuleIteratorByParent(int state)
           
 UnaryRule[] closedRulesByChild(int state)
           
 UnaryRule[] closedRulesByParent(int state)
           
 UnaryRule getRule(UnaryRule ur)
           
 Iterator<UnaryRule> iterator()
           
 int numClosedRules()
           
 int numRules()
           
 void purgeRules()
          Remove A -> A UnaryRules from bestRulesUnderMax.
 void readData(BufferedReader in)
          Populates data in this UnaryGrammar from a character stream.
 Iterator<UnaryRule> ruleIterator()
           
 Iterator<UnaryRule> ruleIteratorByChild(int state)
           
 Iterator<UnaryRule> ruleIteratorByParent(int state)
           
 List<UnaryRule> rules()
           
 List<UnaryRule> rulesByChild(int state)
           
 List<UnaryRule> rulesByParent(int state)
           
 List<UnaryRule>[] rulesWithParent()
           
 double scoreRule(UnaryRule ur)
           
 String toString()
           
 void writeAllData(Writer w)
          Writes out a lot of redundant data from this Object to the Writer w.
 void writeData(Writer w)
          Writes out data from this Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnaryGrammar

public UnaryGrammar(int numStates)

UnaryGrammar

public UnaryGrammar(int numStates,
                    String stateSpace)
Method Detail

numClosedRules

public int numClosedRules()

getRule

public UnaryRule getRule(UnaryRule ur)

closedRuleIterator

public Iterator<UnaryRule> closedRuleIterator()

numRules

public int numRules()

iterator

public Iterator<UnaryRule> iterator()
Specified by:
iterator in interface Iterable<UnaryRule>

ruleIterator

public Iterator<UnaryRule> ruleIterator()

rules

public List<UnaryRule> rules()

purgeRules

public final void purgeRules()
Remove A -> A UnaryRules from bestRulesUnderMax.


scoreRule

public double scoreRule(UnaryRule ur)

addRule

public final void addRule(UnaryRule ur)

closedRulesByParent

public UnaryRule[] closedRulesByParent(int state)

closedRulesByChild

public UnaryRule[] closedRulesByChild(int state)

closedRuleIteratorByParent

public Iterator<UnaryRule> closedRuleIteratorByParent(int state)

closedRuleIteratorByChild

public Iterator<UnaryRule> closedRuleIteratorByChild(int state)

ruleIteratorByParent

public Iterator<UnaryRule> ruleIteratorByParent(int state)

ruleIteratorByChild

public Iterator<UnaryRule> ruleIteratorByChild(int state)

rulesByParent

public List<UnaryRule> rulesByParent(int state)

rulesByChild

public List<UnaryRule> rulesByChild(int state)

rulesWithParent

public List<UnaryRule>[] rulesWithParent()

readData

public void readData(BufferedReader in)
              throws IOException
Populates data in this UnaryGrammar from a character stream.

Parameters:
in - The Reader the grammar is read from.
Throws:
IOException - If there is a reading problem

writeData

public void writeData(Writer w)
Writes out data from this Object.

Parameters:
w - Data is written to this Writer

writeAllData

public void writeAllData(Writer w)
Writes out a lot of redundant data from this Object to the Writer w.

Parameters:
w - Data is written to this Writer

toString

public String toString()
Overrides:
toString in class Object


Stanford NLP Group