public class ParseHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
PATH_DOWN_STRING
This string indicates a path going down a parse tree in the path string.
|
static String |
PATH_UP_STRING
This string indicates a path going up a parse tree in the path string.
|
Constructor and Description |
---|
ParseHelper() |
Modifier and Type | Method and Description |
---|---|
static String[] |
getAllPhraseSiblingLabels(String parseViewName,
Constituent constituent)
Get the labels of all the siblings of the parse tree node that covers the
input constituent.
|
static String[] |
getAllSiblingLabels(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> node)
Get the labels of all siblings of a given tree node.
|
static <T> edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> |
getCommonAncestor(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> t1,
edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> t2,
edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree)
Deprecated.
|
static int |
getHeadWordPosition(Constituent c,
HeadFinderBase headFinder,
String parseViewName)
Get the head word of a constituent using the
HeadFinderBase that
is passed as an argument. |
static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> |
getParseTree(String parseViewName,
Sentence s)
Get the parse tree of a sentence.
|
static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> |
getParseTree(String parseViewName,
TextAnnotation ta,
int sentenceId)
Get the parse tree of the
sentenceId th sentence from the
text annotation. |
static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> |
getParseTree(TextAnnotation ta,
int sentenceId)
Deprecated.
|
static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> |
getParseTreeCovering(String parseViewName,
Constituent c)
Get a parse tree from a text annotation that covers the specified
constituent.
|
static <T> edu.illinois.cs.cogcomp.core.datastructures.Pair<List<edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T>>,List<edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T>>> |
getPath(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> start,
edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> end,
edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree,
int maxDepth)
Deprecated.
|
static <T> String |
getPathString(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> start,
edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> end,
edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree,
int maxDepth)
Deprecated.
|
static <T> String |
getPathStringIgnoreLexicalItems(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> start,
edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> end,
edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree,
int maxDepth)
Deprecated.
|
static <T> String |
getPathStringToCommonAncestor(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> start,
edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> end,
edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree,
int maxDepth)
Deprecated.
|
static <T> List<T> |
getPathToRoot(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree,
edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> leaf,
int maxDepth)
Deprecated.
|
static <T> List<edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T>> |
getPathTreesToRoot(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree,
edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> node,
int maxDepth)
Deprecated.
|
static String |
getSubcatFrame(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> yieldNode)
Assuming that the tree comes with lexical items and POS tags, the subcat
frame for the verb can be found by going to the parent of the POS tag
(which is probably a VP) and listing its children.
|
static String |
getTerminalString(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree) |
static String |
getTerminalStringSentence(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree) |
static List<String> |
getTerminalTokens(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> 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>> |
getTokenIndexedCleanedParseTreeNodeCovering(Constituent c,
String parseViewName) |
static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<edu.illinois.cs.cogcomp.core.datastructures.Pair<String,edu.illinois.cs.cogcomp.core.datastructures.IntPair>> |
getTokenIndexedParseTreeNodeCovering(String parseViewName,
Constituent c) |
static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<edu.illinois.cs.cogcomp.core.datastructures.Pair<String,edu.illinois.cs.cogcomp.core.datastructures.IntPair>> |
getTokenIndexedTreeCovering(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> parse,
int start,
int end)
From a parse tree and a span that is specified with the start and end
(exclusive), this function returns a tree that corresponds to the subtree
that covers the span.
|
static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> |
getTreeCovering(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> parse,
int start,
int end) |
static void |
main(String[] args) |
public static final String PATH_UP_STRING
public static final String PATH_DOWN_STRING
public static String[] getAllPhraseSiblingLabels(String parseViewName, Constituent constituent)
parseViewName
- The name of the parse view. This might typically be one of
ViewNames.PARSE_CHARNIAK or ViewNames.PARSE_STANFORDconstituent
- The constituent whose sibling phrases are required.public static String[] getAllSiblingLabels(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> node)
node
- The node whose siblings are required.@Deprecated public static <T> edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> getCommonAncestor(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> t1, edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> t2, edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree) throws Exception
T
- t1
- The first treet2
- The second treetree
- The tree that contains t1
and t2
.t1
and t2
. If none is found, then the function returns null.Exception
public static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> getParseTree(String parseViewName, Sentence s)
parseViewName
exists in the text annotation.parseViewName
- The name of the parse views
- The sentencepublic static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> getParseTree(String parseViewName, TextAnnotation ta, int sentenceId)
sentenceId
th sentence from the
text annotation. This code assumes that the view called parseViewName
exists in the text annotation.parseViewName
- The name of the parse viewta
- The text annotation objectsentenceId
- The sentence whose parse tree is requiredsentenceId
th sentence@Deprecated public static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> getParseTree(TextAnnotation ta, int sentenceId)
sentenceId
th sentence
from the text annotation. This code assumes that the view called
ViewNames.PARSE_CHARNIAK exists in the text annotation.ta
- The text annotation objectsentenceId
- The sentence whose parse tree is requiredsentenceId
th sentencepublic static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> getParseTreeCovering(String parseViewName, Constituent c)
parseViewName
- The name of the parse viewc
- The constituent that we care aboutTextAnnotation
to
which the constituent belongs which covers the constituent.@Deprecated public static <T> edu.illinois.cs.cogcomp.core.datastructures.Pair<List<edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T>>,List<edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T>>> getPath(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> start, edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> end, edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree, int maxDepth) throws Exception
T
- start
- end
- tree
- maxDepth
- Exception
@Deprecated public static <T> String getPathString(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> start, edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> end, edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree, int maxDepth) throws Exception
start
and
end
that belong to the tree tree
T
- start
- end
- tree
- maxDepth
- Exception
@Deprecated public static <T> String getPathStringIgnoreLexicalItems(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> start, edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> end, edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree, int maxDepth) throws Exception
Exception
@Deprecated public static <T> String getPathStringToCommonAncestor(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> start, edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> end, edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree, int maxDepth) throws Exception
Exception
@Deprecated public static <T> List<T> getPathToRoot(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree, edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> leaf, int maxDepth) throws Exception
Exception
@Deprecated public static <T> List<edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T>> getPathTreesToRoot(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> tree, edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<T> node, int maxDepth) throws Exception
T
- tree
- node
- maxDepth
- Exception
public static String getSubcatFrame(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> yieldNode)
yieldNode
- public static String getTerminalString(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree)
public static String getTerminalStringSentence(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree)
public static List<String> getTerminalTokens(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> tree)
public static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<edu.illinois.cs.cogcomp.core.datastructures.Pair<String,edu.illinois.cs.cogcomp.core.datastructures.IntPair>> getTokenIndexedCleanedParseTreeNodeCovering(Constituent c, String parseViewName)
public static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<edu.illinois.cs.cogcomp.core.datastructures.Pair<String,edu.illinois.cs.cogcomp.core.datastructures.IntPair>> getTokenIndexedParseTreeNodeCovering(String parseViewName, Constituent c)
public static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<edu.illinois.cs.cogcomp.core.datastructures.Pair<String,edu.illinois.cs.cogcomp.core.datastructures.IntPair>> getTokenIndexedTreeCovering(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> parse, int start, int end)
parse
- start
- end
- public static edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> getTreeCovering(edu.illinois.cs.cogcomp.core.datastructures.trees.Tree<String> parse, int start, int end)
public static int getHeadWordPosition(Constituent c, HeadFinderBase headFinder, String parseViewName) throws EdisonException
HeadFinderBase
that
is passed as an argument. To use this function, first, a head finder
should be created. For example:
TextAnnotation ta = ... // some text annotation Constituent c = ... // some constituent CollinsHeadFinder headFinder = new CollinsHeadFinder(); int headId = ParseHelper.getHeadWordPosition(c, headFinder); // now we can do other things with the headId. String headWord = WordHelpers.getWord(ta, headId);
parseViewName
- The name of the view which contains the parse treesc
- The constituent whose head we wish to findheadFinder
- The head finderWordHelpers.getWord(TextAnnotation, int)
.EdisonException
Copyright © 2015. All rights reserved.