/** * Convert the given ValueSetMap to a string of the form: * <p>key1 => value1</p> * <p>key2 => value2</p> * <p>...</p> */ public static <K,V> String mapToString(ValueSetMap<K,V> theMap) { StringBuilder sb = new StringBuilder(); for (K key: theMap.keySet()) sb.append(key).append(" => ").append(theMap.get(key)).append("\n"); return sb.toString(); }
@Override public ImmutableSet<K> keySet() { ImmutableSet<K> ret = null; if (this.bidirectionalMap!=null) { ret = this.bidirectionalMap.leftSet(); } else { ret = this.valueSetMap.keySet(); } return ret; }
private void buildSpecifications() { specs = new LinkedHashSet<RuleSpecification>(); for (BasicNode lhs : matchedLeftHandSides.keySet()) { for (RuleWithConfidenceAndDescription<Info, BasicNode> rule : allMatchedRules.get(lhs)) { for (BidirectionalMap<BasicNode,ExtendedNode> mapLhsToTree : matchedLeftHandSides.get(lhs)) { specs.add(new RuleSpecification(ruleBaseName,rule,mapLhsToTree,this.introduction)); } } } }
/** * The inverse of {@link #mapFromWikiText(String, boolean, boolean)}. * <p>Convert the given ValueSetMap to a string in wiki format: * * <pre> * == key 1 == * * value 1-1 * * value 1-2 * ... * == key 2 == * * value 2-1 * * value 2-2 * ... * ... * </pre> */ public static <K,V> String mapToWikiText(ValueSetMap<K,V> theMap) { StringBuilder sb = new StringBuilder(); for (K key: theMap.keySet()) { sb.append("== ").append(key).append(" ==\n"); for (V value: theMap.get(key)) { sb.append("* ").append(value).append("\n"); } } return sb.toString(); }
/** * @param mapPredToType * @param map2ndPredToType * @param expandedPropertiesFile * @throws IOException */ private static void printWNExpandedPredicateTypePropertiesFile(HashMap<String, PredicateSignature> mapPredToType, HashMap<String, PredicateSignature> map2ndPredToType, File expandedPropertiesFile) throws IOException { // join maps mapPredToType.putAll(map2ndPredToType); // build reversed map ValueSetMap<PredicateSignature, String> mapTypeToPred = Utils.reverseMapIntoValueSetMap(mapPredToType); StringBuilder buf = new StringBuilder(); for (PredicateSignature predType : mapTypeToPred.keySet()) buf.append(predType.name()).append(" = ").append(mapTypeToPred.get(predType)).append("\n\n"); String contents = buf.toString().replaceAll("[\\[\\]]", ""); // remove Java's parenthesis FileUtils.writeFile(expandedPropertiesFile, contents); }
private void extractMatchedRules() throws OperationException { try { allMatchedRules = new LinkedHashMap<BasicNode, ImmutableSet<RuleWithConfidenceAndDescription<Info,BasicNode>>>(); for (BasicNode lhs : matchedLeftHandSides.keySet()) { if (!allMatchedRules.containsKey(lhs)) { ImmutableSet<RuleWithConfidenceAndDescription<Info, BasicNode>> rules = ruleBase.getRulesByLeftHandSide(lhs); if (null==rules)throw new OperationException("DynamicRuleBase returned null for a certain left hand side, that was earlier returned by getLeftHandSidesByLemmaAndPos()"); allMatchedRules.put(lhs, rules); } } } catch (RuleBaseException e) { throw new OperationException("error",e); } }
private static <T> ValueSetMap<T, T> generateMapWithMappedValues(BidirectionalMap<T, T> bidiMap, ValueSetMap<T, T> originalValueSetMap) { ValueSetMap<T, T> ret = new SimpleValueSetMap<T, T>(); for (T element : originalValueSetMap.keySet()) { for (T mappedInOriginal : originalValueSetMap.get(element)) { ret.put(element, bidiMap.leftGet(mappedInOriginal)); } } return ret; }
@Override public void find() throws OperationException { specs = new LinkedHashSet<SubstitutionSubtreeSpecification>(); try { findCoreferringNodes(); for (ExtendedNode nodeInTree : this.getMapNodeToCoreferringNodes().keySet()) { for (ExtendedNode coreferringNode : this.getMapNodeToCoreferringNodes().get(nodeInTree)) { specs.add(new SubstitutionSubtreeSpecification("Coreference substitution", nodeInTree, coreferringNode)); } } } catch (TreeCoreferenceInformationException e) { throw new OperationException("Coreference problem. See nested exception.",e); } }
@Override public void find() throws OperationException { try { fillMapTextNodesToHypothesisNodes(); this.specs = new LinkedHashSet<SubstituteNodeSpecification>(); for (ExtendedNode textNode : mapTextNodesToHypothesisNodes.keySet()) { for (ExtendedNode hypothesisNode : mapTextNodesToHypothesisNodes.get(textNode)) { SubstituteNodeSpecification spec = new SubstituteNodeSpecification(textNode, hypothesisNode.getInfo().getNodeInfo(),textNode.getInfo().getAdditionalNodeInformation()); specs.add(spec); } } } catch(LemmatizerException e) { throw new OperationException("Lemmatizer failed. See nested Exception",e); } }
for (BasicNode lhsNode : vsmNeInTree.keySet())
for (NomlexArgument nomlexArgument : mapNomlexArgumentsToArgumentType.keySet())
for (K key : left.keySet())
for (String entityId : mapEntityToNode.keySet())
for (ExtendedNode hypothesisNode : matchIgnoreAnnotationHypothesisToText.keySet())