Initialize the map of language probabilities.
If there is the specified prior map, use it as initial map.
@return initialized map of language probabilities
184102
private double[] initProbability() {
        double[] prob = new double[ngramFrequencyData.getLanguageList().size()];
        if (priorMap != null) {
            //TODO analyze and optimize this code, looks like double copy.
            System.arraycopy(priorMap, 0, prob, 0, prob.length);
            for(int i=0;i<prob.length;++i) prob[i] = priorMap[i];
        } else {
            for(int i=0;i<prob.length;++i) prob[i] = 1.0 / ngramFrequencyData.getLanguageList().size();
        }
        return prob;
    }


    /**
     * update language probabilities with N-gram string(N=1,2,3)
     * @param count 1-n: how often the gram occurred.
     */
    private boolean updateLangProb(@NotNull double[] prob, @NotNull String ngram, int count, double alpha) {
        double[] langProbMap = ngramFrequencyData.getProbabilities(ngram);
        if (langProbMap==null) {
            return false;
        }
        if (logger.isTraceEnabled()) logger.trace(ngram + "(" + Util.unicodeEncode(ngram) + "):" + Util.wordProbToString(langProbMap, ngramFrequencyData.getLanguageList()));

        double weight = alpha / BASE_FREQ;
        if (ngram.length() >1) {
            if (prefixFactor !=1.0 && ngram.charAt(0)==' ') {
                weight *= prefixFactor;
            } else if (suffixFactor!=1.0 && ngram.charAt(ngram.length()-1)==' ') {
                weight *= suffixFactor;
            }
        }
        for (int i=0; i<prob.length; ++i) {
            for (int amount=0; amount<count; amount++) {
                prob[i] *= (weight + langProbMap[i]);
            }
        }
        return true;
    }


    /**
     * Returns the detected languages sorted by probabilities descending.
     * Languages with less probability than PROB_THRESHOLD are ignored.
     */
    @NotNull
    private List<DetectedLanguage> sortProbability(double[] prob) {
        List<DetectedLanguage> list = new ArrayList<>();
        //step 1: add all that have reached a minimal probability:
        for (int j=0;j<prob.length;++j) {
            double p = prob[j];
            if (p >= probabilityThreshold) {
                list.add(new DetectedLanguage(ngramFrequencyData.getLanguage(j), p));
            }
        }
        //step 2: sort in descending order
        if (list.size() >= 2) {
            Collections.sort(list, PROBABILITY_SORTING_COMPARATOR);
        }
        return list;
    }

}
363032
protected List<List<String>> prepareToStringProbabilistic()
    {
        // adding zeros
        for (String row : allGoldLabels) {
            if (!map.containsKey(row)) {
                map.put(row, new TreeMap<String, Integer>());
            }

            for (String col : allPredictedLabels) {
                if (!map.get(row).containsKey(col)) {
                    map.get(row).put(col, 0);
                }
            }
        }

        List<List<String>> result = new ArrayList<>();

        List<String> allPredictedLabelsSorted = new ArrayList<>();
        TreeSet<String> extraPredictedLabels = new TreeSet<>(allPredictedLabels);
        extraPredictedLabels.removeAll(allGoldLabels);

        allPredictedLabelsSorted.addAll(allGoldLabels);
        allPredictedLabelsSorted.addAll(extraPredictedLabels);

        // header
        List<String> header = new ArrayList<>();
        header.add("↓gold\\pred→");
        header.addAll(allPredictedLabelsSorted);
        result.add(header);

        for (String rowLabel : allGoldLabels) {
            List<String> row = new ArrayList<>();
            row.add(rowLabel);

            double rowSum = getRowSum(rowLabel);

            for (String predictedLabel : allPredictedLabelsSorted) {
                double value = 0;

                if (this.map.containsKey(rowLabel) && this.map.get(rowLabel)
                        .containsKey(predictedLabel)) {
                    value = this.map.get(rowLabel).get(predictedLabel) / rowSum;
                }
                row.add(String.format(locale, getFormat(), value));
            }

            result.add(row);
        }

        return result;
    }
750760
public static Map createInitParamMap(PageContext pContext)
    {
        final ServletContext context = pContext.getServletContext();

        return new EnumeratedMap()
        {
            public Enumeration enumerateKeys()
            {
                return context.getInitParameterNames();
            }

            public Object getValue(Object pKey)
            {
                if (pKey instanceof String) {
                    return context.getInitParameter((String) pKey);
                } else {
                    return null;
                }
            }

            public boolean isMutable()
            {
                return false;
            }
        };
    }
141959
public Map<String, String> toMap() {
        Map<String, String> map = new HashMap<>();

        map.put("message", message);
        map.put("country-code", countryCode);
        map.put("url", url);

        return map;
    }
386404
public Map<String, String> toMap()
	{
		Map<String, String> map = new HashMap<>(vars.size());

		for (NameValuePair nvp : vars.values())
			map.put(nvp.name, nvp.value);

		return map;
	}
1355068
public ImmutableList<AbstractElement> getFirstSetGrammarElements() {
		if (firstSetGrammarElements == null) {
			firstSetGrammarElements = ImmutableList.copyOf(mutableFirstSetGrammarElements);
		}
		return firstSetGrammarElements;
	}
400729
function (map) {
            var key;
            for (key in map) {
                if (map.hasOwnProperty(key)) {
                    this._init(key, map[key]);
                }
            }
            return this;
        }
1296805
public Set entrySet() {
        if(_entrySet == null) {
            Map piMap = InternalUtils.getPageInputMap(_request);
            ArrayList list = new ArrayList();
            if(piMap != null) {
                Iterator iterator = piMap.keySet().iterator();
                while(iterator.hasNext()) {
                    Object name = iterator.next();
                    Object value = piMap.get(name);
                    list.add(new Entry(name, value));
                }
            }

            _entrySet = new EntrySet((Entry[])list.toArray(new Entry[]{}));
        }

        return _entrySet;
    }
1290201
@SuppressWarnings("unchecked")
	public T initKeys() {
		KeyPair keyPair = SecureUtil.generateKeyPair(this.algorithm);
		this.publicKey = keyPair.getPublic();
		this.privateKey = keyPair.getPrivate();
		return (T) this;
	}
68475
public HashMap<Integer, byte[]> getPreKeys() {
        if (preKeys == null) {
            preKeys = new HashMap<>();
            for (int id : preKeysB64.keySet()) {
                preKeys.put(id, Base64.decode(preKeysB64.get(id)));
            }
        }
        return this.preKeys;
    }
1215477
public Pair<Long, Long> getFirstGap() {
        if (m_map.isEmpty() || size() < 2) {
            return null;
        }
        Iterator<Range<Long>> iter = m_map.asRanges().iterator();
        long start = end(iter.next()) + 1;
        long end = start(iter.next()) - 1;
        return new Pair<Long, Long>(start, end);
    }
707844
public static <K, V> V first( NavigableMap<K, V> map ) {
        return map.firstEntry().getValue();
    }
1184317
public Map<String, Set<String>> getTargetLanguagesByBundle() {
        if (targetLanguagesByBundle == null) {
            assert false;
            return Collections.emptyMap();
        }
        return Collections.unmodifiableMap(targetLanguagesByBundle);
    }
1140448
public static NumberList delta(Map<String, Object> currentMap, Map<String, Object> previousMap) {
        LinkedHashMap<String, Long> values = new LinkedHashMap<String, Long>(currentMap.size());
        if(currentMap.size() != previousMap.size()) {
            throw new IllegalArgumentException("Maps must have the same keys");
        }
        for (Entry<String, Object> k : currentMap.entrySet()) {
            Object v = k.getValue();
            Number current = getNumber(v);
            Object p = previousMap.get(k.getKey());
            Number previous = null;
            if (p == null) {
                previous = 0;
            } else {
                previous = getNumber(p);
            }

            long d = (current.longValue() - previous.longValue());
            values.put(k.getKey(), d);
        }

        return new NumberList(values);
    }
937187
private Map getDialogObjectMap() {

        Map objects = (Map)getSettings().getDialogObject();
        if (objects == null) {
            // using hashtable as most efficient version of a synchronized map
            objects = new Hashtable();
            getSettings().setDialogObject(objects);
        }
        return objects;
    }
1217698
public static Map<String, String> getImmutableContext() {
        final Map<String, String> map = contextMap.getImmutableMapOrNull();
        return map == null ? EMPTY_MAP : map;
    }
260048
public final Map<String,Set<IDialect>> getDialectsByPrefix() {
        final Set<DialectConfiguration> dialectConfs;
        if (this.initialized) {
            dialectConfs = this.configuration.getDialectConfigurations();
        } else {
            dialectConfs = this.dialectConfigurations;
        }
        final Map<String,Set<IDialect>> dialectsByPrefix = new LinkedHashMap<String, Set<IDialect>>(3);
        for (final DialectConfiguration dialectConfiguration : dialectConfs) {
            final String prefix = dialectConfiguration.getPrefix();
            Set<IDialect> dialectsForPrefix = dialectsByPrefix.get(prefix);
            if (dialectsForPrefix == null) {
                dialectsForPrefix = new LinkedHashSet<IDialect>(2);
                dialectsByPrefix.put(prefix, dialectsForPrefix);
            }
            dialectsForPrefix.add(dialectConfiguration.getDialect());
        }
        return Collections.unmodifiableMap(dialectsByPrefix);
    }