diff --git a/lib/model/yake_keywords.py b/lib/model/yake_keywords.py index 037be8c..915e8fe 100644 --- a/lib/model/yake_keywords.py +++ b/lib/model/yake_keywords.py @@ -25,14 +25,13 @@ def keep_largest_overlapped_keywords(self, keywords): if keep_keyword: cleaned_keywords.append(keywords[i]) return cleaned_keywords + def normalize_special_characters(self, text): replacement = {"`": "'", "‘": "'", "’": "'", "“": "\"", "”": "\""} - - for k, v in replacement.items(): text = text.replace(k, v) return text diff --git a/test/lib/model/test_yake_keywords.py b/test/lib/model/test_yake_keywords.py index 88750c6..9c36693 100644 --- a/test/lib/model/test_yake_keywords.py +++ b/test/lib/model/test_yake_keywords.py @@ -42,6 +42,7 @@ def test_run_yake_real(self): }) results = self.yake_model.run_yake(**self.yake_model.get_params(message)) self.assertEqual(results, {"keywords": [('love Meedan', 0.0013670273525686505)]}) + def test_keep_largest_overlapped_keywords(self): keywords_test = [('Alegre', 0),('Alegre', 0),('Timpani', 0), ('Presto Timpani', 0), ('AlegreAlegre', 0), ('Alegre Alegre', 0), ("Presto", 0)] expected = [('Presto Timpani', 0), ('AlegreAlegre', 0), ('Alegre Alegre', 0)]