def test_analyze_en(self): lexical_units = apertium.analyze('eng', 'cats') lexical_unit = lexical_units[0] self.assertListEqual(lexical_unit.readings, [[SReading(baseform='cat', tags=['n', 'pl'])]]) self.assertEqual(lexical_unit.wordform, 'cats') self.assertEqual(lexical_unit.knownness, known)
def lemmatize(word, lang): analysis = apertium.analyze(lang, word) if analysis: lemmas = list(OrderedDict.fromkeys([x.split('<')[0] for x in str(analysis[0]).split('/')[1:]])) else: lemmas = [] return list(''.join(lemmas))