private boolean filterAntecedent(S begin, S end, S common) { if ( (begin.getAntecedent()==end) || (end.getAntecedent()==begin) ) { return true; } return false; }
public OriginalTreesAfterInitialization( List<ExtendedNode> originalTextTrees, ExtendedNode hypothesisTree, Map<ExtendedNode, String> originalMapTreesToSentences, TreeCoreferenceInformation<ExtendedNode> coreferenceInformation) throws TreeAndParentMapException { super(); this.originalTextTrees = originalTextTrees; this.hypothesisTree = hypothesisTree; this.originalMapTreesToSentences = originalMapTreesToSentences; hypothesisTreeAndParentMap = new TreeAndParentMap<ExtendedInfo, ExtendedNode>(this.hypothesisTree); this.coreferenceInformation = coreferenceInformation; }
private void addLemmasOfTextFromTree(S tree) { for (S node : TreeIterator.iterableTree(tree)) { lemmasOfText_lowerCase.add(InfoGetFields.getLemma(node.getInfo()).toLowerCase()); } }
public static double missingNodesPortion(TreeAndParentMap<ExtendedInfo,ExtendedNode> text, TreeAndParentMap<ExtendedInfo,ExtendedNode> hypothesis) { int totalNumberOfNodes = AbstractNodeUtils.treeToLinkedHashSet(hypothesis.getTree()).size(); int numberOfMissingNodes = findNodesNoMatch(text, hypothesis).size(); return ((double)numberOfMissingNodes)/((double)totalNumberOfNodes); }
public static <T, S extends AbstractNode<T, S>> void integrateParserAntecedentToCoreference(List<S> textTrees, TreeCoreferenceInformation<S> coreferenceInformation) throws TreeCoreferenceInformationException { for (S tree : textTrees) { for (S node : TreeIterator.iterableTree(tree)) { if (!coreferenceInformation.isNodeExist(node)) { if (node.getAntecedent()!=null) { S deepAntecedent = AbstractNodeUtils.getDeepAntecedentOf(node); if (coreferenceInformation.isNodeExist(deepAntecedent)) { Integer deepAntecedentGroupId = coreferenceInformation.getIdOf(deepAntecedent); coreferenceInformation.addNodeToGroup(deepAntecedentGroupId, node); } } } } } }
private void buildContentLemmasOfHypothesis() { Set<S> hypothesisPredicateNodes = getPredicateNodes(hypothesisStructures); contentLemmasOfHypothesisNonPredicates_lowerCase = contentLemmasOfNodes_lowerCase(TreeIterator.iterableTree(hypothesisTree.getTree()),hypothesisPredicateNodes); contentLemmasOfHypothesisPredicates_lowerCase = contentLemmasOfNodes_lowerCase(hypothesisPredicateNodes); }
private void init() throws TeEngineMlException { this.parentMap = AbstractNodeUtils.parentMap(tree); lca = new LeastCommonAncestor<I, S>(tree); try { lca.compute(); } catch (LeastCommonAncestorException e) { throw new TeEngineMlException("Failed to initialize TemplatesFromTree. See nested exception",e); } }
public static <T, S extends AbstractNode<T,S>> void addItself(S tree, ValueSetMap<S, S> mapOriginalToGenerated) { for (S node : TreeIterator.iterableTree(tree)) { mapOriginalToGenerated.put(node, node); } }
public MoveNodeOperation(TreeAndParentMap<ExtendedInfo,ExtendedNode> textTree, TreeAndParentMap<ExtendedInfo,ExtendedNode> hypothesisTree, ExtendedNode nodeToMove, ExtendedNode newParent, EdgeInfo newEdgeInfo) throws OperationException { super(textTree, hypothesisTree); if (hypothesisTree.getTree()==nodeToMove) throw new OperationException("Moving the root is illegal."); this.nodeToMove = nodeToMove; this.newParent = newParent; this.newEdgeInfo = newEdgeInfo; }
private static void mapItself(BidirectionalMap<ExtendedNode, ExtendedNode> map, ExtendedNode tree) { for (ExtendedNode node : AbstractNodeUtils.treeToLinkedHashSet(tree)) { map.put(node,node); } }
public BidirectionalMap<ExtendedNode, ExtendedNode> getNodesMap() throws TeEngineMlException { if (null==treeCopier) throw new TeEngineMlException("Not generated"); return treeCopier.getNodesMap(); }
public static double missingRelationsPortion(TreeAndParentMap<ExtendedInfo,ExtendedNode> text, TreeAndParentMap<ExtendedInfo,ExtendedNode> hypothesis) { int totalNumberOfRelations = AbstractNodeUtils.treeToLinkedHashSet(hypothesis.getTree()).size()-1; if (0==totalNumberOfRelations) return 0; else { int numberOfMissingRelations = findRelationsNoMatch(text, hypothesis).size(); return ((double)numberOfMissingRelations)/((double)totalNumberOfRelations); } }
private void updateAntecedents() { Set<ExtendedNode> originalTreeNodes = AbstractNodeUtils.treeToLinkedHashSet(textTree.getTree()); for (ExtendedNode originalTreeNode : originalTreeNodes) { if (originalTreeNode.getAntecedent()!=null) { ExtendedNode originalTreeNodeAntecedent = originalTreeNode.getAntecedent(); mapOrigToGenerated.leftGet(originalTreeNode).setAntecedent(mapOrigToGenerated.leftGet(originalTreeNodeAntecedent)); } } }
private String lemma(S node) { return InfoGetFields.getLemma(node.getInfo()); }
public String getEdgeStringRepresentation() { return InfoGetFields.getRelation(node.getInfo()); }
public String getEdgeStringRepresentation() { return InfoGetFields.getRelation(node.getInfo()); }