tml.utils
Class StanfordUtils

java.lang.Object
  extended by tml.utils.StanfordUtils

public class StanfordUtils
extends java.lang.Object

Class to consolidate the calls to the Stanford parser

Author:
Jorge Villalon

Constructor Summary
StanfordUtils()
           
 
Method Summary
static java.util.List<java.lang.String> calculateTypedDependencies(edu.stanford.nlp.trees.Tree tree)
          Calculates the typed dependencies from a grammatical tree
static java.lang.String cleanNodeContent(java.lang.String content)
          Added to remove punctuation from the strings extracted from the tree
static java.util.List<java.lang.String> extractNouns(edu.stanford.nlp.trees.Tree t)
           
static java.util.List<java.lang.String> extractVerbs(edu.stanford.nlp.trees.Tree t)
           
static java.lang.String getPennString(edu.stanford.nlp.trees.Tree tree)
           
static java.lang.String getPennTagFirstBranch(edu.stanford.nlp.trees.Tree orig, edu.stanford.nlp.trees.Tree t, edu.stanford.nlp.trees.Tree pt)
           
static java.lang.String getPennTagMinimalPhrase(edu.stanford.nlp.trees.Tree t)
           
static edu.stanford.nlp.trees.Tree getPennTree(java.lang.String text)
           
static edu.stanford.nlp.trees.Tree getTreeFromString(java.lang.String passageId, java.lang.String pennTreeString)
          Calculates a Penn grammatical tree from its string representation
static java.lang.String nodeContent(edu.stanford.nlp.trees.Tree t)
           
static java.lang.String nodeContent(edu.stanford.nlp.trees.Tree t, edu.stanford.nlp.trees.Tree pv)
           
static java.lang.String removeDeterminersFromNounPhrase(java.lang.String phrase)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StanfordUtils

public StanfordUtils()
Method Detail

extractVerbs

public static java.util.List<java.lang.String> extractVerbs(edu.stanford.nlp.trees.Tree t)
Parameters:
t - a grammar tree to extract the verbs
Returns:
a list of verbs in the tree, an empty list if nothing is found.

nodeContent

public static java.lang.String nodeContent(edu.stanford.nlp.trees.Tree t,
                                           edu.stanford.nlp.trees.Tree pv)
Parameters:
t - the tree to which extract the content
Returns:
the string with the content of the tree

extractNouns

public static java.util.List<java.lang.String> extractNouns(edu.stanford.nlp.trees.Tree t)
Parameters:
t - the grammar tree
Returns:
a list with all concepts identified in a tree

cleanNodeContent

public static java.lang.String cleanNodeContent(java.lang.String content)
Added to remove punctuation from the strings extracted from the tree

Parameters:
content - any string containing punctuation at beginning or end
Returns:
the string without trailing or tailing punctuation

nodeContent

public static java.lang.String nodeContent(edu.stanford.nlp.trees.Tree t)
Parameters:
t - the tree to which extract the content
Returns:
the string with the content of the tree

getTreeFromString

public static edu.stanford.nlp.trees.Tree getTreeFromString(java.lang.String passageId,
                                                            java.lang.String pennTreeString)
Calculates a Penn grammatical tree from its string representation

Parameters:
pennTreeString - the string
Returns:
the grammar tree
Throws:
java.lang.Exception

calculateTypedDependencies

public static java.util.List<java.lang.String> calculateTypedDependencies(edu.stanford.nlp.trees.Tree tree)
Calculates the typed dependencies from a grammatical tree

Parameters:
tree - the grammatical tree

removeDeterminersFromNounPhrase

public static java.lang.String removeDeterminersFromNounPhrase(java.lang.String phrase)
                                                        throws java.io.IOException
Throws:
java.io.IOException

getPennString

public static java.lang.String getPennString(edu.stanford.nlp.trees.Tree tree)

getPennTree

public static edu.stanford.nlp.trees.Tree getPennTree(java.lang.String text)
                                               throws java.io.IOException
Throws:
java.io.IOException

getPennTagMinimalPhrase

public static java.lang.String getPennTagMinimalPhrase(edu.stanford.nlp.trees.Tree t)

getPennTagFirstBranch

public static java.lang.String getPennTagFirstBranch(edu.stanford.nlp.trees.Tree orig,
                                                     edu.stanford.nlp.trees.Tree t,
                                                     edu.stanford.nlp.trees.Tree pt)