Ejemplo n.º 1
0
 def __irse_check__(self, tense, expected):
     irse = Verb_Dictionary.get("irse")
     for person, expected in expected.items():
         irse_expected = None if expected is None else person.indirect_pronoun + " " + expected
         self.assertEqual(
             irse_expected,
             irse.conjugate(tense, person, returnAsString=True),
             "Irse : tense {} Person {} ".format(str(tense), str(person)))
Ejemplo n.º 2
0
 def test_ser_tense(self):
     ser = Verb_Dictionary.get("ser")
     self.assertEqual("siendo",
                      ser.conjugate(Tense.gerund, returnAsString=True))
     self.assertEqual("sido",
                      ser.conjugate(Tense.adjective, returnAsString=True))
     self.assertEqual(
         "sido", ser.conjugate(Tense.past_participle, returnAsString=True))
def find_print_verb(verb_inf, print_all=False):
    verb = Verb_Dictionary.get(verb_inf)
    if verb is None:
        print(verb_inf + ": could not find this verb - not loaded yet?")
    else:
        print(repr(verb.inf_verb_string).decode("unicode-escape"))
        if print_all:
            verb.print_all_tenses()
        else:
            verb.print_irregular_tenses()
        print(repr(verb.overrides_applied()).decode("unicode-escape"))
        print('----------------------')
Ejemplo n.º 4
0
 def test_ir_imperative_positive_tense(self):
     tense = Tense.imperative_positive
     self.__check__(tense, TestIr.ir_expected[tense])
     expected = {
         Person.first_person_singular: None,
         Person.second_person_singular: "vete",
         Person.third_person_singular: "váyase",
         Person.first_person_plural: "vámonos",
         Person.second_person_plural: "idos",
         Person.third_person_plural: "váyanse"
     }
     irse = Verb_Dictionary.get("irse")
     for person, expected in expected.items():
         self.assertEqual(
             expected, irse.conjugate(tense, person, returnAsString=True),
             "Irse tense {} Person {} ".format(str(tense), str(person)))
 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
# -*- coding: utf-8 -*-

import conjugate_spanish
from conjugate_spanish.espanol_dictionary import Verb_Dictionary
from conjugate_spanish.conjugation_override import Standard_Overrides
Verb_Dictionary.load()

Verb_Dictionary.export('501verbs')
Verb_Dictionary.export('501verbs',
                       outputfile='regular',
                       testfn=lambda verb: verb.is_regular)
for override in Standard_Overrides.values():
    filename = override.key.replace(':', '2')
    Verb_Dictionary.export(
        '501verbs',
        outputfile=filename,
        testfn=lambda verb: verb.has_override_applied(override.key))


def find_print_verb(verb_inf, print_all=False):
    verb = Verb_Dictionary.get(verb_inf)
    if verb is None:
        print(verb_inf + ": could not find this verb - not loaded yet?")
    else:
        print(repr(verb.inf_verb_string).decode("unicode-escape"))
        if print_all:
            verb.print_all_tenses()
        else:
            verb.print_irregular_tenses()
        print(repr(verb.overrides_applied()).decode("unicode-escape"))
        print('----------------------')
Ejemplo n.º 7
0
 def test_estar_tense(self):
     estar = Verb_Dictionary.get("estar")
     self.assertEqual("estando", estar.conjugate(Tense.gerund, returnAsString=True))
     self.assertEqual("estado", estar.conjugate(Tense.adjective, returnAsString=True))
     self.assertEqual("estado", estar.conjugate(Tense.past_participle, returnAsString=True))
Ejemplo n.º 8
0
 def __check__(self, tense, expected):
     estar = Verb_Dictionary.get("estar")
     for person, expected in expected.items():
         self.assertEqual(expected,estar.conjugate(tense, person, returnAsString=True))
Ejemplo n.º 9
0
import unittest
import os
for l in os.environ['PYTHONPATH'].split(os.pathsep):
    print(":::", l ) 

from conjugate_spanish import Tense, Person, Verb
from conjugate_spanish.espanol_dictionary import Espanol_Dictionary, Verb_Dictionary
from conjugate_spanish import Infinitive_Ending

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)
Ejemplo n.º 10
0
 def __check__(self, tense, expected):
     ser = Verb_Dictionary.get("ser")
     for person, expected in expected.items():
         self.assertEqual(
             expected, ser.conjugate(tense, person, returnAsString=True),
             "person {} tense {}".format(str(person), str(tense)))
Ejemplo n.º 11
0
 def test_past_part_override(self):
     ir = Verb_Dictionary.get('ir')
     for tense in [Tense.past_participle, Tense.adjective]:
         pp = ir.conjugate_tense(tense)
         self.assertEqual('ido', pp.conjugation, 'ir past part. wrong')
Ejemplo n.º 12
0
 def test_gerund_override(self):
     ir = Verb_Dictionary.get('ir')
     gerund = ir.conjugate_tense(Tense.gerund, returnAsString=True)
     self.assertEqual(gerund, 'yendo', 'ir gerund wrong')