public void copy(int depth) { mapOriginalToGenerated = new SimpleBidirectionalMap<ExtendedNode, ExtendedNode>(); generatedTree = copy(tree,depth,newRootEdgeInfo); }
@Override public void put(L left, R right) { if (null==left) throw new NullForbiddenException("left is null"); if (null==right) throw new NullForbiddenException("right is null"); super.put(left, right); } }
public MapLocalScorer(Set<String> component, double unknownScore, boolean convertProb2Score) { m_desc2idMap = new SimpleBidirectionalMap<String,Integer>(); int id = 1; for(String predicate:component) m_desc2idMap.put(predicate, id++); m_rule2ScoreMap = new LinkedHashMap<Pair<Integer,Integer>, Double>(); m_entailing = new HashSet<Pair<String,String>>(); m_nonEntailing = new HashSet<Pair<String,String>>(); m_convertProb2Score = convertProb2Score; m_unknownScore = prob2Score(unknownScore); }
public void generate() throws TeEngineMlException { mapOrigToGenerated = new SimpleBidirectionalMap<ST, ST>(); affectedNodes = new LinkedHashSet<ST>(); generatedTree = copyRuleSubTree(rule.getRightHandSide(),edgeInfoForRoot); }
/** * Build a {@link SyntacticRule} out of an LHS RHS and alignments. Convert them from {@link AbstractConstructionNode} to {@link AbstractNode}, first. * @param oldLhsRoot * @param oldRhsRoot * @param nodeAlignments * @param isExtraction * @return */ private SyntacticRule<I, N> buildRule(CN oldLhsRoot, CN oldRhsRoot, BidirectionalMap<CN, CN> nodeAlignments, boolean isExtraction) { BidirectionalMap<N, N> newAlignments = new SimpleBidirectionalMap<N, N>(); BidirectionalMap<N, CN> helpMap = new SimpleBidirectionalMap<N, CN>(); N newLhsRoot = convertLhsToNNodes(oldLhsRoot, nodeAlignments, helpMap ); N newRhsRoot = convertRhsToNNodes(oldRhsRoot, helpMap, newAlignments ); return new SyntacticRule<I, N>(newLhsRoot, newRhsRoot, newAlignments, isExtraction); }
@Override protected void generateTheTree() throws OperationException { affectedNodes = new LinkedHashSet<ExtendedNode>(); mapOrigToGenerated = new SimpleBidirectionalMap<ExtendedNode, ExtendedNode>(); mapGeneratedToOrig = new LinkedHashMap<ExtendedNode, ExtendedNode>(); substitutionNodeEncountered = false; this.generatedTree = copySubTree(textTree.getTree(),null,null,false); updateAntecedents(); }
public void annotate() throws AnnotatorException { mapOriginalToAnnotated = new SimpleBidirectionalMap<ExtendedNode, ExtendedNode>(); for (ExtendedNode node : TreeIterator.iterableTree(this.tree)) { mapOriginalToAnnotated.put(node, node); } annotated=true; }
@Override protected void generateTheTree() throws OperationException { mapOrigToGenerated = new SimpleBidirectionalMap<ExtendedNode, ExtendedNode>(); affectedNodes = new LinkedHashSet<ExtendedNode>(); this.generatedTree = copySubTree(this.textTree.getTree()); updateAntecedents(); }
protected void initTraces() throws TeEngineMlException { if (Constants.TRACE_ORIGINAL_NODES) { logger.info("Setting initial trace information..."); BidirectionalMap<ExtendedNode, ExtendedNode> bidiFromOriginal = null; if (mapOriginalToInitialized!=null) bidiFromOriginal = new SimpleBidirectionalMap<ExtendedNode, ExtendedNode>(); List<ExtendedNode> newTextTrees = new ArrayList<ExtendedNode>(originalTextTrees.size()); Map<ExtendedNode,String> newMapTreeToSentence = new LinkedHashMap<ExtendedNode, String>(); for (ExtendedNode textTree : originalTextTrees) { SelfTraceSetter setter = new SelfTraceSetter(textTree); setter.set(); ExtendedNode newTree = setter.getNewTree(); newTextTrees.add(newTree); newMapTreeToSentence.put(newTree, originalMapTreesToSentences.get(textTree)); if (mapOriginalToInitialized!=null) DsUtils.BidiMapAddAll(bidiFromOriginal, setter.getMapping()); } originalTextTrees = newTextTrees; originalMapTreesToSentences = newMapTreeToSentence; if (mapOriginalToInitialized!=null) mapOriginalToInitialized = DsUtils.concatenateBidiMaps(mapOriginalToInitialized, bidiFromOriginal); logger.info("Setting initial trace information done."); } }
public void createMapTemplateToId() throws SQLException, RuleBaseException { mapTemplateToId = new SimpleBidirectionalMap<String, Integer>(); String query = "SELECT id,description FROM "+dbParameters.getTemplatesTableName(); Statement statement = connection.createStatement(); try { ResultSet resultSet = statement.executeQuery(query); while(resultSet.next()) { int id = resultSet.getInt("id"); String description = resultSet.getString("description"); if (description.isEmpty()) ; // ignore rows with an empty pattern-description - they represent duplicates of another row that represents their pattern. else { if (mapTemplateToId.leftContains(description)) throw new RuleBaseException("Malformed rule base. Template "+description+" appears more than once."); mapTemplateToId.put(description, id); } } } finally { statement.close(); } }
@Override protected void generateTheTree() throws OperationException { if (textTree.getTree()==nodeToMove) throw new OperationException("Moving the root is illegal."); affectedNodes = new LinkedHashSet<ExtendedNode>(); mapOrigToCopy = new SimpleBidirectionalMap<ExtendedNode, ExtendedNode>(); this.generatedTree = recursiveGenerate(textTree.getTree(),null,false); updateAntecedentInformation(); this.nodeToMoveNotExistInGeneratedTree = !nodeHasAlreadyBeenMoved; }
@Override protected void generateTheTree() throws OperationException { this.affectedNodes = new LinkedHashSet<ExtendedNode>(); mapOrigToGenerated = new SimpleBidirectionalMap<ExtendedNode, ExtendedNode>(); this.generatedTree = copyTree(this.textTree.getTree()); updateAntecedents(); ExtendedNode parent = mapOrigToGenerated.leftGet(whereToInsert); ExtendedNode insertedNode = new ExtendedNode(nodeToInsert); // ExtendedNode insertedNode = new ExtendedNode(new ExtendedInfo(nodeToInsert.getId(),nodeToInsert.getNodeInfo(),nodeToInsert.getEdgeInfo(),AdditionalInformationServices.emptyInformation())); affectedNodes.add(insertedNode); parent.addChild(insertedNode); }
if (mapOriginalToInitialized!=null) bidiFromOriginal = new SimpleBidirectionalMap<ExtendedNode, ExtendedNode>();
public void initialize() throws TeEngineMlException, AnnotatorException, TreeCoreferenceInformationException { logStartInitialize(); mapOriginalToGenerated = new SimpleBidirectionalMap<BasicNode, ExtendedNode>(); BasicNode tree = getNextTree(); while (tree!=null) { createTree(tree); tree = getNextTree(); } if (originalCoreferenceInformation!=null) { createCorefInformation(); } logger.debug("DocumentInitializer: Initialization done."); }
throws EntailmentCompilationException BidirectionalMap<CN, CN> alignmentsMap = new SimpleBidirectionalMap<CN, CN>(); for (GenericAlignment alignment : idAlignments)
public void merge() throws CoreferenceResolutionException mergedOutput = new SimpleBidirectionalMap<>(); S currentTree = trees.iterator().next(); ListIterator<ArkrefOutputWord<I,S>> arkrefOutputIterator = arkrefOutput.listIterator();
if (AbstractNodeUtils.treeToLinkedHashSet(rhsTree).size()==neList.size()) BidirectionalMap<BasicNode, BasicNode> mapNodes = new SimpleBidirectionalMap<BasicNode, BasicNode>(); BasicNode mappedRhsNode = null; for (BasicNode rhsNode : TreeIterator.iterableTree(rhsTree))
public static <L, R, M> BidirectionalMap<L, R> concatenateBidiMaps(BidirectionalMap<L, M> map1,BidirectionalMap<M, R> map2) throws TeEngineMlException { boolean failed = false; BidirectionalMap<L, R> ret = new SimpleBidirectionalMap<L, R>(); for (L l : map1.leftSet()) { M m = map1.leftGet(l); if (!map2.leftContains(m)) failed=true; ret.put(l, map2.leftGet(m) ); } if (failed) throw new TeEngineMlException("Concatenation failed."); else return ret; } }
BidirectionalMap<BasicNode, BasicNode> ruleMapping = new SimpleBidirectionalMap<BasicNode, BasicNode>();
/** * Generates the tree * @throws CandCTreesGenerationException */ public void generateTree() throws CandCTreesGenerationException { try { mapCCNodeToTreeNode = new SimpleBidirectionalMap<CCNode, S>(); BfsDirectedGraphScan<CCNode, CCEdgeInfo> scan = new BfsDirectedGraphScan<CCNode, CCEdgeInfo>(new CCTreeGenerationScanOperation(), graph); scan.scan(startNode); if (exception != null) throw exception; } catch (DirectedGraphScanException e) { throw new CandCTreesGenerationException("graph scan error. see nested exception",e); } catch (DirectedGraphException e) { throw new CandCTreesGenerationException("graph error. see nested exception",e); } }