edu.upenn.cis.propbank_shen
Class WordSpan

java.lang.Object
  extended by edu.upenn.cis.propbank_shen.WordSpan
All Implemented Interfaces:
Comparable

public class WordSpan
extends Object
implements Comparable

This class represents the span of a propbank argument or of the subtree of a sentence by a pair of integers indicating the first word of the argument and the first word that is outside the argument. It corresponds to the class TreeAddress in the original Propbank API and had to be changed to reflect Libin Shen's change to the original propbank as described in his REAMDE file: "Word IDs are used to represent the phrases, while in the original Propbank, phrases are represented with the root node of the subtree in PTB." The numbers start with zero, i.e. the initial word in a sentence is the zeroth word.

Author:
Scott Cotton

Constructor Summary
WordSpan(int s, int e)
          Construct a word span from a start and an end position
 
Method Summary
static WordSpan combine(WordSpan w1, WordSpan w2)
          Merge two WordSpans.
 int compareTo(Object o)
          Comparison of node addresses just uses comparison of start numbers backing off to end if start numbers are equal.
 int end()
           
 boolean equals(Object o)
           
 ElemTree getSubTree(Sentence s)
          Attempts to find a subtree whose root ElemTree yields the words described by this span.
 int hashCode()
           
static WordSpan merge(Iterator wordSpans)
          Merge any number of WordSpans.
static WordSpan ofString(String s)
          Creates a WordSpan instance from a string of the form
 int start()
           
 String toString()
          Return a string of the form <start>_<end>
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WordSpan

public WordSpan(int s,
                int e)
Construct a word span from a start and an end position

Method Detail

combine

public static WordSpan combine(WordSpan w1,
                               WordSpan w2)
Merge two WordSpans. Returns the smallest span that contains each of the input spans. Always returns a continuous span. If one of the arguments is null then the other one is returned. If both of the arguments are null then an exception is raised.


merge

public static WordSpan merge(Iterator wordSpans)
Merge any number of WordSpans. Returns the smallest span that contains each of the input spans. Always returns a continuous span. Returns an exception if the iterator argument is empty.

Parameters:
wordSpans - an Iterator containing spans
Returns:
a WordSpan that contains each of the input spans

getSubTree

public ElemTree getSubTree(Sentence s)
Attempts to find a subtree whose root ElemTree yields the words described by this span. Returns null otherwise.


equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(Object o)
Comparison of node addresses just uses comparison of start numbers backing off to end if start numbers are equal.

Specified by:
compareTo in interface Comparable

toString

public String toString()
Return a string of the form <start>_<end>

Overrides:
toString in class Object

ofString

public static WordSpan ofString(String s)
                         throws CorruptDataException
Creates a WordSpan instance from a string of the form
 <terminal>_<end> 

Parameters:
s -
Throws:
CorruptDataException

start

public int start()

end

public int end()