public class ParseUtils extends Object
ParseHelper
because
unlike the members of that class, these functions transform a given parse
tree (or its components) into a different form and have a more general usage
than just feature extraction.Constructor and Description |
---|
ParseUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
convertBracketsFromPTBFormat(String sentence)
Convert brackets from the Penn treebank format (which uses strings like
-LRB-, -RRB-, etc to denote '(', ')', etc.) to readable tokens.
|
static String |
convertBracketsToPTBFormat(String sentence)
Convert brackets from readable forms to the Penn treebank format (which
uses strings like -LRB-, -RRB-, etc to denote '(', ')', etc.)
|
static String |
getSentenceFromTree(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree)
Gets the terminal string from the parse tree.
|
static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<edu.illinois.cs.cogcomp.core.datastructures.Pair<String,edu.illinois.cs.cogcomp.core.datastructures.IntPair>> |
getSpanLabeledTree(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> parseTree)
Transforms a parse tree into a new tree where each node is labeled by the
span it covers in addition to the label of that node from the original
parse tree.
|
static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> |
snipNullNodes(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree)
Removes subtrees labeled with the null label (-NONE-) and returns a new
tree
|
static String |
stripFunctionTags(String label)
Strips function tags from a given node label.
|
static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> |
stripFunctionTags(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree)
Strips function tags from a tree and returns a new tree.
|
static String |
stripIndexReferences(String label) |
static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> |
stripIndexReferences(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree)
Removes index information in the parse tree to other nodes.
|
public static String convertBracketsFromPTBFormat(String sentence)
sentence
- A sentence which is to be convertedpublic static String convertBracketsToPTBFormat(String sentence)
sentence
- A sentence which is to be convertedpublic static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<edu.illinois.cs.cogcomp.core.datastructures.Pair<String,edu.illinois.cs.cogcomp.core.datastructures.IntPair>> getSpanLabeledTree(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> parseTree)
For example, consider the following input tree:
(S1 (S (NP (DT The) (NN bird)) (VP (VBD flew))) (. .))This is transformed as follows:
([S1,[0,4]] ([S,[0,4]] ([NP,[0,2]] ([DT,[0,1]] [The,<0,1]]) ([NN,[1,2]] [bird,[1,2]])) ([VP,[2,3]] ([VBD,[2,3]] [flew,[2,3]])) ([.,[3,4]] [.,[3,4]])))Here, the notation [.,.] is used to denote a
Pair
object. That
is, the node labeled [NP,[0,2]] indicates that the corresponding node in
the parse tree is labeled NP and that NP spans the tokens ranging from 0
to 2 (exclusive.)parseTree
- The parse tree to be annotated with the spansPair
of the original
node's label and the span that the node covers.public static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> snipNullNodes(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree)
tree
- A parse tree, possibly containing null labelspublic static String stripFunctionTags(String label)
label
- A node labelpublic static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> stripFunctionTags(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree)
tree
- A parse treepublic static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> stripIndexReferences(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree)
tree
- A parse treepublic static String getSentenceFromTree(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree)
tree
- The parse tree, where the leaf nodes are the terminals we care
aboutCopyright © 2015. All rights reserved.