/** * Given a SemanticGraph, and a set of nodes, finds the "blanket" of nodes that are one * edge away from the set of nodes passed in. This is similar to the idea of a Markov * Blanket, except in the context of a SemanticGraph. * TODO: optimize */ public static Collection<IndexedWord> getDependencyBlanket(SemanticGraph sg, Collection<IndexedWord> assertedNodes) { Set<IndexedWord> retSet = Generics.newHashSet(); for (IndexedWord curr : sg.vertexSet()) { if (!assertedNodes.contains(curr) && !retSet.contains(curr)) { for (IndexedWord assertedNode : assertedNodes) { if (sg.containsEdge(assertedNode, curr) || sg.containsEdge(curr, assertedNode)) { retSet.add(curr); } } } } return retSet; }
public boolean containsEdge(SemanticGraphEdge edge) { return containsEdge(edge.getSource(), edge.getTarget()); }
@Override public void evaluate(SemanticGraph sg, SemgrexMatcher sm) { boolean govWild = govName.equals(WILDCARD_NODE); 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); } } } }
if ( ! sg.containsEdge(modifier, object)) sg.addEdge(modifier, object, CONTROLLING_NOMINAL_SUBJECT, CONTROL_EDGE_WEIGHT, true); if ( ! sg.containsEdge(modifier, subject)) sg.addEdge(modifier, subject, CONTROLLING_NOMINAL_SUBJECT, CONTROL_EDGE_WEIGHT, true);
newDep = leftChildEdge.getDependent(); if (newDep != null && ! sg.containsEdge(head, newDep)) { sg.addEdge(head, newDep, UniversalGrammaticalRelations.REFERENT, RELCL_EDGE_WEIGHT, false);
if ( ! sg.containsEdge(modifier, object)) sg.addEdge(modifier, object, CONTROLLING_NOMINAL_SUBJECT, Double.NEGATIVE_INFINITY, true); if ( ! sg.containsEdge(modifier, subject)) sg.addEdge(modifier, subject, CONTROLLING_NOMINAL_SUBJECT, Double.NEGATIVE_INFINITY, true);
newDep = leftChildEdge.getDependent(); if (newDep != null && ! sg.containsEdge(head, newDep)) { sg.addEdge(head, newDep, REFERENT, Double.NEGATIVE_INFINITY, false);
/** * Given a SemanticGraph, and a set of nodes, finds the "blanket" of nodes that are one * edge away from the set of nodes passed in. This is similar to the idea of a Markov * Blanket, except in the context of a SemanticGraph. * TODO: optimize */ public static Collection<IndexedWord> getDependencyBlanket(SemanticGraph sg, Collection<IndexedWord> assertedNodes) { Set<IndexedWord> retSet = Generics.newHashSet(); for (IndexedWord curr : sg.vertexSet()) { if (!assertedNodes.contains(curr) && !retSet.contains(curr)) { for (IndexedWord assertedNode : assertedNodes) { if (sg.containsEdge(assertedNode, curr) || sg.containsEdge(curr, assertedNode)) { retSet.add(curr); } } } } return retSet; }
/** * Given a SemanticGraph, and a set of nodes, finds the "blanket" of nodes that are one * edge away from the set of nodes passed in. This is similar to the idea of a Markov * Blanket, except in the context of a SemanticGraph. * TODO: optimize */ public static Collection<IndexedWord> getDependencyBlanket(SemanticGraph sg, Collection<IndexedWord> assertedNodes) { Set<IndexedWord> retSet = Generics.newHashSet(); for (IndexedWord curr : sg.vertexSet()) { if (!assertedNodes.contains(curr) && !retSet.contains(curr)) { for (IndexedWord assertedNode : assertedNodes) { if (sg.containsEdge(assertedNode, curr) || sg.containsEdge(curr, assertedNode)) { retSet.add(curr); } } } } return retSet; }
public boolean containsEdge(SemanticGraphEdge edge) { return containsEdge(edge.getSource(), edge.getTarget()); }
public boolean containsEdge(SemanticGraphEdge edge) { return containsEdge(edge.getSource(), edge.getTarget()); }
public boolean containsEdge(SemanticGraphEdge edge) { return containsEdge(edge.getSource(), edge.getTarget()); }
if ( ! sg.containsEdge(modifier, object)) sg.addEdge(modifier, object, CONTROLLING_NOMINAL_SUBJECT, Double.NEGATIVE_INFINITY, true); if ( ! sg.containsEdge(modifier, subject)) sg.addEdge(modifier, subject, CONTROLLING_NOMINAL_SUBJECT, Double.NEGATIVE_INFINITY, true);
if ( ! sg.containsEdge(modifier, object)) sg.addEdge(modifier, object, CONTROLLING_NOMINAL_SUBJECT, Double.NEGATIVE_INFINITY, true); if ( ! sg.containsEdge(modifier, subject)) sg.addEdge(modifier, subject, CONTROLLING_NOMINAL_SUBJECT, Double.NEGATIVE_INFINITY, true);
newDep = leftChildEdge.getDependent(); if (newDep != null && ! sg.containsEdge(head, newDep)) { sg.addEdge(head, newDep, REFERENT, Double.NEGATIVE_INFINITY, false);
newDep = leftChildEdge.getDependent(); if (newDep != null && ! sg.containsEdge(head, newDep)) { sg.addEdge(head, newDep, REFERENT, Double.NEGATIVE_INFINITY, false);