Exemplo n.º 1
0
 def test_rule(self):
     r = Rule("~er >> ~e, ~es, ~e, ~ons, ~ez, ~ent", "PrInd")
     self.assertEqual(r.input, '~er')
     self.assertEqual(r.output, ['~e', '~es', '~e', '~ons', '~ez', '~ent'])
     self.assertEqual(r.match('parler'), (True, 'parl'))
     self.assertEqual(r.match('er'), (True, ''))
     self.assertEqual(r.match('finir'), (False, ''))
     self.assertEqual(r.transform('parler'), ['parle', 'parles', 'parle', 'parlons', 'parlez', 'parlent'])
     self.assertEqual(r.transform('finir'), [])
     r2 = Rule("~cer >> ~ce, ~ces, ~ce, ~cons, ~cez, ~cent", "PrInd")
     self.assertEqual(r.includes(r2), True)
     self.assertEqual(r2.includes(r), False)
Exemplo n.º 2
0
 def test_compl_word_rule(self):
     r = Rule("aller >> vais, vas, va, allons, allez, vont", "PrInd")
     self.assertEqual(r.input, 'aller')
     self.assertEqual(r.output, ['vais', 'vas', 'va', 'allons', 'allez', 'vont'])
     self.assertEqual(r.match('aller'), (True, 'aller'))
     self.assertEqual(r.match('parler'), (False, ''))
     self.assertEqual(r.transform('aller'), ['vais', 'vas', 'va', 'allons', 'allez', 'vont'])
Exemplo n.º 3
0
 def test_word_parts(self):
     r = Rule("~eu >> ~eux", "Pl")
     self.assertEqual(r.match('lieu'), (True, 'li'))
     self.assertEqual(r.match('heure'), (False, ''))
     self.assertEqual(r.transform('heure'), [])