Package edu.stanford.nlp.semgraph

Examples of edu.stanford.nlp.semgraph.SemanticGraphEdge$SemanticGraphEdgeTargetComparator


  @Override
  public void evaluate(SemanticGraph sg, SemgrexMatcher sm) {   
    String relation = sm.getRelnString(edgeName);
    IndexedWord govNode = getNamedNode(govName, sm);
    IndexedWord depNode = getNamedNode(depName, sm);
    SemanticGraphEdge edge = sg.getEdge(govNode, depNode, GrammaticalRelation.valueOf(relation));
   
    if (edge != null) {
      sg.removeEdge(edge);
    }
  }
View Full Code Here


    boolean depWild = depName.equals(WILDCARD_NODE);
    IndexedWord govNode = getNamedNode(govName, sm);
    IndexedWord depNode =getNamedNode(depName, sm);

    if (govNode != null && depNode != null) {
      SemanticGraphEdge edge = sg.getEdge(govNode, depNode, relation);
      if (edge != null) {
        @SuppressWarnings("unused")
        boolean successFlag = sg.removeEdge(edge);
      }
    } else if (depNode != null && govWild) {
      // dep known, wildcard gov
      for (SemanticGraphEdge edge : sg.incomingEdgeIterable(depNode)) {
        if (edge.getRelation().equals(relation) && sg.containsEdge(edge) ) {
          sg.removeEdge(edge);
        }
      }
    }  else if (govNode != null && depWild) {
      // gov known, wildcard dep
      for (SemanticGraphEdge edge : sg.outgoingEdgeIterable(govNode)) {
        if (edge.getRelation().equals(relation) && sg.containsEdge(edge) ) {
          sg.removeEdge(edge);
        }
      }
    }
  }
View Full Code Here

 
  @Override
  public void evaluate(SemanticGraph sg, SemgrexMatcher sm) {
    IndexedWord govNode = getNamedNode(govName, sm);
    IndexedWord depNode =  getNamedNode(depName, sm);
    SemanticGraphEdge existingEdge = sg.getEdge(govNode, depNode, relation);
    if (existingEdge == null) {
      // When adding the edge, check to see if the gov/dep nodes are presently in the graph.
      //
      if (!sg.containsVertex(govNode))
        sg.addVertex(govNode);
View Full Code Here

            }
            if (iterator == null) {
              iterator = sg.outgoingEdgeIterator(node);
            }
            while (iterator.hasNext()) {
              SemanticGraphEdge edge = iterator.next();
              relation = edge.getRelation().toString();
              if (!type.test(relation)) {
                continue;
              }
              this.next = edge.getTarget();
              return;
            }
            this.next = null;
          }
        };
View Full Code Here

                IndexedWord search = searchStack.pop();
                neighborIterator = neighborIterator(sg, search);
              }

              while (neighborIterator.hasNext()) {
                SemanticGraphEdge edge = neighborIterator.next();
                IndexedWord otherEnd = followEdge(edge);
                if (!searchedNodes.contains(otherEnd)) {
                  searchStack.push(otherEnd);
                  searchedNodes.add(otherEnd);
                }
                if (type.test(edge.getRelation().toString()) && !matchedNodes.contains(otherEnd)) {
                  matchedNodes.add(otherEnd);
                  next = otherEnd;
                  relation = edge.getRelation().toString();
                  return;
                }
              }
            }
            // oh well, fell through with no results
View Full Code Here

    // "stub: subj->  be"
    // "stub: be  <-mod"
    // "stub: subj->  be  <-mod"
    if (usingFeature(types, checklist, "dependency_path_stubs_to_verb")) {
      for (IndexedWord node : pathNodes) {
        SemanticGraphEdge edge0 = edgePath.get(0);
        SemanticGraphEdge edge1 = edgePath.get(edgePath.size() - 1);
        if (node.tag().contains("VB")) {
          if (node.equals(node0) || node.equals(node1)) {
            continue;
          }
          String lemma = Morphology.lemmaStatic(node.value(), node.tag(), true);
          String edge0str, edge1str;
          if (node0.equals(edge0.getGovernor())) {
            edge0str = "<-" + generalizeRelation(edge0.getRelation());
          } else {
            edge0str = generalizeRelation(edge0.getRelation()) + "->";
          }
          if (node1.equals(edge1.getGovernor())) {
            edge1str = generalizeRelation(edge1.getRelation()) + "->";
          } else {
            edge1str = "<-" + generalizeRelation(edge1.getRelation());
          }
          features.setCount("stub: " + edge0str + " " + lemma, 1.0);
          features.setCount("stub: " + lemma + edge1str, 1.0);
          features.setCount("stub: " + edge0str + " " + lemma + " " + edge1str, 1.0);
        }
      }
    }

    if (usingFeature(types, checklist, "verb_in_dependency_path")) {
      for (IndexedWord node : pathNodes) {
        if (node.tag().contains("VB")) {
          if (node.equals(node0) || node.equals(node1)) {
            continue;
          }
          SemanticGraphEdge rightEdge = graph.getShortestUndirectedPathEdges(node, node1).get(0);
          SemanticGraphEdge leftEdge = graph.getShortestUndirectedPathEdges(node, node0).get(0);
          String rightRelation, leftRelation;
          boolean governsLeft = false, governsRight = false;
          if (node.equals(rightEdge.getGovernor())) {
            rightRelation = " <-" + generalizeRelation(rightEdge.getRelation());
            governsRight = true;
          } else {
            rightRelation = generalizeRelation(rightEdge.getRelation()) + "-> ";
          }
          if (node.equals(leftEdge.getGovernor())) {
            leftRelation = generalizeRelation(leftEdge.getRelation()) + "-> ";
            governsLeft = true;
          } else {
            leftRelation = " <-" + generalizeRelation(leftEdge.getRelation());
          }
          String lemma = Morphology.lemmaStatic(node.value(), node.tag(), true);

          if (governsLeft || governsRight) {
          }
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.semgraph.SemanticGraphEdge$SemanticGraphEdgeTargetComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.