private List<ExtendedNode> findUpNodes(ExtendedNode textNodeToMove, ExtendedNode textNodeToBeParent, ExtendedNode leastCommonAncestor) { List<ExtendedNode> ret = new LinkedList<ExtendedNode>(); if (leastCommonAncestor==textNodeToMove) { // do nothing - empty list } else { ExtendedNode current = tree.getParentMap().get(textNodeToMove); while(current != leastCommonAncestor) { ret.add(current); current = tree.getParentMap().get(current); } } return ret; }
private List<ExtendedNode> findDownNodes(ExtendedNode textNodeToMove, ExtendedNode textNodeToBeParent, ExtendedNode leastCommonAncestor) { List<ExtendedNode> ret = new LinkedList<ExtendedNode>(); if (leastCommonAncestor==textNodeToBeParent) { // do nothing } else { ExtendedNode current = tree.getParentMap().get(textNodeToBeParent); while (current!=leastCommonAncestor) { ret.add(current); current=tree.getParentMap().get(current); } } Collections.reverse(ret); return ret; }
ExtendedNode current = textNodeToMove; nodes_from_root.add(current); while(tree.getParentMap().containsKey(current)) ExtendedNode parent = tree.getParentMap().get(current); nodes_from_root.add(parent); current = parent; while ( (current!=null) && (!nodes_from_root.contains(current)) ) current = tree.getParentMap().get(current);
public static <I, S extends AbstractNode<I, S>> LinkedHashSet<S> findAllowedRootsByAffectedNodes(TreeAndParentMap<I, S> tree, Set<S> affectedNodes) { final S treeRoot = tree.getTree(); final Map<S, S> parentMap = tree.getParentMap(); LinkedHashSet<S> ret = new LinkedHashSet<>(); for (S affectedNode : affectedNodes) { S node = affectedNode; while (node != treeRoot) { ret.add(node); node = parentMap.get(node); } ret.add(node); } return ret; }
Map<ExtendedNode, ExtendedNode> parentMap = textTree.getParentMap(); ExtendedNode current = subtreeToRemove; while ( (parentMap.get(current)!=null) && (subtreeToAdd!=parentMap.get(current)) )
(null==textTree.getParentMap().get(textTriple)) && (null==hypothesisTree.getParentMap().get(hypothesisTriple)) (null==textTree.getParentMap().get(textTriple)) || (null==hypothesisTree.getParentMap().get(hypothesisTriple)) S textParent = textTree.getParentMap().get(textTriple); S hypothesisParent = hypothesisTree.getParentMap().get(hypothesisTriple); ret = nodesAligned(textTree, hypothesisTree, textTriple, hypothesisTriple)
public static boolean pathOnlyChangeRelation(PathInTree path, TreeAndParentMap<ExtendedInfo,ExtendedNode> tree) { if (path.getTo()==tree.getParentMap().get(path.getFrom())) return true; else return false; }
private List<String> convertRelationsToStrings(Set<ExtendedNode> nodes) { List<String> ret = new ArrayList<>(nodes.size()); for (ExtendedNode node : nodes) { ExtendedNode parent = hypothesisTree.getParentMap().get(node); String parentString = ""; if (parent!=null) { parentString = "<"+InfoGetFields.getLemma(parent.getInfo()); } ret.add(InfoGetFields.getLemma(node.getInfo())+parentString); } return ret; }
private String strListNodes(List<ExtendedNode> nodes, boolean edge) { StringBuilder sb = new StringBuilder(); boolean firstIteration = true; for (ExtendedNode node : nodes) { if (firstIteration){firstIteration=false;} else {sb.append(", ");} sb.append(InfoGetFields.getLemma(node.getInfo())); if (edge) { ExtendedNode parent = hypothesisTree.getParentMap().get(node); if (parent!=null) { sb.append("<").append(InfoGetFields.getLemma(parent.getInfo())); } } } return sb.toString(); }
public static Set<ExtendedNode> findRelationsNoMatch(TreeAndParentMap<ExtendedInfo,ExtendedNode> text, TreeAndParentMap<ExtendedInfo,ExtendedNode> hypothesis) { Set<ExtendedNode> ret = new LinkedHashSet<ExtendedNode>(); Set<ExtendedNode> textNodes = AbstractNodeUtils.treeToLinkedHashSet(text.getTree()); Set<ExtendedNode> hypothesisNodes = AbstractNodeUtils.treeToLinkedHashSet(hypothesis.getTree()); for (ExtendedNode hypothesisNode : hypothesisNodes) { boolean found = false; for (ExtendedNode textNode : textNodes) { if (Equalities.areEqualRelations(hypothesisNode, textNode, hypothesis.getParentMap(),text.getParentMap())) { found = true; break; } } if (!found) ret.add(hypothesisNode); } return ret; }
private boolean parentMapped(ExtendedNode hypothesisNode) ExtendedNode hypothesisParent = HypothesisTree.getParentMap().get(hypothesisNode); if (hypothesisParent!=null) for (ExtendedNode textNode : mapHypothesisNodesToText.get(hypothesisNode)) ExtendedNode textParent = textTree.getParentMap().get(textNode); if ( (textParent!=null) && (mappedToHypothesisParent.contains(textParent)) )
@ParserSpecific("easyfirst") private void addCopyForRefRelation() for (ExtendedNode node : textTree.getParentMap().keySet()) ExtendedNode parent = textTree.getParentMap().get(node); ExtendedNode antecedent = node.getAntecedent(); while (antecedent!=null)
for (ExtendedNode textNode : textNodes) ExtendedNode parentHypothesis = hypothesis.getParentMap().get(hypothesisNode); ExtendedNode parentText = text.getParentMap().get(textNode); if (Equalities.areEqualNodes(hypothesisNode.getInfo(), textNode.getInfo())) Equalities.areEqualRelations(hypothesisNode, textNode, hypothesis.getParentMap(), text.getParentMap()) && Equalities.areEqualNodes(parentHypothesis.getInfo(),parentText.getInfo())
(hypothesisTree.getParentMap().get(hypothesisNode)!=null) // not root && for (ExtendedNode matchingTextNode : matchingNodesMap.get(hypothesisNode)) if (Equalities.areEqualRelations(hypothesisNode, matchingTextNode, hypothesisTree.getParentMap(), textTree.getParentMap()))
public static AStarTreeElement createElement(TreeAndFeatureVector textTree, TreeAndParentMap<ExtendedInfo, ExtendedNode> textTreeAndParentMap, TreeAndParentMap<ExtendedInfo, ExtendedNode> hypothesis, Classifier classifier, TreeHistory history, String sentence, int distance, AStarTreeElement generatedFrom, double estimationPerMissingNode ) throws ClassifierException, TeEngineMlException { double estimation = aStarEstimation(textTree,textTreeAndParentMap,hypothesis,classifier, estimationPerMissingNode); return new AStarTreeElement(textTree.getTree(), textTreeAndParentMap.getParentMap(),history, textTree.getFeatureVector(), sentence, distance, estimation, generatedFrom); }
ExtendedNode parent = originalHypothesisTree.getParentMap().get(missingHypothesisNode);
ExtendedNode textParent = text.getParentMap().get(textNode); ExtendedNode hypothesisParent = hypothesis.getParentMap().get(hypothesisNode); if ( (textParent==null) && (hypothesisParent==null) )
S predicateParent = tree.getParentMap().get(predicate.getHead()); Set<S> predicateParentNodes = getInternalNodes(predicateParent); Argument<I, S> argument = new Argument<I, S>(predicateParentNodes,predicateParent,predicateParent);
AStarTreeElement newElement = new AStarTreeElement(generatedTree.getTree(), mapToTreeAndParentMap.get(generatedTree).getParentMap(), generator.getHistoryMap().get(generatedTree), generatedTree.getFeatureVector(), startingElementInRecursion.getOriginalSentence(), previousElement.getDistance()+1, estimation, previousElement);
ExtendedNode hypothesisParent = hypothesisTree.getParentMap().get(hypothesisChild); if (hypothesisParent!=null)