class WordTests(unittest.TestCase): """ Tests to check if the enclitics are identified correctly and if the word is correctly identidied as a verb """ def setUp(self): self.los = Word(u'los') self.comer = Word(u'comer') self.dimelo = Word(u'dímelo') self.dimelo_wrong = Word(u'dimelo') self.tomaroslo = Word(u'tomároslo') self.tomaroslo_wrong = Word(u'tómaroslo') self.acentuamelo_wrong = Word(u'acentuamelo') self.darlole = Word(u'darlole') self.renidos = Word(u'reñidos') self.comeos = Word(u'comeos') self.vamonos = Word(u'vámonos') self.vamosnos = Word(u'vámosnos') self.demosela = Word(u'démosela') self.tomarosmela = Word(u'tomárosmela') self.tomarososla = Word(u'tomárososla') def test_bad_value(self): bad_values = [u'dime12', u'dime lo', u''] for value in bad_values: with self.assertRaises(ValueError): Word(value) with self.assertRaises(ValueError): Word(u'las').analyze_word() def test_syls_number(self): self.assertEqual(len(self.los.syllables), 1) self.assertEqual(len(self.tomaroslo.syllables), 4) def test_modify_ros_dos(self): self.assertEqual(self.tomaroslo.syllables[-2], u'os') self.assertEqual(self.renidos.syllables[-1], u'os') self.assertEqual(self.tomarosmela.syllables, [u'to',u'már', u'os', u'me', u'la']) self.assertEqual(self.tomarososla.syllables, [u'to', u'már', u'os', u'os', u'la']) def test_get_enclitics(self): self.assertEqual(self.demosela.get_enclitics(), (u'démo', [u'se', u'la'])) self.assertEqual(self.renidos.get_enclitics(), (u'reñid', [u'os'])) self.assertEqual(self.acentuamelo_wrong.get_enclitics(), (u'acentua', [u'me', u'lo'])) self.assertEqual(self.comer.get_enclitics(), (u'comer', [])) def test_irregular(self): pass
def get_word_info(my_word): print(u'\nTu palabra es: {}.'.format(my_word.upper())) word = Word(my_word) word.analyze_word() if not word.structures: print(u'\tParece que "{}" no es un verbo.'. format(my_word)) else: for num, structure in enumerate(word.structures): if len(word.structures) > 1: print(u'Opción {}.'.format(num+1)) print(structure.message)
class WordTests(unittest.TestCase): """ Tests to check if the enclitics are identified correctly and if the word is correctly identidied as a verb """ def setUp(self): self.comer = Word(u"comer") self.acentuamelo = Word(u"acentuamelo") self.renidos = Word(u"reñidos") self.demosela = Word(u"démosela") def test_bad_value(self): bad_values = [u"dime12", u"dime lo", u""] for value in bad_values: with self.assertRaises(ValueError): Word(value) def test_get_enclitics(self): self.demosela.get_enclitics() self.comer.get_enclitics() self.renidos.get_enclitics() self.acentuamelo.get_enclitics() self.assertEqual(self.demosela.current_base, u"demo") self.assertEqual(self.renidos.current_enclitics, [u"os"]) self.assertEqual(self.acentuamelo.current_base, u"acentua") self.assertEqual(self.comer.current_enclitics, []) def test_irregular(self): pass
def setUp(self): self.los = Word(u'los') self.comer = Word(u'comer') self.dimelo = Word(u'dímelo') self.dimelo_wrong = Word(u'dimelo') self.tomaroslo = Word(u'tomároslo') self.tomaroslo_wrong = Word(u'tómaroslo') self.acentuamelo_wrong = Word(u'acentuamelo') self.darlole = Word(u'darlole') self.renidos = Word(u'reñidos') self.comeos = Word(u'comeos') self.vamonos = Word(u'vámonos') self.vamosnos = Word(u'vámosnos') self.demosela = Word(u'démosela') self.tomarosmela = Word(u'tomárosmela') self.tomarososla = Word(u'tomárososla')
def setUp(self): self.comer = Word(u"comer") self.acentuamelo = Word(u"acentuamelo") self.renidos = Word(u"reñidos") self.demosela = Word(u"démosela")