|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.trees.TreePrint
public class TreePrint
A class for customizing the print method(s) for a
edu.stanford.nlp.trees.Tree
as the output of the
parser. This class supports printing in multiple ways and altering
behavior via properties.
Field Summary | |
---|---|
static String |
headMark
|
static String[] |
outputTreeFormats
The legal output tree formats. |
static String |
rootLabelOnlyFormat
|
Constructor Summary | |
---|---|
TreePrint(String formats)
The anglocentric constructor. |
|
TreePrint(String formats,
String options,
TreebankLanguagePack tlp)
|
|
TreePrint(String formatString,
String optionsString,
TreebankLanguagePack tlp,
HeadFinder hf)
Make a TreePrint instance. |
|
TreePrint(String formats,
TreebankLanguagePack tlp)
|
Method Summary | |
---|---|
HeadFinder |
getHeadFinder()
|
PrintWriter |
getPrintWriter()
|
static void |
main(String[] args)
This provides a simple main method for calling TreePrint. |
Tree |
markHeadNodes(Tree t)
|
static void |
print(Collection<TypedDependency> dependencies,
PrintWriter pw)
USED BY TREEPRINT AND WSD.SUPWSD.PREPROCESS Prints this set of typed dependencies to the specified PrintWriter . |
static void |
print(Collection<TypedDependency> dependencies,
String format,
PrintWriter pw)
USED BY TREEPRINT Prints this set of typed dependencies to the specified PrintWriter in the specified format. |
void |
printFooter(PrintWriter pw)
|
void |
printHeader(PrintWriter pw,
String charset)
|
void |
printTree(Tree t)
Prints the tree to the default PrintWriter. |
void |
printTree(Tree t,
PrintWriter pw)
Prints the tree, with an empty ID. |
void |
printTree(Tree t,
String id,
PrintWriter pw)
Prints the tree according to the options specified for this instance. |
void |
printTrees(List<ScoredObject<Tree>> trees,
String id,
PrintWriter pw)
Prints the trees according to the options specified for this instance. |
void |
setHeadFinder(HeadFinder hf)
Set the headfinder to be used for lexicalizing trees. |
void |
setPrintWriter(PrintWriter pw)
Sets the default print writer for printing trees with the instance. |
void |
setStem(boolean stem)
Sets whether or not to stem the Trees using Morphology. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String rootLabelOnlyFormat
public static final String[] outputTreeFormats
public static final String headMark
Constructor Detail |
---|
public TreePrint(String formats)
formats
- The formats to print the tree in.public TreePrint(String formats, TreebankLanguagePack tlp)
public TreePrint(String formats, String options, TreebankLanguagePack tlp)
public TreePrint(String formatString, String optionsString, TreebankLanguagePack tlp, HeadFinder hf)
formatString
- A comma separated list of ways to print each Tree.
For instance, "penn" or "words,typedDependencies".
Known formats are: oneline, penn, latexTree, words,
wordsAndTags, rootSymbolOnly, dependencies,
typedDependencies, typedDependenciesCollapsed,
collocations, semanticGraph. All of them print a blank line after
the output except for oneline. oneline is also not
meaningul in XML output (it is ignored: use penn instead).optionsString
- Options that additionally specify how trees are to
be printed (for instance, whether stemming should be done).
Known options are: stem, lexicalize, markHeadNodes,
xml, removeTopBracket, transChinese,
includePunctuationDependencies
.tlp
- The TreebankLanguagePack used to do things like delete
or ignore punctuation in outputhf
- The HeadFinder used in printing outputMethod Detail |
---|
public void printTree(Tree t)
t
- The tree to displaypublic void printTree(Tree t, PrintWriter pw)
t
- The tree to displaypw
- The PrintWriter to print it topublic void printTree(Tree t, String id, PrintWriter pw)
t
is null
, then the code prints
a line indicating a skipped tree. Under the XML option this is
an s
element with the skipped
attribute having
value true
, and, otherwise, it is the token
SENTENCE_SKIPPED_OR_UNPARSABLE
.
t
- The tree to displayid
- A name for this sentencepw
- Where to dislay the treepublic void printTrees(List<ScoredObject<Tree>> trees, String id, PrintWriter pw)
t
is null
, then the code prints
a line indicating a skipped tree. Under the XML option this is
an s
element with the skipped
attribute having
value true
, and, otherwise, it is the token
SENTENCE_SKIPPED_OR_UNPARSABLE
.
trees
- The list of trees to displayid
- A name for this sentencepw
- Where to dislay the treepublic void printHeader(PrintWriter pw, String charset)
public void printFooter(PrintWriter pw)
public void setStem(boolean stem)
stem
- Whether to stem each wordpublic void setHeadFinder(HeadFinder hf)
CollinsHeadFinder
is used.
hf
- The HeadFinder to usepublic HeadFinder getHeadFinder()
public void setPrintWriter(PrintWriter pw)
System.out
.
pw
- The PrintWriter to use for output by defaultpublic PrintWriter getPrintWriter()
public Tree markHeadNodes(Tree t)
public static void main(String[] args)
args
- Command line arguments, as above.public static void print(Collection<TypedDependency> dependencies, PrintWriter pw)
PrintWriter
.
dependencies
- The collection of TypedDependency to printpw
- Where to print thempublic static void print(Collection<TypedDependency> dependencies, String format, PrintWriter pw)
PrintWriter
in the specified format.
dependencies
- The collection of TypedDependency to printformat
- Where "xml" or "readable" or otherpw
- Where to print them
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |