예제 #1
0
 def test_tener_most_tenses_reflexive(self):
     """
     all except the imperatives
     """
     tener_conjugations = tener.conjugate_all_tenses(returnAsString=True)
     except_tenses = list(Tense.imperative())
     except_tenses.extend(Tense.Person_Agnostic())
     most_tenses = Tense.all_except(except_tenses)
     for tense in most_tenses:
         for person in Person.all():
             tail = faketenerse.conjugate(tense,person, returnAsString=True).split(' ')[1][4:]
             self.assertEqual(tail, tener_conjugations[tense][person], tail+":tense="+str(tense)+" person="+str(person))
             tail = faketenerse_1.conjugate(tense,person, returnAsString=True).split(' ')[1][4:]
             self.assertEqual(tail, tener_conjugations[tense][person], tail+":tense="+str(tense)+" person="+str(person))
             
     tense = Tense.gerund
     tail = faketenerse.conjugate(tense)
     self.assertEqual('faketeniéndose', tail.conjugation, tail.conjugation+":tense="+str(tense))
     tail = faketenerse_1.conjugate(tense)
     self.assertEqual('faketeniéndose', tail.conjugation, tail.conjugation+":tense="+str(tense))
     
     for tense in [Tense.past_participle, Tense.adjective]:
         tail = faketenerse.conjugate_tense(tense, returnAsString=True)[4:]
         self.assertEqual(tail, tener_conjugations[tense], tail+":tense="+str(tense))
         tail = faketenerse_1.conjugate_tense(tense, returnAsString=True)[4:]
         self.assertEqual(tail, tener_conjugations[tense], tail+":tense="+str(tense))
예제 #2
0
 def test_tener_most_tenses_non_reflexive(self):
     """
     all except the imperatives
     """
     conjugations = faketener.conjugate_all_tenses(returnAsString=True)
     tener_conjugations = tener.conjugate_all_tenses(returnAsString=True)
     except_tenses = list(Tense.imperative())
     except_tenses.extend(Tense.Person_Agnostic())
     most_tenses = Tense.all_except(except_tenses)
     for tense in most_tenses:
         for person in Person.all():
             tail = conjugations[tense][person][4:]
             self.assertEqual(tail, tener_conjugations[tense][person], tail+":tense="+str(tense)+" person="+str(person))
             
     for tense in Tense.Person_Agnostic():
         tail = conjugations[tense][4:]
         self.assertEqual(tail, tener_conjugations[tense], tail+":tense="+str(tense))
    def print(self, *, tenses=Tense.all(), persons=Person.all(), options={}):
        result = ''
        irregular_nature = IrregularNature.regular

        def __process(conjugation_notes):
            if conjugation_notes.irregular_nature >= irregular_nature:
                irregular_nature = conjugation_notes.irregular_nature
            if conjugation_notes.conjugation is None:
                result += ','
            else:
                result += ',"' + conjugation_notes.conjugation + '"'

        for tense in Tense.all():
            if tense in Tense.Person_Agnostic():
                conjugation_notes = self.phrase.conjugate(tense)
                if conjugation_notes.irregular_nature > irregular_nature:
                    irregular_nature = conjugation_notes.irregular_nature
                if conjugation_notes.conjugation is None:
                    result += ','
                elif conjugation_notes.irregular_nature == IrregularNature.regular:
                    result += ',"-"'
                else:
                    result += ',"' + conjugation_notes.conjugation + '"'
            else:
                persons = Person.all_except(
                    Person.first_person_singular) if tense in Tense.imperative(
                    ) else Person.all()
                for person in persons:
                    conjugation_notes = self.phrase.conjugate(tense, person)
                    if conjugation_notes.irregular_nature > irregular_nature:
                        irregular_nature = conjugation_notes.irregular_nature
                    if conjugation_notes.conjugation is None:
                        result += ','
                    elif conjugation_notes.irregular_nature == IrregularNature.regular:
                        result += ',"-"'
                    else:
                        result += ',"' + conjugation_notes.conjugation + '"'
        if irregular_nature < self._irregular_nature:
            print('"' + self.phrase.full_phrase + '","' +
                  self.phrase.definition + '","' + irregular_nature.key + '"')
        else:
            print('"' + self.phrase.full_phrase + '","' +
                  self.phrase.definition + '","' + irregular_nature.key + '"' +
                  result)
예제 #4
0
 def test_acordar_multiple_ancestors(self):
     """
     tests the multiple level of derivation case (faketenserse -> faketener -> tener )
     """
     expected_positive = [ None, 'descfakeacuérdate', 'descfakeacuérdese', 'descfakeacordémonos', 'descfakeacordaos',  'descfakeacuérdense']
     expected_negative = [ None, 'te descfakeacuerdes', 'descfakeacuérdese', 'descfakeacordémonos', 'os descfakeacordéis',  'descfakeacuérdense']
     for tense in Tense.imperative():
         expected = expected_negative if tense == Tense.imperative_negative else expected_positive
         for person in Person.all_except([Person.first_person_singular]):
             actual = descfakeacordarse.conjugate(tense, person, returnAsString=True)
             self.assertEqual(expected[person], actual, expected[person]+" != "+actual+":tense="+str(tense)+" person="+str(person))
예제 #5
0
 def test_tener_multiple_ancestors_imperative(self):
     """
     Tests for the case where tener based verbs have 2nd person singular 'ten' as the base ( accents are applied to the 'ten' )
     Also tests the multiple level of derivation case (faketenserse -> faketener -> tener )
     """
     expected_positive = [ None, 'descfaketente', 'descfaketéngase', 'descfaketengámonos', 'descfaketeneos',  'descfaketénganse']
     expected_negative = [ None, 'te descfaketengas', 'descfaketéngase', 'descfaketengámonos', 'os descfaketengáis',  'descfaketénganse']
     for tense in Tense.imperative():
         expected = expected_negative if tense == Tense.imperative_negative else expected_positive
         for person in Person.all_except([Person.first_person_singular]):
             actual = descfaketenerse.conjugate(tense, person, returnAsString=True)
             self.assertEqual(expected[person], actual, expected[person]+" != "+actual+":tense="+str(tense)+" person="+str(person))
예제 #6
0
    def test_tener_imperatives_non_reflexive(self):
        tener_conjugations = tener.conjugate_all_tenses(returnAsString=True)
        for tense in Tense.imperative():
            for person in Person.all_except([Person.first_person_singular, Person.second_person_singular]):
                actual = faketener.conjugate(tense, person, returnAsString=True)
                tail = actual[4:]
                base = tener_conjugations[tense][person]
                self.assertEqual(tail, base, "{0} {1} :tense={2} person={3}".format(actual, base, str(tense), str(person)))
            actual = faketener.conjugate(Tense.imperative_positive, Person.second_person_singular, returnAsString=True)
            tail = actual[4:]
#             print repr(tail).decode("unicode-escape") 
            self.assertEqual("tén", tail)
    def _print_conjugations(self, conjugations):
        if conjugations is not None:
            for tense in range(len(Tense)):
                if conjugations[tense] is None:
                    continue

                print("  " + tense, end=": ")
                if tense in Tense.Person_Agnostic():
                    print(conjugations[tense])
                else:
                    for person in range(len(Person)):
                        if conjugations[tense][person] is not None:
                            if not self.is_reflexive:
                                print(person + " " +
                                      conjugations[tense][person],
                                      end="; ")
                            elif tense not in Tense.imperative():
                                print(conjugations[tense][person], end="; ")
                            else:
                                print(conjugations[tense][person])

                    print()
예제 #8
0
 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
 def __check(self,
             verb_string,
             expected,
             tenses=Tense.all(),
             persons=Person.all()):
     verb = Verb_Dictionary.get(verb_string)
     if verb is None:
         raise Exception(verb_string + ": no verb")
     errors = {}
     for tense in get_iterable(tenses):
         if tense in Tense.Person_Agnostic():
             key = repr(tense)
             expected_conjugation = expected[
                 key] if expected[key] != '' else None
             conjugation = verb.conjugate(tense, returnAsString=True)
             if expected_conjugation != conjugation:
                 errors[key] = {
                     'expected': expected_conjugation,
                     'actual': conjugation
                 }
         else:
             for person in get_iterable(persons):
                 key = repr(tense) + '_' + repr(person)
                 expected_conjugation = expected[
                     key] if expected[key] != '' else None
                 conjugation = verb.conjugate(tense,
                                              person,
                                              returnAsString=True)
                 if expected_conjugation != conjugation:
                     errors[key] = {
                         'expected': expected_conjugation,
                         'actual': conjugation
                     }
     if len(errors) > 0:
         errors['appliedOverrides'] = verb.appliedOverrides
         return errors
     #  self.assertFalse(True, verb.full_phrase+repr(errors))
     else:
         return None
예제 #10
0
    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)))