|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.upenn.cis.spinal.Sentence
public class Sentence
Represents a sentence (an LTAG-spinal derivation tree) in Libin Shen's LTAG-spinal treebank. A typical sentence is represented in Libin Shen's thesis, page 73.
| Constructor Summary | |
|---|---|
Sentence(String representation)
Creates a new Sentence object from a string representation following
the format defined in Libin Shen's thesis. |
|
| Method Summary | |
|---|---|
void |
computeSpanTable()
Computes the span table, a directory whose keys are word spans and whose values are the corresponding subtrees (if any). |
boolean |
containsAdjunction()
Returns true iff at least one of the elementary trees in this Sentence is an auxiliary tree. |
boolean |
containsAttachment()
Returns true iff at least one of the elementary trees in this Sentence is an initial tree. |
boolean |
containsCoordination()
Returns true iff at least one of the elementary trees in this Sentence is a conjunction tree. |
ListIterator |
elemTreesIterator()
Iterates over the elementary trees of which this Sentence
consists, in the order in which they are numbered (left to right in the
sentence). |
ElemTree |
getElemTree(int n)
Returns the ElemTree associated with the nth word of
the sentence. |
List |
getElemTrees()
Returns a List of ElemTrees for
the given word span. |
List |
getElemTrees(int from,
int to)
Returns a List of ElemTrees for
the given word span. |
int |
getFileNumber()
Returns the number of the Penn Treebank file in which the current sentence occurred, or -1 if the sentence is not a Penn Treebank sentence. |
String |
getLocation()
Returns a String representing the location of the current sentence
-- i.e. |
ElemTree |
getRoot()
Returns the elementary tree at the root of this Sentence. |
int |
getSectionNumber()
Returns the number of the Penn Treebank section in which the current sentence occurred, or -1 if the sentence is not a Penn Treebank sentence. |
int |
getSentenceNumber()
Returns the number of the current sentence in the Penn Treebank file or parser output. |
ElemTree |
getSubTree(int start,
int end)
Returns the unique ElemTree that is the root of a subtree whose
yield is the specified word span, or null if there is no such
tree. |
ElemTree |
getSubTree(WordSpan w)
Returns the unique ElemTree that is the root of a subtree whose
yield is the specified word span, or null if there is no such
tree. |
boolean |
isBidirectionalParserOutput()
Returns true if this Sentence has been read in from the
format used in the output of Shen's bidirectional parser. |
boolean |
isSkipped()
Returns true iff the annotation for this sentence only consists of the word "skip", indicating that it is contained in the Penn Treebank but not in the LTAG-spinal treebank. |
int |
length()
Returns the length of this Sentence, that is, the number of elementary
trees in this derivation tree. |
Sentence |
ofString(String representation)
Convenience method that calls the constructor, to follow the conventions in the Propbank API. |
String |
prettyPrintLocation()
Returns a human-readable string representing the location of the current sentence. |
static Sentence |
readTree(BufferedReader inp)
Reads a string representation of a derivation tree from the specified BufferedReader. |
ElemTree |
subTreeForSpan(WordSpan w)
Returns the ElemTree whose yield is the given word span,
or null if there isn't one. |
String |
toGraphviz(boolean includeSpans,
boolean beanPoleStyle,
boolean showSpines)
Returns a visual representation of this sentence in Graphviz format. |
String |
toGraphviz(int start,
int end,
boolean includeSpans,
boolean beanPoleStyle,
boolean showSpines)
Returns a visual representation of a subpart of this sentence in Graphviz format. |
String |
toString()
Returns a string representation of this sentence in LTAG-spinal format. |
void |
writeGraphvizTo(BufferedWriter b,
boolean includeSpans,
boolean beanPoleStyle,
boolean showSpines)
Writes a visual representation of this sentence in Graphviz format to the specified BufferedWriter. |
void |
writeGraphvizTo(BufferedWriter b,
int start,
int end,
boolean includeSpans,
boolean beanPoleStyle,
boolean showSpines)
Writes a visual representation of a subpart of this sentence in Graphviz format to the specified BufferedWriter. |
void |
writeGraphvizTo(Writer w,
boolean includeSpans,
boolean beanPoleStyle,
boolean showSpines)
Writes a visual representation of this sentence in Graphviz format to the specified Writer. |
void |
writeGraphvizTo(Writer w,
int start,
int end,
boolean includeSpans,
boolean beanPoleStyle,
boolean showSpines)
Writes a visual representation of a subpart of this sentence in Graphviz format to the specified Writer. |
void |
writeTo(BufferedWriter b)
Prints this sentence to the specified output in LTAG-spinal format. |
void |
writeTo(Writer w)
Prints this sentence to the specified output in LTAG-spinal format. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Sentence(String representation)
throws ElemTreeFormatException
Sentence object from a string representation following
the format defined in Libin Shen's thesis.
representation - a String containing a specification of
a sentence in LTAG-spinal format
ElemTreeFormatException - if an error occurs while parsing the string representation| Method Detail |
|---|
public Sentence ofString(String representation)
throws ElemTreeFormatException
representation - a String containing a specification of
a sentence in LTAG-spinal format
Sentence constructed from the given String
ElemTreeFormatException - if an error occurs while parsing the string representation
public static Sentence readTree(BufferedReader inp)
throws ElemTreeFormatException,
IOException
BufferedReader.
inp - the BufferedReader from which to read
Sentence element representing the derivation tree, or null
if the input contained nothing or contained only whitespace
ElemTreeFormatException - if an error occurs while parsing the string representation
IOException - if an error occurs while reading
public void writeTo(Writer w)
throws IOException
w - the Writer to which this sentence is to be written
IOException - if an error occurs during writing
public void writeTo(BufferedWriter b)
throws IOException
b - the BufferedWriter to which this sentence is to be written
IOException - if an error occurs during writing
public void writeGraphvizTo(BufferedWriter b,
int start,
int end,
boolean includeSpans,
boolean beanPoleStyle,
boolean showSpines)
throws IOException
BufferedWriter.
b - the BufferedWriter to which the subsentence is to be writtenstart - the first word of the sentence to be included in the graphical outputend - the last word of the sentence to be included in the graphical outputincludeSpans - if true, the word span of the subtree dominated by a node
is appended to that node's representation; otherwise, it only
consists of the node labelbeanPoleStyle - chooses between two very different styles of output -- if true,
the output looks like beanpoles, if false, it looks like tadpoles. See the
illustrations on the LTAG-spinal website.showSpines - if true, shows the internal structure of the elementary trees;
otherwise, shows each elementary tree as one single node
IOException - if an error occurs during writing
public void writeGraphvizTo(Writer w,
boolean includeSpans,
boolean beanPoleStyle,
boolean showSpines)
throws IOException
Writer.
w - the Writer to which this sentence is to be writtenincludeSpans - if true, the word span of the subtree dominated by a node
is appended to that node's representation; otherwise, it only
consists of the node labelbeanPoleStyle - chooses between two very different styles of output -- if true,
the output looks like beanpoles, if false, it looks like tadpoles. See the
illustrations on the LTAG-spinal website.showSpines - if true, shows the internal structure of the elementary trees;
otherwise, shows each elementary tree as one single node
IOException - if an error occurs while writing
public void writeGraphvizTo(Writer w,
int start,
int end,
boolean includeSpans,
boolean beanPoleStyle,
boolean showSpines)
throws IOException
Writer.
w - the Writer to which the subsentence is to be writtenstart - the first word of the sentence to be included in the graphical outputend - the last word of the sentence to be included in the graphical outputincludeSpans - if true, the word span of the subtree dominated by a node
is appended to that node's representation; otherwise, it only
consists of the node labelbeanPoleStyle - chooses between two very different styles of output -- if true,
the output looks like beanpoles, if false, it looks like tadpoles. See the
illustrations on the LTAG-spinal website.showSpines - if true, shows the internal structure of the elementary trees;
otherwise, shows each elementary tree as one single node
IOException - if an error occurs while writing
public void writeGraphvizTo(BufferedWriter b,
boolean includeSpans,
boolean beanPoleStyle,
boolean showSpines)
throws IOException
BufferedWriter.
b - the BufferedWriter to which this sentence is to be writtenincludeSpans - if true, the word span of the subtree dominated by a node
is appended to that node's representation; otherwise, it only
consists of the node labelbeanPoleStyle - chooses between two very different styles of output -- if true,
the output looks like beanpoles, if false, it looks like tadpoles. See the
illustrations on the LTAG-spinal website.showSpines - if true, shows the internal structure of the elementary trees;
otherwise, shows each elementary tree as one single node
IOException - if an error occurs while writingpublic String toString()
toString in class Object
public String toGraphviz(boolean includeSpans,
boolean beanPoleStyle,
boolean showSpines)
includeSpans - if true, the word span of the subtree dominated by a node
is appended to that node's representation; otherwise, it only
consists of the node labelbeanPoleStyle - chooses between two very different styles of output -- if true,
the output looks like beanpoles, if false, it looks like tadpoles. See the
illustrations on the LTAG-spinal website.showSpines - if true, shows the internal structure of the elementary trees;
otherwise, shows each elementary tree as one single node
String containing Graphviz format
public String toGraphviz(int start,
int end,
boolean includeSpans,
boolean beanPoleStyle,
boolean showSpines)
start - the first word of the sentence to be included in the graphical outputend - the last word of the sentence to be included in the graphical outputincludeSpans - if true, the word span of the subtree dominated by a node
is appended to that node's representation; otherwise, it only
consists of the node labelbeanPoleStyle - chooses between two very different styles of output -- if true,
the output looks like beanpoles, if false, it looks like tadpoles. See the
illustrations on the LTAG-spinal website.showSpines - if true, shows the internal structure of the elementary trees;
otherwise, shows each elementary tree as one single node
String containing Graphviz formatpublic String getLocation()
String representing the location of the current sentence
-- i.e. either a triple of section, file, and sentence number as
in the LTAG-spinal treebank (following the Penn Treebank conventions),
or simply a sentence number if the sentence is not from the
LTAG-spinal treebank.
public String prettyPrintLocation()
Section: X File: Y Sentence: ZOtherwise, if the sentence only has a sentence number, the string looks like
Sentence: Z
public ElemTree getSubTree(WordSpan w)
ElemTree that is the root of a subtree whose
yield is the specified word span, or null if there is no such
tree.
w - the span from the first up to and including the last word
ElemTree or null
SkippedSentenceException - if the current sentence
is a skipped sentence in the LTAG-spinal treebank
public ElemTree getSubTree(int start,
int end)
ElemTree that is the root of a subtree whose
yield is the specified word span, or null if there is no such
tree.
start - the first (leftmost) word included in the spanend - the last (rightmost) word included in the span
ElemTree or null
SkippedSentenceException - if the current sentence
is a skipped sentence in the LTAG-spinal treebankpublic boolean isBidirectionalParserOutput()
Sentence has been read in from the
format used in the output of Shen's bidirectional parser. If this is the case,
no information about the spine is present. This is implemented as a simple
lookup of the corresponding property of the ElemTree at
the root of this sentence.
ElemTree.isBidirectionalParserOutput()public boolean isSkipped()
public int getSentenceNumber()
public int getSectionNumber()
public int getFileNumber()
public ElemTree subTreeForSpan(WordSpan w)
ElemTree whose yield is the given word span,
or null if there isn't one.
w - the WordSpan for which the dominating tree
is to be returned
ElemTree or null
SkippedSentenceException - if the current sentence
is a skipped sentence in the LTAG-spinal treebankpublic void computeSpanTable()
SkippedSentenceException - if the current sentence
is a skipped sentence in the LTAG-spinal treebankpublic boolean containsAttachment()
Sentence is an initial tree.
SkippedSentenceException - if the current sentence
is a skipped sentence in the LTAG-spinal treebankpublic boolean containsAdjunction()
Sentence is an auxiliary tree.
SkippedSentenceException - if the current sentence
is a skipped sentence in the LTAG-spinal treebankpublic boolean containsCoordination()
Sentence is a conjunction tree.
SkippedSentenceException - if the current sentence
is a skipped sentence in the LTAG-spinal treebankpublic int length()
Sentence, that is, the number of elementary
trees in this derivation tree.
Sentence
SkippedSentenceException - if the current sentence
is a skipped sentence in the LTAG-spinal treebankpublic ElemTree getRoot()
Sentence.
ElemTree in which this derivation tree is rooted
SkippedSentenceException - if the current sentence
is a skipped sentence in the LTAG-spinal treebankpublic ListIterator elemTreesIterator()
Sentence
consists, in the order in which they are numbered (left to right in the
sentence).
ListIterator
SkippedSentenceException - if the current sentence
is a skipped sentence in the LTAG-spinal treebankpublic ElemTree getElemTree(int n)
ElemTree associated with the nth word of
the sentence.
n - a number between 0 and the length of the sentence
ElemTree for the nth word of the sentence
IndexOutOfBoundsException - if index is out of range (index
< 0 || index >= size()).public List getElemTrees()
List of ElemTrees for
the given word span.
SkippedSentenceException - if the current sentence
is a skipped sentence in the LTAG-spinal treebank
public List getElemTrees(int from,
int to)
List of ElemTrees for
the given word span.
from - the first word to be included in the listto - the last word to be included in the list
SkippedSentenceException - if the current sentence
is a skipped sentence in the LTAG-spinal treebank
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||