def test_complex_verbs(self): """ e:i verbs have a u:ú stem change """ verb = Verb.importString( 'venir', 'come', ["-e:ie_1sp", 'e:ie', 'e:ie_past_all', 'go', 'e2d', "e_and_o"]) radical_stem = Radical_Stem_Conjugation_Overrides['e:ie'] self.assertTrue(verb.has_override_applied(radical_stem.key)) self.assertFalse( verb.has_override_applied( radical_stem.first_person_conjugation_override.key)) self.assertTrue( verb.has_override_applied( radical_stem.stem_changing_ir_past_all.key)) conjugation = verb.conjugate(Tense.present_tense, Person.first_person_singular, returnAsString=True) self.assertEqual('vengo', conjugation, 'vengo !=' + conjugation) conjugation = verb.conjugate(Tense.present_tense, Person.second_person_singular, returnAsString=True) self.assertEqual('vienes', conjugation, 'vienes !=' + conjugation) conjugation = verb.conjugate(Tense.past_tense, Person.first_person_singular, returnAsString=True) self.assertEqual('vine', conjugation, 'vine !=' + conjugation) conjugation = verb.conjugate(Tense.past_tense, Person.third_person_singular, returnAsString=True) self.assertEqual('vino', conjugation, 'vino !=' + conjugation)
def print_all(): if args.phrases is None: sorted_keys = list(Espanol_Dictionary.verbDictionary.keys()) elif args.use_as_base_verb: sorted_keys = [] for phrase in args.phrases: sorted_keys.extend(Espanol_Dictionary.get_derived(phrase)) else: sorted_keys = list(args.phrases) sorted_keys.sort() for key in sorted_keys: phrase = Espanol_Dictionary.get(key) if phrase is None: print("{} not in dictionary".format(key)) if not args.guess: return else: phrase = Verb.importString( key, force_auto_match=args.force_auto_match) if args.no_conjugation: print("{} : {} ( {} )".format(phrase.full_phrase, phrase.definition, phrase.complete_overrides_string)) elif not phrase.is_phrase: printer = args.printer_clazz( phrase, irregular_nature=args.irregular_nature[0], options=options) printer.print(tenses=args.tenses, persons=args.persons) else: print("'{}' is a phrase. (Not conjugated yet)".format(phrase))
def test_uir_verbs(self): """ uir verbs have to worry about removing the 'u' before o """ verb = Verb.importString('constituir', "constitute") conjugation = verb.conjugate(Tense.present_tense, Person.first_person_singular) self.assertEqual('constituyo', conjugation.conjugation)
def test_stem_changing_gerund_implicit_e2i(self): """ fakegir - e:i is implicitly assigned: gir have stem changing by default """ fakegir = Verb.importString('fakegir', "") # self.assertTrue(fakegir.has_override_applied(u'')) self.assertIsNotNone(fakegir.conjugation_stems, "fakegir.conjugation_stems") gerund = fakegir.conjugate_tense(Tense.gerund) self.assertEqual('fakigiendo', gerund.conjugation, 'e2i gerund wrong=' + str(gerund))
def test_u_u_verbs(self): """ uar verbs have a u:ú stem change """ verb = Verb.importString('continuar', 'continue') conjugation = verb.conjugate(Tense.present_tense, Person.first_person_singular) self.assertEqual('continúo', conjugation.conjugation) conjugation = verb.conjugate(Tense.present_subjective_tense, Person.first_person_singular) self.assertEqual('continúe', conjugation.conjugation)
def test_go_verb_rules(self): """-go verbs: in yo present: ending stem-consonent -> 'g' +'o' (tener) ending stem-vowel -> 'ig' + 'o' (asir) ending stem-'c' -> change 'c'->'g' (hacer,decir) """ fakir = Verb.importString("fakir", "fake go 1", "go") conjugation = fakir.conjugate(Tense.present_tense, Person.first_person_singular) self.assertEqual("fakgo", conjugation.conjugation) fair = Verb.importString("fair", "fake go 1", "go") conjugation = fair.conjugate(Tense.present_tense, Person.first_person_singular) self.assertEqual("faigo", conjugation.conjugation) facer = Verb.importString("facer", "fake go 1", "go") conjugation = facer.conjugate(Tense.present_tense, Person.first_person_singular) self.assertEqual("fago", conjugation.conjugation)
def test_beginning_word_radical_stem_changing_overrides(self): """ """ oler = Verb.importString('oler', "to hear", ["o:ue"]) conjugation = oler.conjugate(Tense.present_tense, Person.first_person_singular, returnAsString=True) self.assertEqual( conjugation, 'huelo', "problems with loading manual overrides " + conjugation) conjugation = oler.conjugate(Tense.present_subjective_tense, Person.first_person_plural) self.assertEqual( 'olamos', conjugation.conjugation, "replacing the beginning vowel back with the infinitive vowel")
def test_stem_changing_gerund_e2i(self): """ faketir - e:i is explicitly assigned ( fake verb to make it easier to debug ) """ faketir = Verb.importString("faketir", "", conjugation_overrides="e:i") # match = Dependent_Standard_Overrides[u"stem_changing_ir_"+u"e:i"].is_match(faketir) # self.assertTrue(match, 'automatch') self.assertIsNotNone(faketir.conjugation_stems, "faketir.conjugation_stems") self.assertTrue(inspect.ismethod(faketir.conjugation_stems[9][0]), "is method") self.assertFalse(inspect.isfunction(faketir.conjugation_stems[9][0]), "is function") gerund = faketir.conjugate_tense(Tense.gerund) self.assertEqual('fakitiendo', gerund.conjugation, 'e2i gerund wrong')
def test_second_person_plural(self): """ """ person = Person.second_person_plural for ending in All_Infinitive_Ending: fake = Verb.importString('faket' + ending.key, "a fake verb") present_subjective_tense = fake.conjugate( Tense.present_subjective_tense, person) conjugation_note = fake.conjugate(Tense.imperative_positive, person) self.assertEqual(conjugation_note.conjugation, fake.inf_verb_string[:-1] + 'd') conjugation_note = fake.conjugate(Tense.imperative_negative, person) self.assertEqual(conjugation_note.conjugation, present_subjective_tense.conjugation)
def test_third_first_person(self): for person in [ Person.third_person_plural, Person.third_person_singular, Person.first_person_plural ]: for ending in All_Infinitive_Ending: fake = Verb.importString('faket' + ending.key, "a fake verb") present_subjective_tense = fake.conjugate( Tense.present_subjective_tense, person) conjugation_note = fake.conjugate(Tense.imperative_positive, person) self.assertEqual(conjugation_note.conjugation, present_subjective_tense.conjugation) conjugation_note = fake.conjugate(Tense.imperative_negative, person) self.assertEqual(conjugation_note.conjugation, present_subjective_tense.conjugation)
def test_second_person_singular(self): """ """ person = Person.second_person_singular for ending in All_Infinitive_Ending: fake = Verb.importString('faket' + ending.key, "a fake verb") present_subjective_tense = fake.conjugate_tense( Tense.present_subjective_tense) present_tense = fake.conjugate_tense(Tense.present_tense) conjugation_note = fake.conjugate(Tense.imperative_positive, person) self.assertEqual( conjugation_note.conjugation, present_tense[Person.third_person_singular].conjugation) conjugation_note = fake.conjugate(Tense.imperative_negative, person) self.assertEqual(conjugation_note.conjugation, present_subjective_tense[person].conjugation)
def test_third_sing_only(self): verb = Verb.importString('helar', 'freeze', conjugation_overrides=["e:ie"]) results = [ 'hiela', 'helaba', 'heló', 'helará', 'helaría', 'hiele', 'helara', 'hiele', 'hiele', 'helando', 'helado', 'helado' ] #'3rd_sing_only', for tense in Tense.all(): for person in [Person.third_person_singular]: expected = results[tense] conjugation = verb.conjugate(tense, person, returnAsString=True) self.assertEqual(expected, conjugation, "tense {}".format(str(tense)))
def test_radical_o2ue__ir_changing(self): """ make sure that the key places of stem changing occur (ir different than er ar verbs) """ verb = Verb.importString('dormir', 'fake', "o:ue") conjugation = verb.conjugate(Tense.present_tense, Person.first_person_singular) self.assertEqual('duermo', str(conjugation)) conjugation = verb.conjugate(Tense.past_tense, Person.third_person_plural) self.assertEqual('durmieron', str(conjugation)) conjugation = verb.conjugate(Tense.present_subjective_tense, Person.first_person_plural) self.assertEqual('durmamos', str(conjugation)) conjugation = verb.conjugate(Tense.present_subjective_tense, Person.third_person_plural) self.assertEqual('duerman', str(conjugation)) conjugation = verb.conjugate(Tense.gerund) self.assertEqual('durmiendo', str(conjugation))
def test_that_explicit_override_takes_precedent(self): """ decir is a go verb which must override the default -cir behavior of changing c-> zc test to see if a manual override defined as a json object will be correctly applied. Make sure for a manual override with None in a override position does not remove a previous override. """ decir = Verb.importString("decir", "to say, tell", [ "go", "e:i", "-v_cir", ConjugationOverride.create_from_json( "" '{"conjugation_stems":{"past":"dij","future":"dir","conditional":"dir"},"conjugations":{"imperative_positive_second":"di"}}' ) ]) conjugations = decir.conjugate_tense(Tense.imperative_positive) self.assertEqual( conjugations[Person.second_person_singular].conjugation, 'di', "problems with loading manual overrides of imperative") self.assertEqual( conjugations[Person.third_person_singular].conjugation, 'diga', "problems with loading manual overrides of imperative")
def test_third_only(self): verb = Verb.importString('suceder', 'happen', conjugation_overrides=['3rd_only']) results = [['sucede', 'suceden'], ['sucedía', 'sucedían'], ['sucedió', 'sucedieron'], ['sucederá', 'sucederán'], ['sucedería', 'sucederían'], ['suceda', 'sucedan'], ['sucediera', 'sucedieran'], ['suceda', 'sucedan'], ['suceda', 'sucedan'], 'sucediendo', 'sucedido', 'sucedido'] for tense in Tense.all(): if tense in Tense.Person_Agnostic(): conjugation_notes = verb.conjugate(tense, returnAsString=True) self.assertEqual(results[tense], conjugation_notes) else: index = 0 for person in Person.third_person(): expected = results[tense][index] conjugation_notes = verb.conjugate(tense, person, returnAsString=True) self.assertEqual(expected, conjugation_notes) index += 1
All_Infinitive_Ending= list(Infinitive_Ending) All_Infinitive_Ending.append('ír') Espanol_Dictionary.load() # # complex tener based derivations # tener = Verb_Dictionary.get('tener') # Note: need to add to dictionary in order to do base_string lookup # TODO : levels of dictionary so we can drop a dictionary faketener = Verb_Dictionary.add('fake-tener', "fake tener", base_verb=tener) faketenerse = Verb_Dictionary.add('fake-tener-se', "fake tener", base_verb=tener) # tests double derivatives # real world example: desacordarse -> acordarse -> acordar descfaketenerse = Verb_Dictionary.add('descfaketenerse', "fake tener", base_verb=faketenerse) faketenerse_1 = Verb.importString('faketenerse', "fake tener", base_verb=faketener) fakeacordar = Verb_Dictionary.add("fakeacordar", "fake acordar", conjugation_overrides="o:ue") #derive just because of reflexive/non-reflexive fakeacordarse = Verb_Dictionary.add("fakeacordarse", "fake acordarse") descfakeacordarse = Verb_Dictionary.add("desc-fakeacordarse", "fake word descfakeacordarse", base_verb=fakeacordarse) class TestDerivedVerb(unittest.TestCase): def test_tener_setup(self): tener_ = faketener.base_verb self.assertEqual("tener", tener.inf_verb_string) self.assertEqual(tener_, tener) self.assertTrue(faketener.is_child(tener_)) self.assertTrue(faketener.is_child(tener)) self.assertTrue(faketenerse.is_child(tener_))
def test_guir_yo(self): distinguir = Verb.importString('distinguir', '') yo_present = distinguir.conjugate(Tense.present_tense, Person.first_person_singular) self.assertEqual('distingo', yo_present.conjugation, 'guir yo present wrong')