public class ParseHelper extends Object
Sep 30, 2009
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(Tree<String> node)
Get the labels of all siblings of a given tree node.
|
static <T> Tree<T> |
getCommonAncestor(Tree<T> t1,
Tree<T> t2,
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 Tree<String> |
getParseTree(String parseViewName,
Sentence s)
Get the parse tree of a sentence.
|
static Tree<String> |
getParseTree(String parseViewName,
TextAnnotation ta,
int sentenceId)
Get the parse tree of the
sentenceId th sentence from the text annotation. |
static Tree<String> |
getParseTree(TextAnnotation ta,
int sentenceId)
Deprecated.
|
static Tree<String> |
getParseTreeCovering(String parseViewName,
Constituent c)
Get a parse tree from a text annotation that covers the specified constituent.
|
static <T> Pair<List<Tree<T>>,List<Tree<T>>> |
getPath(Tree<T> start,
Tree<T> end,
Tree<T> tree,
int maxDepth)
Deprecated.
|
static <T> String |
getPathString(Tree<T> start,
Tree<T> end,
Tree<T> tree,
int maxDepth)
Deprecated.
|
static <T> String |
getPathStringIgnoreLexicalItems(Tree<T> start,
Tree<T> end,
Tree<T> tree,
int maxDepth)
Deprecated.
|
static <T> String |
getPathStringToCommonAncestor(Tree<T> start,
Tree<T> end,
Tree<T> tree,
int maxDepth)
Deprecated.
|
static <T> List<T> |
getPathToRoot(Tree<T> tree,
Tree<T> leaf,
int maxDepth)
Deprecated.
|
static <T> List<Tree<T>> |
getPathTreesToRoot(Tree<T> tree,
Tree<T> node,
int maxDepth)
Deprecated.
|
static Constituent |
getPhraseFromHead(Constituent predicate,
Constituent argHead,
String parseViewName)
Primarily a fix for prepSRL objects; converts them from single head words to constituents.
|
static String |
getSubcatFrame(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(Tree<String> tree) |
static String |
getTerminalStringSentence(Tree<String> tree) |
static List<String> |
getTerminalTokens(Tree<String> tree) |
static Tree<Pair<String,IntPair>> |
getTokenIndexedCleanedParseTreeNodeCovering(Constituent c,
String parseViewName) |
static Tree<Pair<String,IntPair>> |
getTokenIndexedParseTreeNodeCovering(String parseViewName,
Constituent c) |
static Tree<Pair<String,IntPair>> |
getTokenIndexedTreeCovering(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 Tree<String> |
getTreeCovering(Tree<String> parse,
int start,
int end) |
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(Tree<String> node)
node
- The node whose siblings are required.@Deprecated public static <T> Tree<T> getCommonAncestor(Tree<T> t1, Tree<T> t2, Tree<T> tree) throws Exception
T
- The type of treet1
- 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 Tree<String> getParseTree(String parseViewName, Sentence s)
parseViewName
exists in the text annotation.parseViewName
- The name of the parse views
- The sentencepublic static 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 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 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> Pair<List<Tree<T>>,List<Tree<T>>> getPath(Tree<T> start, Tree<T> end, Tree<T> tree, int maxDepth) throws Exception
Exception
@Deprecated public static <T> String getPathString(Tree<T> start, Tree<T> end, Tree<T> tree, int maxDepth) throws Exception
start
and end
that belong to
the tree tree
Exception
@Deprecated public static <T> String getPathStringIgnoreLexicalItems(Tree<T> start, Tree<T> end, Tree<T> tree, int maxDepth) throws Exception
Exception
@Deprecated public static <T> String getPathStringToCommonAncestor(Tree<T> start, Tree<T> end, Tree<T> tree, int maxDepth) throws Exception
Exception
@Deprecated public static <T> List<T> getPathToRoot(Tree<T> tree, Tree<T> leaf, int maxDepth) throws Exception
Exception
@Deprecated public static <T> List<Tree<T>> getPathTreesToRoot(Tree<T> tree, Tree<T> node, int maxDepth) throws Exception
Exception
public static String getSubcatFrame(Tree<String> yieldNode)
public static Tree<Pair<String,IntPair>> getTokenIndexedCleanedParseTreeNodeCovering(Constituent c, String parseViewName)
public static Tree<Pair<String,IntPair>> getTokenIndexedParseTreeNodeCovering(String parseViewName, Constituent c)
public static Tree<Pair<String,IntPair>> getTokenIndexedTreeCovering(Tree<String> parse, int start, int end)
public static int getHeadWordPosition(Constituent c, HeadFinderBase headFinder, String parseViewName) throws Exception
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
Exception
public static Constituent getPhraseFromHead(Constituent predicate, Constituent argHead, String parseViewName)
predicate
- The predicate of the construction (e.g. "with")argHead
- The head-word of the argument of the construction (e.g. "telescope")parseViewName
- The name of the parse view used to extract the phrase-structure treeCopyright © 2017. All rights reserved.