IndexedWord node = depTree.getNodeByIndexSafe(i + 1); if (node != null) { List<SemanticGraphEdge> edgeList = depTree.getIncomingEdgesSorted(node); if (!edgeList.isEmpty()) { assert edgeList.size() == 1;
/** * Mostly just an alias, but make sure our featurizer is serializable! */ public interface Featurizer extends Function<Triple<ClauseSplitterSearchProblem.State, ClauseSplitterSearchProblem.Action, ClauseSplitterSearchProblem.State>, Counter<String>>, Serializable { boolean isSimpleSplit(Counter<String> feats); }
List<SemanticGraphEdge> edgeList = graph.getIncomingEdgesSorted(node); if (! edgeList.isEmpty()) { assert edgeList.size() == 1;
/** * Post-process graph and copy over case markers in case the PP-complement * is conjoined. * @param sg */ public static void addCaseMarkerForConjunctions(SemanticGraph sg) { SemanticGraph sgCopy = sg.makeSoftCopy(); for (SemanticGraphEdge edge : sgCopy.edgeIterable()) { String relnName = edge.getRelation().toString(); if (relnName.equals("nmod") || relnName.equals("obl") || relnName.equals("acl") || relnName.equals("advcl")) { Set<IndexedWord> conjParents = sg.getParentsWithReln(edge.getDependent(), "conj"); for (IndexedWord conjParent : conjParents) { List<SemanticGraphEdge> conjParentIncomingEdges = sg.getIncomingEdgesSorted(conjParent); boolean changed = false; for (SemanticGraphEdge edge1: conjParentIncomingEdges) { if (edge1.getRelation().toString().startsWith(relnName) && edge1.getRelation().getSpecific() != null) { changed = true; sg.getEdge(edge.getGovernor(), edge.getDependent(), edge.getRelation()).setRelation(edge1.getRelation()); break; } } if (changed) { break; } } } } }
for (SemanticGraphEdge edge : getIncomingEdgesSorted(word)) { GrammaticalRelation relation = edge.getRelation();
public static Set<IndexedWord> getParents(SemanticGraph semanticGraph, IndexedWord node) { Set<IndexedWord> ret = new HashSet<>(); List<SemanticGraphEdge> incomingEdgesSorted = semanticGraph.getIncomingEdgesSorted(node); if (incomingEdgesSorted.size() > 0) { for (SemanticGraphEdge semanticGraphEdge : incomingEdgesSorted) { ret.add(semanticGraphEdge.getGovernor()); } } return ret; }
public static void getHistory(SemanticGraph semanticGraph, IndexedWord node, List<IndexedWord> start) { List<SemanticGraphEdge> incomingEdgesSorted = semanticGraph.getIncomingEdgesSorted(node); if (incomingEdgesSorted.size() > 0) { IndexedWord governor = incomingEdgesSorted.get(0).getGovernor(); start.add(governor); getHistory(semanticGraph, governor, start); } }
/** * Mostly just an alias, but make sure our featurizer is serializable! */ public interface Featurizer extends Function<Triple<ClauseSplitterSearchProblem.State, ClauseSplitterSearchProblem.Action, ClauseSplitterSearchProblem.State>, Counter<String>>, Serializable { boolean isSimpleSplit(Counter<String> feats); }
IndexedWord node = depTree.getNodeByIndexSafe(i + 1); if (node != null) { List<SemanticGraphEdge> edgeList = depTree.getIncomingEdgesSorted(node); if (!edgeList.isEmpty()) { assert edgeList.size() == 1;
public static Map<Integer, String> getParent(VerbMultiToken verb, SemanticGraph semanticGraph) { Map<Integer, String> parents = new HashMap<>(); Set<Integer> removeIndexes = new HashSet<>(); for (CoreLabel token : verb.getTokens()) { int index = token.index(); removeIndexes.add(index); try { IndexedWord node = semanticGraph.getNodeByIndex(index); List<SemanticGraphEdge> incomingEdgesSorted = semanticGraph .getIncomingEdgesSorted(node); // System.out.println(token + " --- " + incomingEdgesSorted); for (SemanticGraphEdge edge : incomingEdgesSorted) { int parentIndex = edge.getGovernor().index(); parents.put(parentIndex, edge.getRelation().getShortName()); } } catch (Exception e) { // ignored // System.out.println("ERR: no node for index " + index); // System.out.println(token); } } for (Integer removeIndex : removeIndexes) { parents.remove(removeIndex); } return parents; } }
public static Map<Integer, String> getParent(VerbMultiToken verb, SemanticGraph semanticGraph) { Map<Integer, String> parents = new HashMap<>(); Set<Integer> removeIndexes = new HashSet<>(); for (CoreLabel token : verb.getTokens()) { int index = token.index(); removeIndexes.add(index); try { IndexedWord node = semanticGraph.getNodeByIndex(index); List<SemanticGraphEdge> incomingEdgesSorted = semanticGraph .getIncomingEdgesSorted(node); // System.out.println(token + " --- " + incomingEdgesSorted); for (SemanticGraphEdge edge : incomingEdgesSorted) { int parentIndex = edge.getGovernor().index(); parents.put(parentIndex, edge.getRelation().getShortName()); } } catch (Exception e) { // ignored // System.out.println("ERR: no node for index " + index); // System.out.println(token); } } for (Integer removeIndex : removeIndexes) { parents.remove(removeIndex); } return parents; } }
for (SemanticGraphEdge edge : getIncomingEdgesSorted(word)) { GrammaticalRelation relation = edge.getRelation();
for (SemanticGraphEdge edge : getIncomingEdgesSorted(word)) { GrammaticalRelation relation = edge.getRelation();
for (SemanticGraphEdge edge : getIncomingEdgesSorted(word)) { GrammaticalRelation relation = edge.getRelation();