edu.stanford.nlp.trees.semgraph
Class SemanticGraph

java.lang.Object
  extended by edu.stanford.nlp.trees.semgraph.SemanticGraph
All Implemented Interfaces:
Serializable

public class SemanticGraph
extends Object
implements Serializable

Represents a semantic graph of a sentence or document, with IndexedWord objects for nodes.

Note that given the kinds of representations that we normally use with typedDependenciesCollapsed that there can be (small) cycles in a SemanticGraph, and these cycles may involve the node that is conceptually the root of the graph, so there may be no node without a parent node. You can better get at the root(s) via the variable and methods provided.

Author:
Christopher Cox, Teg Grenager
See Also:
SemanticGraphEdge, IndexedWord, Serialized Form

Field Summary
static boolean addSRLArcs
           
 
Constructor Summary
SemanticGraph()
           
SemanticGraph(Collection<TypedDependency> dependencies, Collection<TreeGraphNode> roots)
          This is the constructor used by the parser.
SemanticGraph(Collection<TypedDependency> dependencies, Collection<TreeGraphNode> rootNodes, String docID, int sentIndex)
           
SemanticGraph(Collection<TypedDependency> dependencies, Collection<TreeGraphNode> rootNodes, String docID, int sentIndex, boolean lemmatize, boolean threadSafe)
           
SemanticGraph(SemanticGraph g)
          Returns a new SemanticGraph which is a copy of the supplied SemanticGraph.
SemanticGraph(SemanticGraph g, Map<IndexedWord,IndexedWord> prevToNewMap)
          Copies a the current graph, but also sets the mapping from the old to new graph.
 
Method Summary
 SemanticGraphEdge addEdge(IndexedWord s, IndexedWord d, GrammaticalRelation reln, double weight)
           
 void addRoot(IndexedWord root)
           
 void addVertex(IndexedWord vertex)
           
 boolean attachedNegatedVerb(IndexedWord vertex)
           
 List<Pair<GrammaticalRelation,IndexedWord>> childPairs(IndexedWord vertex)
          Returns a list of pairs of a relation name and the child IndexedFeatureLabel that bears that relation.
 Set<GrammaticalRelation> childRelns(IndexedWord vertex)
          Returns a list of relations which this node has with its children.
 int commonAncestor(IndexedWord v1, IndexedWord v2)
          Return the maximum distance to a least common ancestor.
 boolean containsEdge(IndexedWord source, IndexedWord target)
           
 boolean containsEdge(SemanticGraphEdge edge)
           
 boolean containsVertex(IndexedWord vertex)
           
 Set<IndexedWord> descendants(IndexedWord vertex)
          Returns the set of descendants governed by this node in the graph.
 int edgeCount()
           
 Iterable<SemanticGraphEdge> edgeIterable()
           
 List<SemanticGraphEdge> edgeListSorted()
          Returns an ordered list of edges in the graph.
 boolean equals(Object o)
           
 List<SemanticGraphEdge> findAllRelns(GrammaticalRelation tgtRelation)
          Given a semantic graph, and a target relation, returns a list of all relations (edges) matching.
 List<SemanticGraphEdge> getAllEdges(IndexedWord gov, IndexedWord dep)
           
 List<IndexedWord> getAllNodesByWordPattern(String pattern)
          Returns all nodes of type IndexedWord in this SemanticGraph having the given word or regex, or returns empty list if no such found.
 List<IndexedWord> getChildList(IndexedWord vertex)
           
 Collection<IndexedWord> getChildren(IndexedWord vertex)
           
 List<IndexedWord> getChildrenWithReln(IndexedWord vertex, GrammaticalRelation reln)
          Returns a list of all children bearing a certain grammatical relation, or an empty list if none.
 List<IndexedWord> getChildrenWithRelns(IndexedWord vertex, Collection<GrammaticalRelation> relns)
          Returns a list of all children bearing one of a set of grammatical relations, or an empty list if none.
 IndexedWord getChildWithReln(IndexedWord vertex, GrammaticalRelation reln)
          Returns the first IndexedFeatureLabel bearing a certain grammatical relation, or null if none.
 IndexedWord getCommonAncestor(IndexedWord v1, IndexedWord v2)
          Returns the least common ancestor.
 SemanticGraphEdge getEdge(IndexedWord gov, IndexedWord dep)
           
 SemanticGraphEdge getEdge(IndexedWord gov, IndexedWord dep, GrammaticalRelation reln)
          Given a governor, dependent, and the relation between them, returns the SemanticGraphEdge object of that arc if it exists, otherwise returns null.
 Set<SemanticGraphEdge> getEdgeSet()
          Return a set of all the edges in the graph.
 IndexedWord getFirstRoot()
          Returns the (first) root of this SemanticGraph.
 List<SemanticGraphEdge> getIncomingEdgesSorted(IndexedWord vertex)
           
 Set<IndexedWord> getLeafVertices()
           
 IndexedWord getNodeByIndex(int index)
          Returns the first IndexedWord in this SemanticGraph having the given integer index, or throws IllegalArgumentException if no such node is found.
 IndexedWord getNodeByIndexSafe(int index)
          Same as above, but returns null if the index does not exist (instead of throwing an exception).
 IndexedWord getNodeByWordPattern(String pattern)
          Returns the first IndexedWord in this SemanticGraph having the given word or regex, or return null if no such found.
 List<SemanticGraphEdge> getOutEdgesSorted(IndexedWord vertex)
           
 IndexedWord getParent(IndexedWord vertex)
           
 List<IndexedWord> getParentList(IndexedWord vertex)
           
 Collection<IndexedWord> getParents(IndexedWord vertex)
           
 List<IndexedWord> getParentsWithReln(IndexedWord vertex, GrammaticalRelation reln)
          Returns a list of all parents bearing a certain grammatical relation, or an empty list if none.
 List<IndexedWord> getPathToRoot(IndexedWord vertex)
           
 Collection<IndexedWord> getRoots()
           
 List<SemanticGraphEdge> getShortestDirectedPathEdges(IndexedWord source, IndexedWord target)
           
 List<IndexedWord> getShortestDirectedPathNodes(IndexedWord source, IndexedWord target)
          Returns the shortest directed path between two edges in the graph.
 List<SemanticGraphEdge> getShortestUndirectedPathEdges(IndexedWord source, IndexedWord target)
           
 List<IndexedWord> getShortestUndirectedPathNodes(IndexedWord source, IndexedWord target)
          Returns the nodes in the shortest undirected path between two edges in the graph.
 Collection<IndexedWord> getSiblings(IndexedWord vertex)
          Method for getting the siblings of a particular node.
 boolean hasChild(IndexedWord vertex, GrammaticalRelation reln, String childLemma)
           
 boolean hasChildren(IndexedWord vertex)
           
 boolean hasChildWithReln(IndexedWord vertex, GrammaticalRelation reln)
           
 int hashCode()
           
 boolean hasParentWithReln(IndexedWord vertex, GrammaticalRelation reln)
          Returns true if vertex has an incoming relation reln
 Iterable<SemanticGraphEdge> incomingEdgeIterable(IndexedWord v)
           
 List<SemanticGraphEdge> incomingEdgeList(IndexedWord v)
           
 int inDegree(IndexedWord vertex)
           
 int isAncestor(IndexedWord child, IndexedWord ancestor)
          Searches up to 2 levels to determine how far ancestor is from child (i.e., returns 1 if "ancestor" is a parent, or 2 if ancestor is a grandparent.
 boolean isAuxiliaryVerb(IndexedWord vertex)
           
 boolean isDag()
           
 boolean isEmpty()
           
 boolean isInConditionalContext(IndexedWord vertex)
          Check if the vertex is in a "conditional" context.
 boolean isNegatedVertex(IndexedWord vertex)
           
 boolean matchPatternToVertex(String pattern, IndexedWord vertex)
           
 boolean matchPatternToVertex(String pattern, IndexedWord vertex, boolean det)
           
 int outDegree(IndexedWord vertex)
           
 Iterable<SemanticGraphEdge> outgoingEdgeIterable(IndexedWord v)
           
 List<SemanticGraphEdge> outgoingEdgeList(IndexedWord v)
           
 List<Pair<GrammaticalRelation,IndexedWord>> parentPairs(IndexedWord vertex)
          Returns a list of pairs of a relation name and the parent IndexedFeatureLabel to which we bear that relation.
 void prettyPrint()
          Pretty-prints this semantic graph to System.out, formatted by the default semantic graph formatter.
 void prettyPrint(SemanticGraphFormatter formatter)
          Pretty-prints this semantic graph to System.out, formatted by the supplied semantic graph formatter.
 GrammaticalRelation reln(IndexedWord a, IndexedWord b)
          Returns the relation that node a has with node b.
 Set<GrammaticalRelation> relns(IndexedWord vertex)
          Returns a set of relations which this node has with its parents.
 boolean removeEdge(SemanticGraphEdge e)
           
 boolean removeVertex(IndexedWord vertex)
           
 void resetRoots()
          This method should not be used if possible.
 void setRoot(IndexedWord word)
           
 void setRoots(Collection<IndexedWord> words)
           
 int size()
           
 String toCompactString()
           
 String toCompactString(boolean showTags)
           
 String toEnUncollapsedSentenceString()
          Similar to toRecoveredString, but will fill in words that were collapsed into relations (i.e.
 String toFormattedString()
          Returns a String representation of this semantic graph, formatted by the default semantic graph formatter.
 String toFormattedString(SemanticGraphFormatter formatter)
          Returns a String representation of this semantic graph, formatted by the supplied semantic graph formatter.
 String toList()
          Returns a String representation of this graph as a list of typed dependencies, as exemplified by the following:
 List<IndexedWord> topologicalSort()
           
 String toPOSList()
          Similar to toList(), but uses POS tags instead of word and index.
 String toRecoveredSentenceString()
           
 String toRecoveredSentenceStringWithIndexMarking()
           
 String toString()
          Recursive depth first traversal.
 String toString(String format)
          Returns a String representation of the result of this set of typed dependencies in a user-specified format.
 Collection<TypedDependency> typedDependencies()
          returns a list of TypedDependency in the graph this method goes through all SemanticGraphEdge and converts to TypedDependency.
static SemanticGraph valueOf(String s)
          Tries to parse a String representing a SemanticGraph.
 List<IndexedWord> vertexListSorted()
          This returns an ordered list of vertices (based upon their indices in the sentence).
 Set<IndexedWord> vertexSet()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

addSRLArcs

public static boolean addSRLArcs
Constructor Detail

SemanticGraph

public SemanticGraph()

SemanticGraph

public SemanticGraph(SemanticGraph g)
Returns a new SemanticGraph which is a copy of the supplied SemanticGraph. Both the nodes (IndexedWords) and the edges (SemanticGraphEdges) are copied.


SemanticGraph

public SemanticGraph(SemanticGraph g,
                     Map<IndexedWord,IndexedWord> prevToNewMap)
Copies a the current graph, but also sets the mapping from the old to new graph.


SemanticGraph

public SemanticGraph(Collection<TypedDependency> dependencies,
                     Collection<TreeGraphNode> roots)
This is the constructor used by the parser.


SemanticGraph

public SemanticGraph(Collection<TypedDependency> dependencies,
                     Collection<TreeGraphNode> rootNodes,
                     String docID,
                     int sentIndex)

SemanticGraph

public SemanticGraph(Collection<TypedDependency> dependencies,
                     Collection<TreeGraphNode> rootNodes,
                     String docID,
                     int sentIndex,
                     boolean lemmatize,
                     boolean threadSafe)
Method Detail

edgeCount

public int edgeCount()

outDegree

public int outDegree(IndexedWord vertex)

inDegree

public int inDegree(IndexedWord vertex)

getAllEdges

public List<SemanticGraphEdge> getAllEdges(IndexedWord gov,
                                           IndexedWord dep)

getEdge

public SemanticGraphEdge getEdge(IndexedWord gov,
                                 IndexedWord dep)

addVertex

public void addVertex(IndexedWord vertex)

containsVertex

public boolean containsVertex(IndexedWord vertex)

containsEdge

public boolean containsEdge(IndexedWord source,
                            IndexedWord target)

containsEdge

public boolean containsEdge(SemanticGraphEdge edge)

vertexSet

public Set<IndexedWord> vertexSet()

getEdgeSet

public Set<SemanticGraphEdge> getEdgeSet()
Return a set of all the edges in the graph. The set does not already exist in the graph data structure, so this method builds it. Therefore, it is expensive; call edgeIterable() if possible.


removeEdge

public boolean removeEdge(SemanticGraphEdge e)

removeVertex

public boolean removeVertex(IndexedWord vertex)

vertexListSorted

public List<IndexedWord> vertexListSorted()
This returns an ordered list of vertices (based upon their indices in the sentence). This creates and sorts a list, so prefer vertexSet unless you have a good reason to want nodes in index order.

Returns:
Ordered list of vertices

edgeListSorted

public List<SemanticGraphEdge> edgeListSorted()
Returns an ordered list of edges in the graph. This creates and sorts a list, so prefer edgeIterable().


edgeIterable

public Iterable<SemanticGraphEdge> edgeIterable()

outgoingEdgeIterable

public Iterable<SemanticGraphEdge> outgoingEdgeIterable(IndexedWord v)

incomingEdgeIterable

public Iterable<SemanticGraphEdge> incomingEdgeIterable(IndexedWord v)

outgoingEdgeList

public List<SemanticGraphEdge> outgoingEdgeList(IndexedWord v)

incomingEdgeList

public List<SemanticGraphEdge> incomingEdgeList(IndexedWord v)

isEmpty

public boolean isEmpty()

isAncestor

public int isAncestor(IndexedWord child,
                      IndexedWord ancestor)
Searches up to 2 levels to determine how far ancestor is from child (i.e., returns 1 if "ancestor" is a parent, or 2 if ancestor is a grandparent.

Parameters:
child - candidate child
ancestor - candidate ancestor
Returns:
the number of generations between "child" and "ancestor" (1 is an immediate parent), or -1 if there is no relationship found.

commonAncestor

public int commonAncestor(IndexedWord v1,
                          IndexedWord v2)
Return the maximum distance to a least common ancestor. We only search as high as grandparents. We return -1 if no common parent or grandparent is found.

Returns:
The maximum distance to a least common ancestor.

getCommonAncestor

public IndexedWord getCommonAncestor(IndexedWord v1,
                                     IndexedWord v2)
Returns the least common ancestor. We only search as high as grandparents. We return null if no common parent or grandparent is found. Any of the input words can also be the answer if one is the parent or grandparent of other

Returns:
The least common ancestor.

matchPatternToVertex

public boolean matchPatternToVertex(String pattern,
                                    IndexedWord vertex,
                                    boolean det)

matchPatternToVertex

public boolean matchPatternToVertex(String pattern,
                                    IndexedWord vertex)

getChildList

public List<IndexedWord> getChildList(IndexedWord vertex)

getChildren

public Collection<IndexedWord> getChildren(IndexedWord vertex)

hasChildren

public boolean hasChildren(IndexedWord vertex)

getIncomingEdgesSorted

public List<SemanticGraphEdge> getIncomingEdgesSorted(IndexedWord vertex)

getOutEdgesSorted

public List<SemanticGraphEdge> getOutEdgesSorted(IndexedWord vertex)

getParentList

public List<IndexedWord> getParentList(IndexedWord vertex)

getParents

public Collection<IndexedWord> getParents(IndexedWord vertex)

getSiblings

public Collection<IndexedWord> getSiblings(IndexedWord vertex)
Method for getting the siblings of a particular node. Siblings are the other children of your parent, where parent is determined as the parent returned by getParent

Returns:
collection of sibling nodes (does not include vertex) the collection is empty if your parent is null

getPathToRoot

public List<IndexedWord> getPathToRoot(IndexedWord vertex)

getParent

public IndexedWord getParent(IndexedWord vertex)

getNodeByIndex

public IndexedWord getNodeByIndex(int index)
                           throws IllegalArgumentException
Returns the first IndexedWord in this SemanticGraph having the given integer index, or throws IllegalArgumentException if no such node is found.

Throws:
IllegalArgumentException

getNodeByIndexSafe

public IndexedWord getNodeByIndexSafe(int index)
Same as above, but returns null if the index does not exist (instead of throwing an exception).


getNodeByWordPattern

public IndexedWord getNodeByWordPattern(String pattern)
Returns the first IndexedWord in this SemanticGraph having the given word or regex, or return null if no such found.


getAllNodesByWordPattern

public List<IndexedWord> getAllNodesByWordPattern(String pattern)
Returns all nodes of type IndexedWord in this SemanticGraph having the given word or regex, or returns empty list if no such found.


descendants

public Set<IndexedWord> descendants(IndexedWord vertex)
Returns the set of descendants governed by this node in the graph.


childPairs

public List<Pair<GrammaticalRelation,IndexedWord>> childPairs(IndexedWord vertex)
Returns a list of pairs of a relation name and the child IndexedFeatureLabel that bears that relation.


parentPairs

public List<Pair<GrammaticalRelation,IndexedWord>> parentPairs(IndexedWord vertex)
Returns a list of pairs of a relation name and the parent IndexedFeatureLabel to which we bear that relation.


relns

public Set<GrammaticalRelation> relns(IndexedWord vertex)
Returns a set of relations which this node has with its parents.

Returns:
The set of relations which this node has with its parents.

reln

public GrammaticalRelation reln(IndexedWord a,
                                IndexedWord b)
Returns the relation that node a has with node b.


childRelns

public Set<GrammaticalRelation> childRelns(IndexedWord vertex)
Returns a list of relations which this node has with its children.


getRoots

public Collection<IndexedWord> getRoots()

getFirstRoot

public IndexedWord getFirstRoot()
Returns the (first) root of this SemanticGraph.


addRoot

public void addRoot(IndexedWord root)

resetRoots

public void resetRoots()
This method should not be used if possible. TODO: delete it Recomputes the roots, based of actual candidates. This is done to ensure a rooted tree after a sequence of edits. If the none of the vertices can act as a root (due to a cycle), keep old rootset, retaining only the existing vertices on that list. TODO: this cannot deal with "Hamburg is a city which everyone likes", as the intended root node,'Hamburg, is also the dobj of the relative clause. A possible solution would be to create edgeset routines that allow filtering over a predicate, and specifically filter out dobj relations for choosing next best candidate. This could also be useful for dealing with non-syntactic arcs in the future. TODO: There is also the possibility the roots could be empty at the end, and will need to be resolved. TODO: determine if this is a reasonably correct solution.


setRoot

public void setRoot(IndexedWord word)

setRoots

public void setRoots(Collection<IndexedWord> words)

topologicalSort

public List<IndexedWord> topologicalSort()
                                  throws IllegalStateException
Returns:
A sorted list of the vertices
Throws:
IllegalStateException - if this graph is not a DAG

hasChild

public boolean hasChild(IndexedWord vertex,
                        GrammaticalRelation reln,
                        String childLemma)

hasChildWithReln

public boolean hasChildWithReln(IndexedWord vertex,
                                GrammaticalRelation reln)

hasParentWithReln

public boolean hasParentWithReln(IndexedWord vertex,
                                 GrammaticalRelation reln)
Returns true if vertex has an incoming relation reln

Parameters:
vertex - a node in this graph
reln - the relation we want to check
Returns:
true if vertex has an incoming relation reln

getChildWithReln

public IndexedWord getChildWithReln(IndexedWord vertex,
                                    GrammaticalRelation reln)
Returns the first IndexedFeatureLabel bearing a certain grammatical relation, or null if none.


getParentsWithReln

public List<IndexedWord> getParentsWithReln(IndexedWord vertex,
                                            GrammaticalRelation reln)
Returns a list of all parents bearing a certain grammatical relation, or an empty list if none.


getChildrenWithReln

public List<IndexedWord> getChildrenWithReln(IndexedWord vertex,
                                             GrammaticalRelation reln)
Returns a list of all children bearing a certain grammatical relation, or an empty list if none.


getChildrenWithRelns

public List<IndexedWord> getChildrenWithRelns(IndexedWord vertex,
                                              Collection<GrammaticalRelation> relns)
Returns a list of all children bearing one of a set of grammatical relations, or an empty list if none. NOTE: this will only work for relation types that are classes. Those that are collapsed are currently not handled correctly since they are identified by strings.


getEdge

public SemanticGraphEdge getEdge(IndexedWord gov,
                                 IndexedWord dep,
                                 GrammaticalRelation reln)
Given a governor, dependent, and the relation between them, returns the SemanticGraphEdge object of that arc if it exists, otherwise returns null.


isNegatedVertex

public boolean isNegatedVertex(IndexedWord vertex)

isInConditionalContext

public boolean isInConditionalContext(IndexedWord vertex)
Check if the vertex is in a "conditional" context. Right now it's only returning true if vertex has an "if" marker attached to it, i.e. the vertex is in a clause headed by "if".


attachedNegatedVerb

public boolean attachedNegatedVerb(IndexedWord vertex)

isAuxiliaryVerb

public boolean isAuxiliaryVerb(IndexedWord vertex)

getLeafVertices

public Set<IndexedWord> getLeafVertices()

size

public int size()

isDag

public boolean isDag()
Returns:
true if the graph contains no cycles.

toString

public String toString()
Recursive depth first traversal. Returns a structured representation of the dependency graph. Example:

  /-> need-3 (root)
    -> We-0 (nsubj)
    -> do-1 (aux)
    -> n't-2 (neg)
    -> badges-6 (dobj)
      -> no-4 (det)
      -> stinking-5 (amod)
 

Overrides:
toString in class Object

toRecoveredSentenceString

public String toRecoveredSentenceString()

toRecoveredSentenceStringWithIndexMarking

public String toRecoveredSentenceStringWithIndexMarking()

toEnUncollapsedSentenceString

public String toEnUncollapsedSentenceString()
Similar to toRecoveredString, but will fill in words that were collapsed into relations (i.e. prep_for --> 'for'). Mostly to deal with collapsed dependency trees. TODO: consider merging with toRecoveredString() NOTE: assumptions currently are for English. NOTE: currently takes immediate successors to current word and expands them. This assumption may not be valid for other conditions or languages?


toString

public String toString(String format)
Returns a String representation of the result of this set of typed dependencies in a user-specified format. Currently, three formats are supported:
"plain"
(Default.) Formats the dependencies as logical relations, as exemplified by the following:
  nsubj(died-1, Sam-0)
  tmod(died-1, today-2)
 
"readable"
Formats the dependencies as a table with columns dependent, relation, and governor, as exemplified by the following:
  Sam-0               nsubj               died-1
  today-2             tmod                died-1
 
"xml"
Formats the dependencies as XML, as exemplified by the following:
  <dependencies>
    <dep type="nsubj">
      <governor idx="1">died</governor>
      <dependent idx="0">Sam</dependent>
    </dep>
    <dep type="tmod">
      <governor idx="1">died</governor>
      <dependent idx="2">today</dependent>
    </dep>
  </dependencies>
 

Parameters:
format - a String specifying the desired format
Returns:
a String representation of the typed dependencies in this GrammaticalStructure

toList

public String toList()
Returns a String representation of this graph as a list of typed dependencies, as exemplified by the following:
  nsubj(died-6, Sam-3)
  tmod(died-6, today-9)
 

Returns:
a String representation of this set of typed dependencies

toPOSList

public String toPOSList()
Similar to toList(), but uses POS tags instead of word and index.


toCompactString

public String toCompactString()

toCompactString

public String toCompactString(boolean showTags)

toFormattedString

public String toFormattedString()
Returns a String representation of this semantic graph, formatted by the default semantic graph formatter.


toFormattedString

public String toFormattedString(SemanticGraphFormatter formatter)
Returns a String representation of this semantic graph, formatted by the supplied semantic graph formatter.


prettyPrint

public void prettyPrint(SemanticGraphFormatter formatter)
Pretty-prints this semantic graph to System.out, formatted by the supplied semantic graph formatter.


prettyPrint

public void prettyPrint()
Pretty-prints this semantic graph to System.out, formatted by the default semantic graph formatter.


addEdge

public SemanticGraphEdge addEdge(IndexedWord s,
                                 IndexedWord d,
                                 GrammaticalRelation reln,
                                 double weight)

valueOf

public static SemanticGraph valueOf(String s)
Tries to parse a String representing a SemanticGraph. Right now it's fairly dumb, could be made more sophisticated.

Example: "[ate subj:Bill dobj:[muffins nn:blueberry]]"

This is the same format generated by toCompactString().


getShortestUndirectedPathNodes

public List<IndexedWord> getShortestUndirectedPathNodes(IndexedWord source,
                                                        IndexedWord target)
Returns the nodes in the shortest undirected path between two edges in the graph. if source == target, returns a singleton list

Parameters:
source - node
target - node
Returns:
nodes along shortest undirected path from source to target, in order

getShortestUndirectedPathEdges

public List<SemanticGraphEdge> getShortestUndirectedPathEdges(IndexedWord source,
                                                              IndexedWord target)

getShortestDirectedPathNodes

public List<IndexedWord> getShortestDirectedPathNodes(IndexedWord source,
                                                      IndexedWord target)
Returns the shortest directed path between two edges in the graph.

Parameters:
source - node
target - node
Returns:
shortest directed path from source to target

getShortestDirectedPathEdges

public List<SemanticGraphEdge> getShortestDirectedPathEdges(IndexedWord source,
                                                            IndexedWord target)

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

findAllRelns

public List<SemanticGraphEdge> findAllRelns(GrammaticalRelation tgtRelation)
Given a semantic graph, and a target relation, returns a list of all relations (edges) matching.


typedDependencies

public Collection<TypedDependency> typedDependencies()
returns a list of TypedDependency in the graph this method goes through all SemanticGraphEdge and converts to TypedDependency.



Stanford NLP Group