/** * @return the Collection mapped to by key, never null, but may be empty. */ public CollectionValuedMap<K2,V> getCollectionValuedMap(K1 key1) { CollectionValuedMap<K2,V> cvm = map.get(key1); if (cvm == null) { cvm = new CollectionValuedMap<>(mf, cf, treatCollectionsAsImmutable); map.put(key1, cvm); } return cvm; }
/** * yes, this is a weird method, but i need it. * */ public void addKey(K1 key1) { CollectionValuedMap<K2,V> cvm = map.get(key1); if (cvm == null) { cvm = new CollectionValuedMap<>(mf, cf, treatCollectionsAsImmutable); map.put(key1,cvm); } }
/** * Adds the value to the Collection mapped to by the key. * */ public void add(K1 key1, K2 key2, V value) { CollectionValuedMap<K2,V> cvm = map.get(key1); if (cvm == null) { cvm = new CollectionValuedMap<>(mf, cf, treatCollectionsAsImmutable); map.put(key1,cvm); } cvm.add(key2,value); }
/** * Creates a "delta copy" of this Map, where only the differences * from the original Map are represented. (This typically assumes * that this map will no longer be changed.) */ public CollectionValuedMap<K, V> deltaCopy() { Map<K,Collection<V>> deltaMap = new DeltaMap<>(this.map); return new CollectionValuedMap<>(null, cf, true, deltaMap); }
/** * Adds a collection of values to the Collection mapped to by the key. * */ public void add(K1 key1, K2 key2, Collection<V> value) { CollectionValuedMap<K2,V> cvm = map.get(key1); if (cvm == null) { cvm = new CollectionValuedMap<>(mf, cf, treatCollectionsAsImmutable); map.put(key1,cvm); } for(V v: value) cvm.add(key2,v); }
public static <K,V> CollectionValuedMap<Iterable<K>, V> collectionValuedTrieMap(CollectionFactory<V> collectionFactory) { return new CollectionValuedMap<>( TrieMapUtils.<K, Collection<V>>trieMapFactory(), collectionFactory, false); }
public void labelWords(String label, Map<String, DataInstance> sents, Collection<CandidatePhrase> identifiedWords) throws IOException { CollectionValuedMap<E, Triple<String, Integer, Integer>> matchedTokensByPat = new CollectionValuedMap<>(); labelWords(label, sents, identifiedWords, null, matchedTokensByPat); }
private void readSRLFile(String srlFile) { srlMap = Generics.newHashMap(); for (String line : ObjectBank.getLineIterator(new File(srlFile))) { String[] bits = line.split("\\s+", 3); String filename = bits[0]; int treeNum = Integer.parseInt(bits[1]); String info = bits[2]; CollectionValuedMap<Integer,String> cvm = srlMap.get(filename); if (cvm == null) { cvm = new CollectionValuedMap<>(); srlMap.put(filename, cvm); } cvm.add(treeNum, info); } }
public static <K,V> CollectionValuedMap<Iterable<K>, V> collectionValuedTrieMap() { return new CollectionValuedMap<>( TrieMapUtils.<K, Collection<V>>trieMapFactory(), CollectionFactory.<V>hashSetFactory(), false); }
@Override public CollectionValuedMap<String, String> getRelevantWords() { CollectionValuedMap<String, String> relwordsThisPat = new CollectionValuedMap<>(); for(Pair<Token, GrammaticalRelation> r: relations) getRelevantWordsBase(r.first(), relwordsThisPat); return relwordsThisPat; }
public CollectionValuedMap<String, JollyHoliday> getAllHolidaysCVMap(Set<de.jollyday.config.Holiday> allHolidays) { CollectionValuedMap<String, JollyHoliday> map = new CollectionValuedMap<>(); for (de.jollyday.config.Holiday h:allHolidays) { String descKey = h.getDescriptionPropertiesKey(); if (descKey != null) { descKey = descKey.replaceAll(".*\\.",""); JollyHoliday jh = new JollyHoliday(descKey, holidayManager, h); map.add(jh.label, jh); } } return map; }
CollectionValuedMap<String, E> sentIds2Pats = new CollectionValuedMap<>(); for(Map.Entry<E, Set<String>> setEn: sentids.entrySet()){ if(!sentsAll.containsKey(setEn.getKey()))
@Override public CollectionValuedMap<String, String> getRelevantWords() { CollectionValuedMap<String, String> relwordsThisPat = new CollectionValuedMap<>(); Token[] next = getNextContext(); getRelevantWordsBase(next, relwordsThisPat); Token[] prev = getPrevContext(); getRelevantWordsBase(prev, relwordsThisPat); return relwordsThisPat; }
CollectionValuedMap<IntPair, Mention> goldMentionPositions = new CollectionValuedMap<>(); for(Mention g : golds) { IntPair ip = new IntPair(g.startIndex, g.endIndex);
private static void updateTimeZoneNames(Locale locale) { long time1 = new SUTime.IsoDate(2013,1,1).getJodaTimeInstant().getMillis(); long time2 = new SUTime.IsoDate(2013,6,1).getJodaTimeInstant().getMillis(); CollectionValuedMap<String,DateTimeZone> tzMap = new CollectionValuedMap<>(); for (DateTimeZone dtz:TimeZoneIdComponent.timeZonesById.values()) { // standard timezones tzMap.add(dtz.getShortName(time1, locale).toLowerCase(), dtz); tzMap.add(dtz.getName(time1, locale).toLowerCase(), dtz); // Add about half a year to get day light savings timezones... tzMap.add(dtz.getShortName(time2, locale).toLowerCase(), dtz); tzMap.add(dtz.getName(time2, locale).toLowerCase(), dtz); // tzMap.add(dtz.getNameKey(time).toLowerCase(), dtz); // tzMap.add(dtz.getID().toLowerCase(), dtz); } // Order by length for regex List<String> tzNames = new ArrayList<>(tzMap.keySet()); Collections.sort(tzNames, STRING_LENGTH_REV_COMPARATOR); String tzRegex = makeRegex(tzNames); synchronized (TimeZoneComponent.class) { timeZoneNames.put(locale,tzNames); timeZonesByName.put(locale,tzMap); timeZoneRegexes.put(locale,tzRegex); } }
CollectionValuedMap<IntPair, Mention> goldMentionPositions = new CollectionValuedMap<>(); for(Mention g : golds) { IntPair ip = new IntPair(g.startIndex, g.endIndex);
List<ValuedInterval<CoreMap,Integer>> processed = new ArrayList<>(); CollectionValuedMap<Integer, ValuedInterval<CoreMap,Integer>> unprocessed = new CollectionValuedMap<>(CollectionFactory.<ValuedInterval<CoreMap, Integer>>arrayListFactory()); for (ValuedInterval<CoreMap,Integer> v:timexList) { CoreMap timexAnn = v.getValue();
JsonObjectBuilder pats = Json.createObjectBuilder(); for (Entry<E, Collection<Triple<String, Integer, Integer>>> en : tokensMatchedPat.entrySet()) { CollectionValuedMap<String, Pair<Integer, Integer>> matchedStrs = new CollectionValuedMap<>(); for (Triple<String, Integer, Integer> en2 : en.getValue()) { allMatchedSents.add(en2.first());
.get(PatternsAnnotations.MatchedPhrases.class); if (matchedPhrases == null) { matchedPhrases = new CollectionValuedMap<>(); matchedPhrases.add(label, CandidatePhrase.createOrGet(l.word()));
CollectionValuedMap<String, CoreMap> corefChainMap = new CollectionValuedMap<>(CollectionFactory.<CoreMap>arrayListFactory()); List<CoreMap> nerChunks = new ArrayList<>(); for (int i = 0; i < sentences.size(); i++) {