@Override public boolean containsValue(V value) { boolean ret = false; if (this.bidirectionalMap!=null) { ret = this.bidirectionalMap.rightContains(value); } else { ret = this.valueSetMap.containsValue(value); } return ret; }
@Override public ImmutableSet<K> getKeysOf(V value) { ImmutableSet<K> ret = null; if (this.bidirectionalMap!=null) { LinkedHashSet<K> set = new LinkedHashSet<K>(); if (this.bidirectionalMap.rightContains(value)) { K key = this.bidirectionalMap.rightGet(value); set.add(key); } ret = new ImmutableSetWrapper<K>(set); } else { ret = this.valueSetMap.getKeysOf(value); } return ret; }
/** * @param node * @param mapNodeToId * @param id * @param nodeToConllStringConvertor * @param variableId * @return * @throws ConllConverterException */ private static <I extends Info, N extends AbstractNode<I, N>> StringBuilder nodeToConll(N node, BidirectionalMap<N, N> alignments, Map<N, Integer> mapNodeToId, RuleConllStringConverter<I, N> nodeToConllStringConvertor) throws ConllConverterException { StringBuilder conllStr = new StringBuilder(); int variableId = -1; // -1 means no alignment if (alignments.leftContains(node)) variableId = mapNodeToId.get(alignments.leftGet(node)); else if (alignments.rightContains(node)) variableId = mapNodeToId.get(alignments.rightGet(node)); conllStr.append(nodeToConllStringConvertor.convert(node, mapNodeToId, variableId)).append('\n'); if (node.hasChildren()) for (N child : node.getChildren()) conllStr.append(nodeToConll(child, alignments , mapNodeToId, nodeToConllStringConvertor)); return conllStr; }
if (!mapTemplateToId.rightContains(idAndScore.getId())) throw new RuleBaseException("BUG in rule base "+this.ruleBaseName); String rightHandSideTemplate = mapTemplateToId.rightGet(idAndScore.getId()); if (null==givenTemplateConverter)
protected ST copyNonRuleSubTree(ST subtree) { ST ret = nodeConstructor.newNode(subtree.getInfo()); if (subtree.getChildren()!=null) { for (ST child : subtree.getChildren()) { if (!mapRuleLhsToTree.rightContains(child)) { ret.addChild(copyNonRuleSubTree(child)); } } } mapOrigToGenerated.put(subtree, ret); return ret; }
/** * @param rhs * @param helpMap * @param newMapping * @return */ private N convertRhsToNNodes( CN rhs, BidirectionalMap<N, CN> helpMap, BidirectionalMap<N, N> newMapping) { N newRhs = compilationServices.newNode(rhs.getInfo()); if (rhs.getChildren() != null) for (CN child : rhs.getChildren()) { N newChild = convertRhsToNNodes(child, helpMap, newMapping); newRhs.addChild(newChild); newChild.setAntecedent(newRhs); } // update the new mapping if necessary if (helpMap.rightContains(rhs)) newMapping.put(helpMap.rightGet(rhs), newRhs); return newRhs; }
if (node.getInfo().getNodeInfo().isVariable() && !rule.getMapNodes().rightContains(node)) throw new EntailmentCompilationException("There's an rhs node that is an unmapped variable: " + node);
if (rule.getMapNodes().rightContains(ruleRhsSubTree)) if (rule.getMapNodes().rightContains(ruleRhsSubTree)) if (!mapRuleLhsToTree.rightContains(originalTreeChild)) if (rule.getMapNodes().rightContains(ruleRhsSubTree))