def handle(self, *args, **kwargs): portuguese = Language.objects.first() cj = Conjugator(lang=portuguese.short_code) verb_list = cj.get_verbs_list() for verb in verb_list: new_verb = Verb(name=verb, language=portuguese) new_verb.save()
def handle(self, *args, **kwargs): verbs = Verb.objects.all()[:5000] cg = Conjugator(lang="pt") for verb in verbs: verb_name = self.get_verb_conjugations(cg, verb.name) print(verb_name) for mood_name, mood in self.get_verb_moods(verb_name): mood_instance = Mood.objects.get_or_create(name=mood_name) for tense_name, tense in self.get_table(mood): tense_name = Tense.objects.get_or_create( name=tense_name, mood=mood_instance[0], language=Language.objects.get(id=1)) for item in tense: if item == "-": continue new_form = Form(form=item, verb=verb, tense=tense_name[0]) new_form.save()
f = os.listdir() if "dicoFR1.txt" in f : print('Doc ok') else : print('Création du doc') file = open("dicoFR1.txt","w") file.close() choix = input('Quele est ton choix(1:ajout de mot/2:conjugaison) : ') if int(choix) == 1 : mot = input('Mot : ') app(mot) else : file = open("dicoFR1.txt", 'r') c = file.read().split('\n') file.close() cg = Conjugator(lang='fr') d = [] for x in c : d.append(x) for verbe in d : try: result = cg.conjugate(verbe) print(result) ls = [] temps = result['moods']['indicatif'].keys() #print(temps) for t in temps: conjugaison = result['moods']['indicatif'][str(t)] #print(conjugaison) ls = ls + conjugaison print(ls)
# -*- coding: utf-8 -*- import pytest from verbecc import Conjugator cg = Conjugator(lang='it') test_it_conjugate_mood_tense_data = [ ('avere', 'indicativo', 'presente', ['io ho', 'tu hai', 'lui ha', 'noi abbiamo', 'voi avete', 'loro hanno']), ('avere', 'indicativo', 'imperfetto', ['io avevo', 'tu avevi', 'lui aveva', 'noi avevamo', 'voi avevate', 'loro avevano']), ('avere', 'indicativo', 'passato-remoto', ['io ebbi', 'tu avesti', 'lui ebbe', 'noi avemmo', 'voi aveste', 'loro ebbero']), ('avere', 'indicativo', 'futuro', ['io avrò', 'tu avrai', 'lui avrà', 'noi avremo', 'voi avrete', 'loro avranno']) ] @pytest.mark.parametrize("infinitive,mood,tense,expected_result", test_it_conjugate_mood_tense_data) def test_inflector_it_conjugate_mood_tense(infinitive, mood, tense, expected_result): assert cg.conjugate_mood_tense(infinitive, mood, tense) == expected_result def test_inflector_it_conjugate(): assert cg.conjugate('avere') != None def test_inflector_it_add_subjunctive_relative_pronoun(): assert cg._inflector._add_subjunctive_relative_pronoun('io abbia', '') == 'che io abbia' test_inflector_it_get_default_pronoun_data = [
# -*- coding: utf-8 -*- import pytest from verbecc import Conjugator cg = Conjugator(lang='ro') test_ro_conjugate_mood_tense_data = [ ('avea', 'participiu', 'participiu', False, ['avut']), ('face', 'participiu', 'participiu', False, ['făcut']), ('avea', 'indicativ', 'prezent', False, ['eu am', 'tu ai', 'el a', 'noi am', 'voi aţi', 'ei au']), ('avea', 'indicativ', 'prezent', True, ['eu am', 'tu ai', 'el are', 'noi avem', 'voi aveţi', 'ei au']), ('avea', 'indicativ', 'imperfect', False, [ 'eu aveam', 'tu aveai', 'el avea', 'noi aveam', 'voi aveaţi', 'ei aveau' ]), ('avea', 'indicativ', 'perfect-simplu', False, [ 'eu avui', 'tu avuși', 'el avu', 'noi avurăm', 'voi avurăţi', 'ei avură' ]), ('avea', 'indicativ', 'perfect-compus', False, [ 'eu am avut', 'tu ai avut', 'el a avut', 'noi am avut', 'voi aţi avut', 'ei au avut' ]), ('avea', 'indicativ', 'mai-mult-ca-perfect', False, [ 'eu avusem', 'tu avuseși', 'el avuse', 'noi avuserăm', 'voi avuserăţi', 'ei avuseră' ]),
self.width = width self.height = height def __repr__(self): return "Line(w=%s)" % self.width def draw(self): self.canv.line(0, self.height, self.width, self.height) # Dictionary of each group premierGroupe = {} deuxiemeGroupe = {} troisiemeGroupe = {} lg = Conjugator(lang='fr') # Method detects conjugation time def detecterTemps(verbe, verbeRechercher): temps = "" congugation = lg.conjugate(verbe) trouve = False for i in congugation.values(): if type(i) is dict: for j in i.values(): if type(j) is dict: for k in j.items(): if type(k) is tuple: for x in k: if type(x) is list:
def openconjugation() -> None: parser = argparse.ArgumentParser(description="French Conjugation Tool") parser.add_argument( '-w', '--word', help='The French word you want conjugations for', required=True, type=str, ) parser.add_argument( '--indicatif', help="Set if you only want to see the indicatif tenses", action="store_true", ) parser.add_argument( '--conditionnel', help="Set if you only want to see the indicatif tenses", action="store_true", ) parser.add_argument( '--secondary-tense', dest='secondary_tense', help="Set the secondary tense. For indicatif: présent, imparfait, " "futur-simple, passé-simple, passé-composé, plus-que-parfait," " futur-antérieur, passé-antérieur \n For conditionnel: présent, passé", type=str, choices=sum(SECONDARY_TENSES.values(), []), ) parser.add_argument( '-b', '--browser', help="Set to true if you want to open Conjugations in Chrome", action="store_true") args = parser.parse_args() if args.browser: chrome_options = Options() chrome_options.add_experimental_option("detach", True) window = webdriver.Chrome('./chromedriver', options=chrome_options) window.get(FRENCH_CONJUGATION) time.sleep(5) search_box = window.find_element_by_name("q") search_box.send_keys(args.word) search_box.submit() else: cg = Conjugator(lang=FRENCH) conjugation = cg.conjugate(args.word) if args.indicatif: if args.secondary_tense in SECONDARY_TENSES[INDICATIF]: transform(conjugation, tense_secondary=args.secondary_tense) else: transform(conjugation) elif args.conditionnel: if args.secondary_tense in SECONDARY_TENSES[CONDITIONNEL]: transform(conjugation, tense_primary=CONDITIONNEL, tense_secondary=args.secondary_tense) else: transform(conjugation, tense_primary='conditionnel') else: transform(conjugation) transform(conjugation, tense_primary='conditionnel')
# -*- coding: utf-8 -*- import pytest from verbecc import Conjugator cg = Conjugator(lang='pt') test_pt_conjugate_mood_tense_data = [ ('ter', 'indicativo', 'presente', ['eu tenho', 'tu tens', 'ele tem', 'nós temos', 'vós tendes', 'eles têm']), ('ter', 'indicativo', 'pretérito-perfeito', [ 'eu tive', 'tu tiveste', 'ele teve', 'nós tivemos', 'vós tivestes', 'eles tiveram' ]), ('ter', 'indicativo', 'pretérito-imperfeito', [ 'eu tinha', 'tu tinhas', 'ele tinha', 'nós tínhamos', 'vós tínheis', 'eles tinham' ]), ('ter', 'indicativo', 'pretérito-mais-que-perfeito', [ 'eu tivera', 'tu tiveras', 'ele tivera', 'nós tivéramos', 'vós tivéreis', 'eles tiveram' ]), ('ter', 'indicativo', 'pretérito-perfeito-composto', [ 'eu tenho tido', 'tu tens tido', 'ele tem tido', 'nós temos tido', 'vós tendes tido', 'eles têm tido' ]), ('ter', 'indicativo', 'pretérito-mais-que-perfeito-composto', [ 'eu tinha tido', 'tu tinhas tido', 'ele tinha tido', 'nós tínhamos tido', 'vós tínheis tido', 'eles tinham tido'
# -*- coding: utf-8 -*- import pytest from lxml import etree from verbecc import Conjugator from verbecc.tense_template import TenseTemplate cg = Conjugator(lang='es') # presente = Subjunctive Present (yo haya) # pretérito-perfecto = Subjunctive Perfect (yo haya habido) # pretérito-imperfecto-1 = Subjunctive Past 1 (yo hubiera) # pretérito-imperfecto-2 = Subjunctive Past 2 (yo hubiese) # pretérito-pluscuamperfecto-1 = Subjunctive Pluperfect 1 (yo hubiera habido) # pretérito-pluscuamperfecto-2 = Subjunctive Pluperfect 2 (yo hubiese habido) # futuro = Subjunctive Future (yo hubiere) # futuro-perfecto = Subjunctive Future Perfect (yo hubiere habido) test_es_conjugate_mood_tense_data = [ ('abañar', 'indicativo', 'presente', [ 'yo abaño', 'tú abañas', 'él abaña', 'nosotros abañamos', 'vosotros abañáis', 'ellos abañan' ]), ('estar', 'indicativo', 'presente', [ 'yo estoy', 'tú estás', 'él está', 'nosotros estamos', 'vosotros estáis', 'ellos están' ]), ('ser', 'indicativo', 'presente', [ 'yo soy', 'tú eres', 'él es', 'nosotros somos', 'vosotros sois', 'ellos son'
# P5.append(verb) # cell_number = chr(ord(cell_number)+1) # verb = sheet_verbs[cell_letter + cell_number].value # cell_letter = 'G' # P6 = [] # verb = sheet_verbs[cell_letter + cell_number].value # while type(verb) != type(None): # P6.append(verb) # cell_number = chr(ord(cell_number)+1) # verb = sheet_verbs[cell_letter + cell_number].value cell_letter = args.init_cell[0] cell_number = args.init_cell[1:] sheet = workbook['LINGÜÍSTICAS'] cg = Conjugator(lang='es') verb = sheet[cell_letter + cell_number].value infinitive = sheet[chr(ord(cell_letter) + 1) + cell_number].value empty_cell = sheet[chr(ord(cell_letter) + 2) + cell_number].value while verb and not empty_cell: if infinitive: try: conjugation = cg.conjugate(str(infinitive)) conj = conjugation['moods'] conj = remove_suj(conj) modes_match, verb_times_match, pers_match = get_verb_time( conj, verb) infinitive = conj['infinitivo']['infinitivo'][0]