edu.stanford.nlp.parser.lexparser
Class BinaryRule

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

public class BinaryRule
extends java.lang.Object
implements Rule, java.lang.Comparable<BinaryRule>, java.io.Serializable

Binary rules (ints for parent, left and right children)

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

Field Summary
 int leftChild
           
 int parent
           
 int rightChild
           
 float score
          Score should be a log probability
 
Constructor Summary
BinaryRule(int parent, int leftChild, int rightChild)
          Create a new BinaryRule with the parent and children coded as ints.
BinaryRule(int parent, int leftChild, int rightChild, double score)
           
BinaryRule(java.lang.String s, Index<java.lang.String> index)
          Creates a BinaryRule from String s, assuming it was created using toString().
 
Method Summary
 int compareTo(BinaryRule br)
           
 boolean equals(java.lang.Object o)
           
 int hashCode()
           
 int parent()
           
 float score()
           
 java.lang.String toString()
           
 java.lang.String toString(Index<java.lang.String> index)
           
 java.lang.String toStringNoScore(Index<java.lang.String> index)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

public int parent

score

public float score
Score should be a log probability


leftChild

public int leftChild

rightChild

public int rightChild
Constructor Detail

BinaryRule

public BinaryRule(int parent,
                  int leftChild,
                  int rightChild)
Create a new BinaryRule with the parent and children coded as ints. Score defaults to Float.NaN.

Parameters:
parent - The parent int
leftChild - The left child int
rightChild - The right child int

BinaryRule

public BinaryRule(int parent,
                  int leftChild,
                  int rightChild,
                  double score)

BinaryRule

public BinaryRule(java.lang.String s,
                  Index<java.lang.String> index)
Creates a BinaryRule from String s, assuming it was created using toString().

Parameters:
s - A String in which the binary rule is represented as parent, left-child, right-child, score, with the items quoted as needed
index - Index used to convert String names to ints
Method Detail

score

public float score()
Specified by:
score in interface Rule

parent

public int parent()
Specified by:
parent in interface Rule

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(Index<java.lang.String> index)

toStringNoScore

public java.lang.String toStringNoScore(Index<java.lang.String> index)

compareTo

public int compareTo(BinaryRule br)
Specified by:
compareTo in interface java.lang.Comparable<BinaryRule>


Stanford NLP Group