Example #1
0
void Language::append(const Language &language) {
    for(unsigned int i = 0; i < language.size(); i++){
        Word* word = language.getWord(i);

        this->addWord(new Word(word));
    }
}
Example #2
0
Language::Language(const Language &language) :
        _alphabet(language.getAlphabet()){
    for(unsigned int i = 0; i < language.size(); i++){
        Word* otherWord = language.getWord(i);
        Word *word = new Word(*otherWord);

        this->addWord(word);
    }
}
    double similarity(const Language &language1, const Language &language2) {
        unsigned int size1 = language1.size();
        unsigned int size2 = language2.size();

        std::vector<double> wordSimilarities;
        double similarityLanguage = 0;
        for(unsigned int i = 0; i < size1; i++){
            wordSimilarities.clear();
            Word* word1 = language1.getWord(i);
            for(unsigned int j = 0; j < size2; j++){
                Word* word2 = language2.getWord(j);
                double similarity = word::similarity(*word1, *word2);
                wordSimilarities.push_back(similarity);
            }
            double maxSimilarity = math::max(wordSimilarities);
            similarityLanguage += maxSimilarity;
        }
        similarityLanguage /= size1;

        return similarityLanguage;
    }