Search code examples
stanford-nlp

Stanford CoreNLP get all edges of a SemanticGraph


I am trying to get a list of all the edges in a given SemanticGraph.
There is "getAllEdges(IndexedWord gov, IndexedWord dep)" method but it seems to only work on a pair of 2 Indexed words, not the whole graph.
Is there another way to get all the edges without traversing the whole graph manually?


Solution

  • You can try:

    SemanticGraph parse = ...
    for (SemanticGraphEdge edge : parse.edgeIterable()) {
      ...
    }
    

    There are also parallels of this in outgoingEdgeIterable and incomingEdgeIterable.