void addProfile(LangProfile profile) {
        String lang = profile.name;
        if (langlist.contains(lang)) {
            throw new IllegalArgumentException("Duplicate language profile for [" + lang + "]");
        }
        int index = langlist.size();
        if (capacity <= index) {
            ensureCapacity(capacity + 1);
        }
        this.langlist.add(lang);
        for (String word: profile.freq.keySet()) {
            if (!this.wordLangProbMap.containsKey(word)) {
                this.wordLangProbMap.put(word, new double[capacity]);
            }
            int length = word.length();
            if (length >= 1 && length <= 3) {
                double prob = profile.freq.get(word).doubleValue() / profile.n_words[length - 1];
                this.wordLangProbMap.get(word)[index] = prob;
            }
        }
    }