edu.stanford.nlp.parser.lexparser
Class BinaryGrammar

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

public class BinaryGrammar
extends Object
implements Serializable, Iterable<BinaryRule>

Maintains efficient indexing of binary grammar rules.

Author:
Dan Klein, Christopher Manning (generified and optimized storage)
See Also:
Serialized Form

Constructor Summary
BinaryGrammar(int numStates)
           
BinaryGrammar(int numStates, String stateSpace)
           
 
Method Summary
 void addRule(BinaryRule br)
           
 boolean isSynthetic(int state)
           
 Iterator<BinaryRule> iterator()
           
 int numRules()
           
 void readData(BufferedReader in)
          Populates data in this BinaryGrammar from the character stream given by the Reader r.
 Iterator ruleIteratorByLeftChild(int state)
           
 Iterator ruleIteratorByParent(int state)
           
 Iterator ruleIteratorByRightChild(int state)
           
 List ruleListByLeftChild(int state)
           
 List ruleListByParent(int state)
           
 List ruleListByRightChild(int state)
           
 List<BinaryRule> rules()
           
 double scoreRule(BinaryRule br)
           
 void splitRules()
          Populates the "splitRules" accessor lists using the existing rule lists.
 BinaryRule[] splitRulesWithLC(int state)
           
 BinaryRule[] splitRulesWithRC(int state)
           
 String stateSpace()
           
 void writeData(Writer w)
          Writes out data from this Object to the Writer w.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryGrammar

public BinaryGrammar(int numStates)

BinaryGrammar

public BinaryGrammar(int numStates,
                     String stateSpace)
Method Detail

numRules

public int numRules()

rules

public List<BinaryRule> rules()

stateSpace

public String stateSpace()

isSynthetic

public boolean isSynthetic(int state)

splitRules

public void splitRules()
Populates the "splitRules" accessor lists using the existing rule lists. If the state is synthetic, these lists contain all rules for the state. If the state is NOT synthetic, these lists contain only the rules in which both children are not synthetic.

This method must be called before the grammar is used, either after training or deserializing grammar.


splitRulesWithLC

public BinaryRule[] splitRulesWithLC(int state)

splitRulesWithRC

public BinaryRule[] splitRulesWithRC(int state)

scoreRule

public double scoreRule(BinaryRule br)

addRule

public void addRule(BinaryRule br)

iterator

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

ruleIteratorByParent

public Iterator ruleIteratorByParent(int state)

ruleIteratorByRightChild

public Iterator ruleIteratorByRightChild(int state)

ruleIteratorByLeftChild

public Iterator ruleIteratorByLeftChild(int state)

ruleListByParent

public List ruleListByParent(int state)

ruleListByRightChild

public List ruleListByRightChild(int state)

ruleListByLeftChild

public List ruleListByLeftChild(int state)

readData

public void readData(BufferedReader in)
              throws IOException
Populates data in this BinaryGrammar from the character stream given by the Reader r.

Throws:
IOException

writeData

public void writeData(Writer w)
               throws IOException
Writes out data from this Object to the Writer w.

Throws:
IOException


Stanford NLP Group