List of usage examples for edu.stanford.nlp.semgraph SemanticGraph getShortestUndirectedPathEdges
public List<SemanticGraphEdge> getShortestUndirectedPathEdges(IndexedWord source, IndexedWord target)
From source file:sleventextraction.SLRegularization.java
public Datum ConnectiveFeatures(IndexedWord iwtrigger, CoreMap senCM, SemanticGraph senSG, SLEntity e1, SLEntity e2, String anchor) { Datum d = new Datum(); if (e1.head == null || e2.head == null) { return null; }// w ww . j ava 2 s. c o m d.addFV("filename", Ace.currentDocPath); d.addFV("Trigger", anchor); d.addFV("deprel", e1.dep); d.addFV("deprel", e2.dep); d.addFV("head", e1.head.word()); d.addFV("head", e2.head.word()); d.addFV("entitytype", e1.entitytype); d.addFV("entitytype", e2.entitytype); d.addFV("entitysubtype", e1.entitysubtype); d.addFV("entitysubtype", e2.entitysubtype); d.addFV("mentiontype", e1.mentiontype); d.addFV("mentiontype", e2.mentiontype); if (e1.head.index() < iwtrigger.index() && e2.head.index() < iwtrigger.index() || e1.head.index() > iwtrigger.index() && e2.head.index() > iwtrigger.index()) { d.addFV("TriggerSameOrNot", "yes"); } else { d.addFV("TriggerSameOrNot", "no"); } int entitydis = Math.abs(e1.head.index() - e2.head.index()); d.addFV("EntityDis", String.valueOf(entitydis)); CoreMap span = senCM; SemanticGraph totaldep = senSG; List<SemanticGraphEdge> path = totaldep.getShortestUndirectedPathEdges(e1.head, e2.head); int entitydepdis = path == null ? 1000 : path.size(); d.addFV("EntityDepDis", String.valueOf(entitydepdis)); int predicatedis = Math.abs(e1.predicate.index() - e2.predicate.index()); d.addFV("PredicateDis", String.valueOf(predicatedis)); List<SemanticGraphEdge> prepath = totaldep.getShortestUndirectedPathEdges(e1.predicate, e2.predicate); int predepdis = prepath == null ? 1000 : prepath.size(); if (predepdis == 0) { d.addFV("predicatePOS", e1.predicate.tag()); if (e1.head.index() < e1.predicate.index() && e2.head.index() < e1.predicate.index() || e1.head.index() > e1.predicate.index() && e2.head.index() > e1.predicate.index()) { d.addFV("PredicateSameOrNot", "yes"); } else { d.addFV("PredicateSameOrNot", "no"); } } d.addFV("PredicateDepDis", String.valueOf(predepdis)); return d; }