Java Code Examples for edu.stanford.nlp.semgraph.SemanticGraphEdge#getWeight()

The following examples show how to use edu.stanford.nlp.semgraph.SemanticGraphEdge#getWeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClauseDetector.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
/** Creates a constituent for a possessive relative clause
 * @param semanticGraph The semantic graph
 * @param poss The edge referring to the possessive relation
 * @param rcmod The relative clause modifier of the relation
 * @param constGovernor The root of the constituent
 * @param type The type of the constituent*/
private static Constituent createPossConstituent(SemanticGraph semanticGraph, SemanticGraphEdge poss, SemanticGraphEdge rcmod,
    IndexedWord constGovernor, Type type) {

  SemanticGraph newSemanticGraph = new SemanticGraph(semanticGraph);
  double weight = poss.getWeight();
  newSemanticGraph.addEdge(poss.getGovernor(), rcmod.getGovernor(), EnglishGrammaticalRelations.POSSESSION_MODIFIER, weight, false);
  Set<IndexedWord> exclude = DpUtils.exclude(newSemanticGraph, EXCLUDE_RELATIONS_COMPLEMENT, rcmod.getGovernor());
  newSemanticGraph.removeEdge(poss);
  newSemanticGraph.removeEdge(rcmod);
  return new IndexedConstituent(newSemanticGraph, constGovernor, Collections.<IndexedWord>emptySet(), exclude, type);
}
 
Example 2
Source File: ProcessConjunctions.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
private static void addEdges(List<SemanticGraphEdge> outEdgesSorted, IndexedWord governor, SemanticGraph semanticGraph) {
  Set<GrammaticalRelation> relations = collectRelations(outEdgesSorted);
  Set<GrammaticalRelation> noRelations = collectRelations(semanticGraph.getOutEdgesSorted(governor));
  relations.removeAll(noRelations);
  for(SemanticGraphEdge edge: outEdgesSorted) {
    if(!relations.contains(edge.getRelation())) {
      continue;
    }
    SemanticGraphEdge nedge = new SemanticGraphEdge(governor, edge.getDependent(), edge.getRelation(), edge.getWeight(), edge.isExtra());
    semanticGraph.addEdge(nedge);
  }
}
 
Example 3
Source File: ClauseDetector.java    From minie with GNU General Public License v3.0 5 votes vote down vote up
/** Creates a constituent for a possessive relative clause
 * @param semanticGraph The semantic graph
 * @param poss The edge referring to the possessive relation
 * @param rcmod The relative clause modifier of the relation
 * @param constGovernor The root of the constituent
 * @param type The type of the constituent
*/
private static Constituent createPossConstituent(SemanticGraph semanticGraph,
        SemanticGraphEdge poss, SemanticGraphEdge rcmod, IndexedWord constGovernor, Type type) {
    SemanticGraph newSemanticGraph = new SemanticGraph(semanticGraph);
    double weight = poss.getWeight();
    newSemanticGraph.addEdge(poss.getGovernor(), rcmod.getGovernor(), EnglishGrammaticalRelations.POSSESSION_MODIFIER, 
                             weight, false);
    Set<IndexedWord> exclude = DpUtils.exclude(newSemanticGraph, EXCLUDE_RELATIONS_COMPLEMENT, rcmod.getGovernor());
    newSemanticGraph.removeEdge(poss);
    newSemanticGraph.removeEdge(rcmod);
    return new IndexedConstituent(newSemanticGraph, constGovernor, Collections.<IndexedWord> emptySet(), exclude, type);
}