Example usage for edu.stanford.nlp.semgraph SemanticGraph getShortestDirectedPathEdges

List of usage examples for edu.stanford.nlp.semgraph SemanticGraph getShortestDirectedPathEdges

Introduction

In this page you can find the example usage for edu.stanford.nlp.semgraph SemanticGraph getShortestDirectedPathEdges.

Prototype

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

Source Link

Usage

From source file:main.java.parsers.StanfordParser.java

/**
 * Gets a dependency path between iw1 and iw2 if it exists.
 * //from  www . j  a v a 2  s .c o  m
 * @param iw1 is the Stanford data-structure indexed word posited as first node in the path
 * @param iw2 is the Stanford data-structure indexed word posited as second node in the path
 * @param graph is the dependency path
 * @return dependency path between iw1 and iw2 if it exits, else an empty string
 */
public static String getPath(IndexedWord iw1, IndexedWord iw2, SemanticGraph graph) {
    List<SemanticGraphEdge> edges = graph.getShortestDirectedPathEdges(iw1, iw2);

    if (edges != null)
        return createPath(edges, ">");

    edges = graph.getShortestDirectedPathEdges(iw2, iw1);
    if (edges != null) {
        Collections.reverse(edges);
        return createPath(edges, "<");
    }

    return "";
}