public class TreePrint
extends java.lang.Object
edu.stanford.nlp.trees.Tree
as the output of the
parser. This class supports printing in multiple ways and altering
behavior via properties specified at construction.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
headMark |
static java.lang.String[] |
outputTreeFormats
The legal output tree formats.
|
static java.lang.String |
rootLabelOnlyFormat |
Constructor and Description |
---|
TreePrint(java.lang.String formats)
Construct a new TreePrint that will print the given formats.
|
TreePrint(java.lang.String formats,
java.lang.String options,
TreebankLanguagePack tlp)
Make a TreePrint instance.
|
TreePrint(java.lang.String formatString,
java.lang.String optionsString,
TreebankLanguagePack tlp,
HeadFinder hf,
HeadFinder typedDependencyHF)
Make a TreePrint instance.
|
TreePrint(java.lang.String formats,
TreebankLanguagePack tlp)
Make a TreePrint instance with no options specified.
|
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] args)
This provides a simple main method for calling TreePrint.
|
Tree |
markHeadNodes(Tree t) |
static void |
print(java.util.Collection<TypedDependency> dependencies,
boolean includeTags,
java.io.PrintWriter pw)
USED BY TREEPRINT AND WSD.SUPWSD.PREPROCESS
Prints this set of typed dependencies to the specified
PrintWriter . |
static void |
print(java.util.Collection<TypedDependency> dependencies,
java.lang.String format,
boolean includeTags,
java.io.PrintWriter pw)
USED BY TREEPRINT
Prints this set of typed dependencies to the specified
PrintWriter in the specified format. |
void |
printFooter(java.io.PrintWriter pw) |
void |
printHeader(java.io.PrintWriter pw,
java.lang.String charset) |
void |
printTree(Tree t)
Prints the tree to the default PrintWriter.
|
void |
printTree(Tree t,
java.io.PrintWriter pw)
Prints the tree, with an empty ID.
|
void |
printTree(Tree t,
java.lang.String id,
java.io.PrintWriter pw)
Prints the tree according to the options specified for this instance.
|
void |
printTrees(java.util.List<ScoredObject<Tree>> trees,
java.lang.String id,
java.io.PrintWriter pw)
Prints the trees according to the options specified for this instance.
|
public static final java.lang.String rootLabelOnlyFormat
public static final java.lang.String headMark
public static final java.lang.String[] outputTreeFormats
public TreePrint(java.lang.String formats)
formats
- The formats to print the tree in.public TreePrint(java.lang.String formats, TreebankLanguagePack tlp)
public TreePrint(java.lang.String formats, java.lang.String options, TreebankLanguagePack tlp)
public TreePrint(java.lang.String formatString, java.lang.String optionsString, TreebankLanguagePack tlp, HeadFinder hf, HeadFinder typedDependencyHF)
formatString
- A comma separated list of ways to print each Tree.
For instance, "penn" or "words,typedDependencies".
Known formats are: oneline, penn, latexTree, xmlTree, words,
wordsAndTags, rootSymbolOnly, dependencies,
typedDependencies, typedDependenciesCollapsed,
collocations, semanticGraph, conllStyleDependencies,
conll2007. The last two are both tab-separated values
formats. The latter has a lot more columns filled with
underscores. All of them print a blank line after
the output except for oneline. oneline is also not
meaningful in XML output (it is ignored: use penn instead).
(Use of typedDependenciesCollapsed is deprecated. It
works but we recommend instead selecting a type of
dependencies using the optionsString argument. Note in
particular that typedDependenciesCollapsed does not do
CC propagation, which we generally recommend.)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, basicDependencies, treeDependencies,
CCPropagatedDependencies, collapsedDependencies, nonCollapsedDependencies,
nonCollapsedDependenciesSeparated, includeTags
.tlp
- The TreebankLanguagePack used to do things like delete
or ignore punctuation in outputhf
- The HeadFinder used in printing outputpublic void printTree(Tree t)
t
- The tree to displaypublic void printTree(Tree t, java.io.PrintWriter pw)
t
- The tree to displaypw
- The PrintWriter to print it topublic void printTree(Tree t, java.lang.String id, java.io.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 display the treepublic void printTrees(java.util.List<ScoredObject<Tree>> trees, java.lang.String id, java.io.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(java.io.PrintWriter pw, java.lang.String charset)
public void printFooter(java.io.PrintWriter pw)
public static void main(java.lang.String[] args)
args
- Command line arguments, as above.public static void print(java.util.Collection<TypedDependency> dependencies, boolean includeTags, java.io.PrintWriter pw)
PrintWriter
.dependencies
- The collection of TypedDependency to printpw
- Where to print thempublic static void print(java.util.Collection<TypedDependency> dependencies, java.lang.String format, boolean includeTags, java.io.PrintWriter pw)
PrintWriter
in the specified format.dependencies
- The collection of TypedDependency to printformat
- "xml" or "readable" or otherpw
- Where to print them