def test_parse(self): lexical_units = list(parse(self.s1)) self.assertEqual(len(lexical_units), 1) lexical_unit = lexical_units[0] self.assertEqual(str(lexical_unit), 'x\/y\^\$\<z\>å/A\$\^B<tag><tag2>/A\/S<tag><#1-\>2>') readings = lexical_unit.readings self.assertListEqual( readings, [[SReading(baseform='A\\$\\^B', tags=['tag', 'tag2'])], [SReading(baseform='A\\/S', tags=['tag', '#1-\\>2'])]]) self.assertEqual(lexical_unit.wordform, 'x\/y\^\$\<z\>å') self.assertEqual(lexical_unit.knownness, known)
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 test_wordbound_blanks(self): lexical_units = list(parse(self.s5)) self.assertEqual(len(lexical_units), 3) self.assertListEqual( lexical_units[2].readings, [ [SReading(baseform='name', tags=['n', 'sg'])], [SReading(baseform='name', tags=['vblex', 'inf'])], [SReading(baseform='name', tags=['vblex', 'pres'])], ], ) self.assertEqual(lexical_units[0].wordform, 'My') self.assertEqual(lexical_units[0].wordbound_blank, '[[t:b:123456]]') self.assertEqual(lexical_units[1].wordform, 'test') self.assertEqual(lexical_units[1].wordbound_blank, '') self.assertEqual(lexical_units[2].wordform, 'name') self.assertEqual(lexical_units[2].wordbound_blank, '[[t:i:12asda; t:p:1abc76]]')
def test_tagger_en(self): tagger = apertium.Tagger('en') lexical_units = tagger.tag('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 test_parse_subreadings(self): lexical_units = list(parse(self.s4)) self.assertEqual(len(lexical_units), 1) self.assertListEqual( lexical_units[0].readings, [ [ SReading(baseform='decir', tags=['vblex', 'imp', 'p2', 'sg']), SReading(baseform='me', tags=['prn', 'enc', 'p1', 'mf', 'sg']), SReading(baseform='lo', tags=['prn', 'enc', 'p3', 'nt']), ], [ SReading(baseform='decir', tags=['vblex', 'imp', 'p2', 'sg']), SReading(baseform='me', tags=['prn', 'enc', 'p1', 'mf', 'sg']), SReading(baseform='lo', tags=['prn', 'enc', 'p3', 'm', 'sg']), ], ], )