def morphologicalSimilarity(ehrAttribute, fhirAttribute, lemmaSimilarityThreshold=TranslationConstants.MORPHOLOGICAL_SIMILARITY_THRESHOLD):

        if SimilarityMetrics.textMatch(ehrAttribute, fhirAttribute): return 1;

        highestSimilarity = 0;

        for lemma in Utilities.lemmas(ehrAttribute):

            if SimilarityMetrics.textSimilarity(lemma, fhirAttribute, True) > highestSimilarity and SimilarityMetrics.textMatch(lemma, fhirAttribute, True, lemmaSimilarityThreshold):
                highestSimilarity = SimilarityMetrics.textSimilarity(lemma, fhirAttribute, True);

        return highestSimilarity;
Esempio n. 2
0
    def test_TestMorphological(self):

        # e.g. self.assertTrue(Matches.match("PostCode", "postalCode"));

        total = 0
        matched = 0
        for key, value in usToGB.items():
            lemmas = list(Utilities.lemmas(value))
            if (lemmas):
                total += 1
                shuffle(lemmas)
                if (Matches.matches(value, lemmas[0])):
                    matched += 1
                else:
                    print(str(value) + " " + str(lemmas[0]))
        matchPercentage = matched / float(total)
        self.assertTrue(matchPercentage > 0.90)