Last active
April 3, 2025 14:50
-
-
Save tommycarstensen/d6ca630431d1472bb2588fe159fa0777 to your computer and use it in GitHub Desktop.
Conjugación de verbos en español
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Copyright (C) 2019, Tommy Carstensen | |
# https://brittanygervin.com/projects/stem-changing-spanish-verbs-flowchart/ | |
# https://2.bp.blogspot.com/-Y8Y7cyZEpzs/WuLmoDZhvYI/AAAAAAAAPDs/GAAtM_6zA5EwG9aPkh0e06uUQ3vDXVSXQCLcBGAs/s1600/gram%25C3%25A1tica-mind-map.png | |
# https://www.spanishdict.com/guide/spanish-present-tense-forms | |
# https://www.spanishdict.com/guide/spanish-irregular-present-tense/ | |
# https://www.spanishdict.com/guide/stem-changing-verbs/ | |
# https://www.spanishdict.com/guide/spelling-changes-in-the-present-tense | |
import json | |
from collections import Counter | |
import re | |
import random | |
# Irregular “yo” form with no stem change | |
# conocer – “to know” – yo conozco, tú conoces | |
# dar – “to give” – yo doy, tú das | |
# hacer – “to do, make” – yo hago, tú haces | |
# poner – “to put” – yo pongo, tú pones | |
# salir – “to exit” – yo salgo, tú sales | |
# traer – “to bring” – yo traigo, tú traes | |
# ver – “to see” – yo veo, tú ves | |
# oír – “to hear” – yo oigo, tú oyes | |
# saber – “to know” – yo sé, tú sabes | |
# ir – “to go” – yo voy, tú vas | |
# estar – “to be” – yo estoy, tú estás | |
# caber – “to fit” – yo quepo, tú cabes | |
# lucir – “to wear” – yo luzco, tú luces | |
# valer – “to be worth” – yo valgo, tú vales | |
# Irregular “yo” form with a stem change | |
# decir – “to say” – yo digo, tú dices | |
# tener – “to have” – yo tengo, tú tienes | |
# venir – “to come” – yo vengo, tú vienes | |
##import pyphen | |
##dic = pyphen.Pyphen(lang='es') | |
# wrong for sobreestimar | |
##print(dic.inserted('sobreestimar')) | |
# pres1s | |
# raer rao,raigo,rayo | |
# mecer mezo - estremecer estremezco | |
# pres2s | |
# ofender ofendes - defender defiendes | |
# adecentar ad/e/cen/tar adecentas - acrecentar ac/cre/cen/tar acrecientas | |
# anhelar an/he/lar anhelas - helar he/lar hielas | |
# alcanforar al/can/fo/rar alcanforas - aforar a/fo/rar afueras/aforas - agorar a/go/rar agoras | |
# aposentar a/po/sen/tar aposentas - asentar a/sen/tar asientas | |
# asonar a/so/nar asuenas - apisonar a/pi/so/nar apisonas | |
# atentar a/ten/tar atentas - | |
# acollar a/co/llar acolas - apercollar apercollas - descollar des/co/llar descuelas | |
# descolar descolas - encolar encolas - escolar escuelas - trascolar trascuelas | |
# atronar atruenas - destronar destronas | |
# empavesar empaviesas - atravesar atraviesas | |
# aporcar aporcas - emporcar empuercas | |
# decorar decoras - encorar encueras | |
# alforzar alforzas - esforzar esfuerzas | |
# impostar impostas - apostar apuestas | |
# censar censas - incensar inciensas | |
# inmolar inmolas - amolar amuelas | |
# insolar insolas - consolar consuelas | |
# interpretar interpretas - apretar aprietas | |
# inventar inventas - aventar avientas | |
# aprehender aprehendes - hender hiendes | |
# bregar bregas - regar riegas | |
# rogar ruegas - derogar derogas | |
# adecentar adecentas - acrecentar acrecientas | |
# descompensar descompensas - pensar piensas | |
# pres2s tilde | |
# vaciar vacías - viciar vicias | |
# ahumar ahúmas - inhumar inhumas | |
# airar aíras - desairar desairas | |
# cohibir cohíbes - inhibir inhibes | |
# participio | |
# entre/a/brir entreabierto, des/a/brir desabrido | |
# pret3s | |
# contrahacer contrahízo deshacer deshizo | |
# hacer, deshacer, satisfacer, rehacer, etc | |
# poner, componer, descomponer, reponer, etc | |
# decir, maldecir, bendecir, etc | |
# verbos terciopersonales: | |
# llover, tronar, granizar, relampaguear, diluviar, nevar | |
# Aspecto: Perfecto/Perfectivo (Preterite), Imperfecto/Imperfectivo (Imperfecto) | |
# Modo: Indicativo o Subjuntivo o Imperativo | |
# Tiempo: presente, pasado y futuro | |
# Persona: 1a, singular (se llama numero?) | |
# https://en.wiktionary.org/wiki/Category:Spanish_prefixes | |
prefijos = [ | |
'mal', 'ben', 'des', 'pre', | |
#'con', # not conocer | |
'ex', 'inter', 're', | |
# 'sobre', # not so/bren/ten/der? pero sobre-estimar | |
'sub', 'contra', 'uni', 'equi', | |
'ante', 'entre', 'hiper', 'hipo', | |
# 'pos', # not poseer | |
'super', | |
'in', | |
'trans', | |
'ad', # Contiene prefijo ad- que proviene del latín y significa "proximidad", "hacia" o "añadido". Ejemplos: adyacente, adjunto. | |
'en', | |
] | |
tilde = {'a': 'á', 'e': 'é', 'i': 'í', 'o': 'ó', 'u': 'ú',} | |
endings_uir4 = ( | |
'buir', 'cuir', 'tuir', 'huir', 'güir', 'luir', | |
'nuir', # disminuir | |
) | |
endings_uir5 = endings_pres2s_ui_to_uy = endings_pret3s_ui_to_yo = [ | |
'fluir', 'truir', 'cluir', 'rruir', | |
# 'creer', | |
] | |
endings_CeCXir = [ | |
'servir', | |
'rendir', | |
'seguir', | |
'vestir', | |
] | |
endings_CeCir = ( | |
'cebir', | |
'decir', | |
'pedir', 'medir', | |
'regir', 'legir', | |
'gemir', | |
'ferir', 'gerir', 'herir', 'jerir', | |
'petir', | |
) | |
def main(): | |
with open('esp_verbos.json') as f: | |
l = json.loads(f.read()) | |
# import sys | |
# if len(sys.argv) > 1: | |
# l = [{ | |
# 'verbo': sys.argv[-1], | |
# 'indicativo': {'presente': {'tú': 'xxx'}}, | |
# 'perfecto': {'presente': {'yo': 'xxx'}}, | |
# }] | |
# print(l) | |
endings = [] | |
##for d in random.sample(l, len(l)): | |
w2 = [] | |
w3 = [] | |
w4 = [] | |
w5 = [] | |
w6 = [] | |
# Crear ordenable lista de verbos. Create sortable list of verbs. | |
verbos = [] | |
reflexivos = set() | |
for d in l: | |
verbo = d['verbo'] | |
if d['indicativo']['presente']['yo'].startswith('me '): | |
reflexivos.add(verbo) | |
if verbo in ( | |
# pres2s missing - just a dash | |
'tutear', | |
): | |
continue | |
sílabas = find_syllables(verbo) | |
try: | |
sil2 = sílabas[-2] | |
except IndexError: | |
sil2 = '' | |
conj = { | |
'imp2p': d['imperativo']['afirmativo']['vosotros'].split()[-1], | |
'gerundio': d['progresivo']['presente']['yo'].split()[-1], | |
'participio': d['perfecto']['presente']['yo'].split()[-1].split(','), | |
'pres1s': d['indicativo']['presente']['yo'].split()[-1].split(','), | |
'pres2s': d['indicativo']['presente']['tú'].split()[-1].split(','), | |
'pres3s': d['indicativo']['presente']['él/ella/Ud.'].split()[-1].split(','), | |
'pres1p': d['indicativo']['presente']['nosotros'].split()[-1].split(','), | |
'pres2p': d['indicativo']['presente']['vosotros'].split()[-1].split(','), | |
'pres3p': d['indicativo']['presente']['ellos/ellas/Uds.'].split()[-1].split(','), | |
'pret3s': d['indicativo']['preterito']['él/ella/Ud.'].split()[-1].split(','), | |
'imp2s': d['imperativo']['afirmativo']['tú'].split()[-1].split(','), | |
'subj1s': d['subjuntivo']['presente']['yo'].split()[-1].split(','), | |
'subj3s': d['subjuntivo']['presente']['yo'].split()[-1].split(','), | |
} | |
verbos.append(( | |
verbo[::-1], | |
verbo[-2:], # ar or er/ir | |
verbo[-3:], # iar, uar or ??? | |
# len(sílabas[[-2]), | |
sílabas[-1][:-2], | |
verbo, | |
conj | |
)) | |
for k, v in conj.items(): | |
if ',' in v: | |
print(k, v) | |
stop | |
v = list(sorted(verbos)) | |
verbos = v | |
# for i_verbo, d in enumerate(reversed(l)): | |
for i_verbo, t in enumerate(sorted(verbos)): | |
print() | |
# palabra = verbo = word = verb = d['verbo'] | |
verbo = t[4] | |
d = t[5] | |
# participio = d['perfecto']['presente']['yo'].split()[-1] | |
participio = d['participio'] | |
# pres2s = d['indicativo']['presente']['tú'].split()[-1] | |
pres1s = d['pres1s'] | |
pres2s = d['pres2s'] | |
pret3s = d['pret3s'] | |
## print(d['indicativo']['presente']) | |
# pres2s = pres2s.replace('í', 'i') # tmp!!! | |
# pres2s = pres2s.replace('ú', 'u') # tmp!!! | |
# participio = participio.replace('ído', 'ido') # tmp!!! | |
if ',' in pres2s: continue | |
if ',' in pret3s: continue | |
if ',' in participio: continue | |
if verbo in ( | |
'fungus', 'lee', 'poteen', 'UNIDO', 'VI', 'quejarse', | |
'collar', 'familiar', 'caviar', 'alongar', # no es un verbo... | |
'tutear', 'solar', # pres2s missing - just a dash | |
'asolar', # Asolar suele conjugarse usando el modelo de contar, con el cambio de la o por ue en algunas tiempos, pero también se acepta el uso de la conjugación regular, sin dicho cambio. | |
'repudrir', # incorrectly pres2s repodres in json and not repudres | |
'colar', # colas/cuelas https://dle.rae.es/?id=9jtl8nd https://dle.rae.es/?id=9jtl8nd | |
# memorize | |
# 'haber', 'hacer', 'ser', 'estar', 'poder', 'poner', 'ir', 'decir', 'querer', 'volver', | |
'holgar', 'hollar', # incorrectly conjugated in the json file | |
# 'placer', # pret3s plació,plugo | |
# 'responder', # pret3s respondió,repuso | |
# 'sobrentender', # sobre-entender | |
'minar', # participio minarán in JSON file | |
# 'dar', # super irregular | |
'manir', # manir participio manirán not manido | |
'preterir', # pres2s not preteres | |
'raer', # pres1s raigo,rayo | |
# 'yacer', # pres1s yazco,yago,yazgo | |
'roer', 'corroer', # pres1s roo o roigo o royo | |
): | |
continue | |
## syllables = dic.inserted(verbo) | |
## print(syllables) | |
sílabas = find_syllables(verbo) | |
# syllabyle_last = syllables.split('/')[-1] | |
sílaba_ultima = sílabas[-1] | |
for i in range(len(verbo)-1): | |
w2.append(verbo[i:i+2]) | |
for i in range(len(verbo)-2): | |
w3.append(verbo[i:i+3]) | |
for i in range(len(verbo)-3): | |
w4.append(verbo[i:i+4]) | |
for i in range(len(verbo)-4): | |
w5.append(verbo[i:i+5]) | |
for i in range(len(verbo)-5): | |
w6.append(verbo[i:i+6]) | |
print( | |
i_verbo, len(verbos), | |
'\n'+verbo, sílabas, | |
'\npres', | |
d['pres1s'], d['pres2s'], d['pres3s'], | |
d['pres1p'], d['pres2p'], d['pres3p'], | |
'\npret', pret3s, | |
'\npart', participio, | |
) | |
# Para determinar primera letra. | |
sílabas_sin_prefijos = sílabas | |
while sílabas_sin_prefijos[0] in prefijos: | |
sílabas_sin_prefijos = sílabas_sin_prefijos[1:] | |
if verbo[-2:] == 'ar': | |
ar(verbo, d, sílabas, sílabas_sin_prefijos) | |
# | |
# er/ir | |
# | |
else: | |
erir(verbo, d, sílabas, sílabas_sin_prefijos) | |
with open('pass.txt', 'a') as f: | |
print(verbo, file=f) | |
## print(d['indicativo']['presente']) | |
## print(d['indicativo']['preterito']) | |
## print(d['indicativo']['imperfecto']) | |
## print(d['indicativo']['futuro']) | |
## print(d['indicativo']['condicional']) | |
## print(d['imperativo']) | |
## print(d['progresivo']) | |
## print(d['subjuntivo']) | |
## print(d['perfecto_subjuntivo']) | |
## print(verb) | |
## print(m) | |
## print(m.group(0)) | |
# m = re.search("[aeiou][^aeiou]*[ar|er|ir]$", verb) | |
# ending = m.group(0) | |
# try: | |
# ending = dic.inserted(word).split('-')[-2][-1] + dic.inserted(word).split('-')[-1] | |
# except IndexError: | |
# ending = dic.inserted(word).split('-')[-1] | |
## print(ending, verb) | |
## stop | |
## ass.append(verbo[-3:]) | |
endings.append(sílaba_ultima) | |
## print(verbo[-3:], verbo) | |
print(Counter(w2).most_common(100)) | |
print(Counter(w3).most_common(100)) | |
print(Counter(w4).most_common(100)) | |
print(Counter(w5).most_common(100)) | |
print(Counter(w6).most_common(100)) | |
for t in Counter(endings).most_common(): | |
print(t[1], t[0], sep=' ') | |
return | |
def ar(verbo, d, sílabas, sílabas_sin_prefijos): | |
# participio ar | |
assert verbo[:-2] + 'ado' in d['participio'] | |
pres_ar(d, verbo, sílabas, sílabas_sin_prefijos) | |
pret_ar(d, verbo, sílabas) | |
return | |
def erir(verbo, d, sílabas, sílabas_sin_prefijos): | |
participio_erir(d, verbo, sílabas) | |
pres_erir(d, verbo, sílabas, sílabas_sin_prefijos) | |
pret_erir(d, verbo, sílabas) | |
return | |
def participio_erir(d, verbo, sílabas): | |
# participio er/ir | |
Irreg = [ | |
# eir/ito | |
['freir', 'frito',], | |
] | |
if verbo == 'escribir': | |
print(verbo, d['participio'], participio) | |
stoptmp | |
if False: | |
pass | |
elif verbo.endswith('ver') and verbo[:-3] in [''] + prefijos: # ver | |
participio = verbo[:-2] + 'isto' | |
# elif verbo == 'leer': | |
# assert participio == verbo[:-2] + 'ído', participio | |
elif verbo != 'desabrir' and verbo.endswith('brir'): # abrir, cubrir, escribir | |
# entre/a/brir, des/a/brir | |
participio = verbo[:-4] + 'bierto' | |
elif verbo[-5:] in ('morir',): # morir | |
participio = verbo[:-4] + 'uerto' | |
elif verbo.endswith('poner'): # poner, yuxtaponer | |
participio = verbo[:-4] + 'uesto' | |
## elif verbo[-3:] == 'ver': # volver | |
## assert participio == verbo[0] +'uelto', participio | |
elif verbo[-6:] in ('solver', 'volver'): # disolver, volver, resolver | |
participio = verbo[:-5] + 'uelto' | |
elif verbo.endswith('decir'): # decir | |
participio = verbo[:-4] + 'icho' | |
elif verbo[-5:] in ('facer', 'hacer'): # hacer, satisfacer | |
participio = verbo[:-4] + 'echo' | |
elif verbo.endswith('freir'): # freor | |
participio = verbo[:-3] + 'ito' | |
elif verbo != 'corromper' and verbo.endswith('romper'): # romper | |
participio = verbo[:-5] + 'oto' | |
elif verbo.endswith('pudrir'): # pudrir | |
participio = verbo[:-5] + 'odrido' | |
else: | |
if sílabas[-1] in ('er', 'ír') and verbo[-3] in 'aeo': | |
participio = verbo[:-2] + 'ído' | |
assert verbo in ( | |
'caer', 'decaer', 'recaer', | |
'raer', 'traer', 'atraer', 'detraer', | |
'retraer', 'maltraer', 'contraer', 'retrotraer', | |
'distraer', 'sustraer', | |
'leer', 'releer', 'creer', | |
'sobreseer', 'poseer', 'desposeer', 'proveer', 'desproveer', | |
'roer', 'corroer', | |
'reír', 'sonreír', | |
) or verbo.endswith('traer') or verbo.endswith('creer'), verbo | |
# assert len(sílabas_sin_prefijos) <= 2 | |
else: | |
participio = verbo[:-2] + 'ido' | |
assert not verbo.endswith('aer') | |
assert not verbo.endswith('eer') | |
assert not verbo.endswith('oer') | |
assert participio in d['participio'], ('participio', d['participio']) | |
assert participio in d['participio'], ('participio', participio, d['participio']) | |
return | |
def pres_ar(d, verbo, sílabas, sílabas_sin_prefijos): | |
ie = 'ie' | |
ue = 'ue' | |
if False: | |
pass | |
# tmp removal... | |
# elif verbo[:3] == 'vol' and verbo[-3:] not in ('ear', 'zar'): # volcar, volar | |
# pres2s = verbo[:1] +'uel'+ verbo[3:-2] +'as' | |
# ## elif verbo[-4:] == 'ezar': (not acezar) | |
# ## assert d['pres2s'] == verbo[:-4] +'iezas', pres2s | |
# assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# dar > doy | |
elif verbo == 'dar': | |
pres1s = 'doy' | |
pres2s = 'das' | |
assert pres1s in d['pres1s'], (d['pres1s'], pres1s) | |
# estar > estoy; a > á (ar) | |
elif sílabas[-2:] == ['es', 'tar']: | |
pres1s = verbo[:-2] + 'oy' | |
pres2s = verbo[:-2] + 'ás' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# ar, pres2s, o > ue | |
# elif verbo[-4:] == 'ovar' and sílabas[-2:] != ['o', 'var']: # renovar | |
# assert d['pres2s'] == verbo[:-4] +'ue'+ verbo[-3] +'as', pres2s | |
# print('o>ue 9', verbo) | |
elif verbo in ('rogar', 'renovar',) or ''.join(sílabas[-2:]) in ( | |
'gorar', | |
'rodar', | |
'novar', # renovar, not innovar | |
'forar', | |
# 'rogar', | |
) and verbo not in ( | |
'derogar', 'innovar', | |
'alcanforar', 'perforar', | |
): # destrocar (not debocar), a/fo/rar, not alcanforar | |
if verbo.endswith('gorar'): | |
ue = 'üe' | |
raiz = verbo[:-4] + ue + verbo[-3] | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'as' | |
print('o>ue 2', verbo) | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# elif sílabas[-2:] in (['xxlo', 'car'],) and verbo not in ('alocar', 'colocar', 'descolocar'): | |
# conj = verbo[:-4] + 'ue' + verbo[-3] + 'as' | |
# assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
elif verbo in ( | |
'escolar', 'trascolar', | |
'amolar', | |
) or verbo == 'encorar' or verbo[-5:] in ( | |
'sonar', # asonar (not apisonar) | |
'volar', | |
# 'colar', # escolar, trascolar, not descolar | |
# 'molar', # amolar, not molar | |
'solar', | |
# 'corar', | |
) and verbo not in ( | |
'apisonar', 'artesonar', 'blasonar', | |
'inmolar', | |
'insolar', 'acrisolar', 'tornasolar', | |
'descolar', 'encolar', 'estercolar', 'socolar', | |
): # tronar (not embolar), trasvolar, trascolar not socolar | |
raiz = verbo[:-4] + 'ue' + verbo[-3] | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'as' | |
print('o>ue 3', verbo) | |
afijo = 'o_to_ue' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# ar, pres2s, o > ue (CCoCar and CoCCar) | |
elif verbo == 'esforzar' or verbo == 'descollar' or verbo[-6:] in ( | |
'porcar', | |
'volcar', | |
'cordar', | |
'goldar', | |
'soldar', | |
# 'longar', # not prolongar | |
'colgar', | |
# 'drogar', | |
'poblar', | |
# 'collar', # descollar, not escollar | |
'sollar', | |
'cornar', | |
'contar', | |
'costar', | |
'nostar', | |
'postar', | |
'tostar', | |
'soltar', | |
# 'forzar', # not alforzar | |
'forzar', | |
'gonzar', | |
'morzar', | |
'probar', | |
'clocar', | |
'trocar', | |
'tronar', | |
) and verbo not in ( | |
'acollar', 'apercollar', 'destronar', 'aporcar' ,'encornar', 'alforzar', 'impostar',): # contar, encordar (not asordar) | |
if verbo[-6:-4] == 'go': | |
ue = 'üe' | |
if verbo[-5] == 'o': | |
pres2s = verbo[:-5] + ue + verbo[-4:-2] + 'as' | |
pres1s = verbo[:-5] + ue + verbo[-4:-2] + 'o' | |
else: | |
pres2s = verbo[:-4] + ue + verbo[-3:-2] + 'as' | |
pres1s = verbo[:-4] + ue + verbo[-3:-2] + 'o' | |
ue = 'ue' | |
print('o>ue 8', verbo) | |
assert pres1s in d['pres1s'], (d['pres1s'], pres1s) | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
elif verbo[-7:] in ( | |
'mostrar', 'contrar',): # demostrar, encontrar | |
raiz = verbo[:-6] +'ue'+ verbo[-5:-2] | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'as' | |
print('o>ue 5', verbo) | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
elif verbo[-8:] in ('desollar', 'degollar'): # demostrar | |
if verbo[-6] == 'g': | |
ue = 'üe' | |
raiz = verbo[:-5] + ue + verbo[-4:-2] | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'as' | |
ue = 'ue' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# elif verbo[-7:] == 'degollar': # degollar (not acogollar) | |
# assert d['pres2s'] == verbo[:-5] +'üe'+ verbo[-4:-2] +'as', pres2s | |
# print('o>ue 6', verbo) | |
# pres, u > ue (jugar) | |
elif verbo == 'jugar': | |
pres1s = 'juego' | |
pres2s = 'juegas' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# ar, pres2s, e > ie | |
elif verbo == 'regar' or verbo[-5:] in ( | |
'helar', | |
'fesar', # confesar, not profesar | |
'vesar', | |
'pezar', | |
'negar', # denegar, but anegas en DLE, aniegas en WR | |
'segar', | |
'cegar', | |
'nevar', | |
# 'regar', | |
) and verbo not in ( | |
'anhelar', 'empavesar', 'bregar', 'anegar', 'profesar', | |
): | |
raiz = verbo[:-4] + ie + verbo[-3] | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'as' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# elif verbo[-5:] in ('eblar',): # temblar tmp!!! | |
# conj = verbo[:-5] + ie + verbo[-4:-2] + 'as' | |
# assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# ar, pres2s, e > ie (CeCCar/CeCCar) | |
elif verbo in ( | |
'escarmentar', | |
'apretar', | |
'desapretar', | |
'aventar', 'reventar', | |
'acrecentar', 'apacentar', | |
'desalentar', | |
'mentar', 'salpimentar', 'cimentar', | |
'pensar', 'repensar', | |
'sentar', 'asentar', | |
'tentar', | |
'dentar', 'endentar', | |
'incensar', | |
) or ''.join(sílabas[-2:]) in ( | |
# 'yerbar', | |
'herbar', | |
'beldar', | |
'mendar', | |
'rendar', | |
'plegar', | |
'fregar', | |
'tregar', # restregar | |
'holgar', | |
'hollar', | |
'neblar', | |
'hollar', | |
'bernar', | |
# 'censar', not censar | |
'pensar', # not compensar | |
'cerrar', | |
'herrar', | |
'pedrar', | |
'serrar', | |
'terrar', | |
'centar', # acrecentar, not adecentar | |
'certar', # 'acertar', 'concertar', 'desacertar', | |
'dentar', | |
'festar', # manifestar, not infestar | |
# 'mentar', # escarmentar (not alimentar/alimentum/alimento, not argumentar) | |
'hestar', | |
'pertar', # despertar | |
# 'lentar', | |
# 'pretar', | |
# 'sentar', | |
# 'tentar', | |
'testar', # atestas/atiestas, not contestar, atestar, not testar | |
# 'ventar', | |
'menzar', | |
#) and ( | |
# len(sílabas_sin_prefijos) == 2 or verbo[-7] in 'aeiou' | |
) and verbo not in ( | |
'aposentar', | |
'atentar', 'contentar', | |
'alimentar', 'bastimentar', | |
'fundamentar', 'ornamentar', 'sacramentar', 'juramentar', | |
'lamentar', 'reglamentar', 'parlamentar', | |
'argumentar', 'aumentar', | |
'atormentar', | |
# 'censar', | |
'testar', 'detestar', 'contestar', 'protestar', 'infestar', 'desinfestar', | |
'interpretar', | |
'descompensar', 'dispensar', 'expensar', 'recompensar', 'compensar', | |
'adecentar', | |
'inventar', 'reinventar', 'solventar', | |
): # herrar (not aferrar) | |
# tentar | |
if verbo[-5] == 'e': | |
raiz = verbo[:-5] + ie + verbo[-4:-2] | |
pres2s = raiz + 'as' | |
pres1s = raiz + 'o' | |
# pretar | |
else: | |
raiz = verbo[:-4] + ie + verbo[-3:-2] | |
pres2s = raiz + 'as' | |
pres1s = raiz + 'o' | |
assert pres1s in d['pres1s'], (d['pres1s'], pres1s) | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
elif verbo[-7:] in ( | |
'temblar', 'sembrar', 'membrar', 'grentar', 'quebrar', | |
'rrendar', | |
): # temblar, sembrar (not zozobras) | |
if verbo[-6] == 'e': | |
raiz = verbo[:-6] + ie + verbo[-5:-2] | |
else: | |
raiz = verbo[:-5] + ie + verbo[-4:-2] | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'as' | |
assert pres1s in d['pres1s'], (d['pres1s'], pres1s) | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
elif verbo[-6:] in ('lentar') and verbo[-7] in 'a': # alentar, sobrecalentar (not violentar) | |
raiz = verbo[:-5] + ie + verbo[-4:-2] | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'as' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
else: # hablar, acantonar, ventear | |
# if len(sílabas) > 1: | |
# if 'a' in sílabas[-2]: | |
# afijo = 'a' | |
# elif 'e' in sílabas[-2]: | |
# afijo = 'e' | |
# elif 'i' in sílabas[-2]: | |
# afijo = 'i' | |
# elif 'o' in sílabas[-2]: | |
# afijo = 'o' | |
# elif 'u' in sílabas[-2]: | |
# afijo = 'u' | |
# else: | |
# print(sílabas[-2]) | |
# stop | |
# else: | |
# afijo = 'x' | |
if False: | |
pass | |
# elif sílabas[-1] == 'ciar' and len(sílabas) <= 2 and verbo not in ('saciar', 'viciar',): | |
# conj = verbo[:-3] + tilde.get(verbo[-3], verbo[-3]) + 'as' | |
# afijo = 'tilde' | |
# assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# ar, pres, i > í / u > ú / iar > íar / uar > úar | |
# tilde | |
elif verbo in ( # irregulars / palabras graves | |
# 'espiar', 'expiar', | |
# 'aliar', 'desliar', | |
# 'aviar', 'desviar', 'enviar', 'reenviar', | |
'cariar', 'contrariar', 'inventariar', 'variar', 'desvariar', 'averiar', | |
# 'hastiar', | |
# 'ansiar', | |
# 'confiar', | |
'vaciar', 'ciar', 'rociar', | |
'piar', 'pipiar', 'espiar', 'expiar', | |
# 'criar', | |
# 'ampliar', | |
) or (verbo not in ( # regulars / sin tilde | |
# Pregunta Daniel por qué no hay tilde en pres2s... | |
# https://www.spanishdict.com/guide/spanish-word-stress/ | |
'espaciar', 'agraciar', 'congraciar', 'desgraciar', 'saciar', | |
'apreciar', 'depreciar', 'especiar', 'justipreciar', 'despreciar', | |
'iniciar', 'reiniciar', 'oficiar', | |
'menospreciar', 'arreciar', 'codiciar', 'desperdiciar', 'beneficiar', | |
'conciliar', 'domiciliar', 'reconciliar', 'defoliar', 'exfoliar', 'foliar', | |
'exiliar', 'expoliar', 'tertuliar', | |
'chipiar', 'principiar', 'limpiar', 'tapiar', 'ripiar', 'columpiar', | |
'acopiar', 'copiar', 'fotocopiar', 'multicopiar', 'xerocopiar', | |
'escariar', 'excoriar', 'feriar', 'injuriar', 'asalariar', 'seriar', | |
'pifiar', 'atrofiar', | |
'obviar', 'agraviar', 'desagraviar', 'aliviar', 'soliviar', 'noviar', 'diluviar', | |
'angustiar', 'sitiar', | |
'soliloquiar', 'obsequiar', | |
'anestesiar', | |
# 'feriar', | |
) and sílabas[-1] in ( | |
'cuar', | |
'duar', # graduar | |
'luar', # valuar | |
'nuar', # atenuar | |
'ruar', | |
'suar', | |
'tuar', | |
# 'ciar', # ciar, vaciar, not espaciar, not agraciar, not desgraciar, not saciar | |
'fiar', # desafiar, confiar, not pifiar, not atrofiar | |
'liar', # aliar, desliar, paliar, not exiliar, not familiar | |
# 'miar', # | |
# 'piar', # espiar, expiar, pipiar | |
# 'riar', # cariar, inventariar, not injuriar, not asalariar | |
'siar', | |
'tiar', # hastiar, amnistiar | |
'viar', # aviar | |
'criar', | |
'friar', | |
'griar', | |
'pliar', 'rriar', | |
'triar', | |
'truar', | |
'guiar', | |
'quiar', # esquiar, not soliloquiar | |
)# and any(( | |
# 'tiar' in verbo, 'fiar' in verbo, 'aliar' in verbo, | |
# 'riar' in verbo, 'squia' in verbo, | |
# )) | |
): | |
raiz = verbo[:-3] + tilde.get(verbo[-3], verbo[-3]) | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'as' | |
afijo = 'tilde' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# elif len(sílabas) == 2 and sílabas[-1] in ( | |
# 'riar', | |
# ): | |
# conj = verbo[:-3] + tilde.get(verbo[-3], verbo[-3]) + 'as' | |
# afijo = 'tilde' | |
elif ''.join(sílabas[-2:]) in ( | |
'baular', 'feinar', | |
): | |
raiz = ''.join(sílabas[:-2]) + ''.join(sílabas[-2:])[:-4] + tilde.get(verbo[-4], verbo[-4]) + verbo[-3:-2] | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'as' | |
afijo = 'tilde' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# # pres2s i > í (ar) | |
# elif len(sílabas) == 1 and 'i' in verbo[:-2]: | |
# conj = verbo[:-3] + tilde[verbo[-3]] + 'as' | |
# assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# pres2s i > í (ar) | |
elif sílabas[0][-1] in 'aeo' and ''.join(sílabas[-2:]) in ( | |
'hijar', # ahijar, prohijar | |
'hilar', # ahilar, rehilar | |
'hinar', # amohinar | |
'hitar', # ahitar | |
'humar', # ahumar, not inhumar, not trashumar, not exhumar | |
'husar', # rehusar | |
'hincar', # ahincar (silent h?) | |
'huchar', # ahuchar (silent h?) | |
): | |
raiz = ''.join(sílabas[:-2]) + sílabas[-2][0] + tilde.get(sílabas[-2][1]) + sílabas[-2][2:] + sílabas[-1][:-2] | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'as' | |
afijo = 'tilde' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
elif all(( | |
verbo not in ('desairar',), | |
''.join(sílabas[-2:]) in ( | |
'traillar', 'aullar', 'maullar', | |
'aunar', | |
'aislar', | |
'mau', | |
'nar', 'rar', | |
# 'lar', # aislar, not bailar, not hular | |
'aupar', | |
'airar', # airar, not desairar | |
'raizar', # enraizar | |
'peizar', | |
), | |
)): | |
print(''.join(sílabas[:-1])[:-1]) | |
print(tilde.get(''.join(sílabas[:-1])[-1])) | |
print(sílabas[-1][:-2]) | |
if sílabas[-2] in ('ais',): | |
raiz = ''.join(sílabas[:-1])[:-2] + tilde.get(''.join(sílabas[:-1])[-2]) + ''.join(sílabas[:-1])[-1] + sílabas[-1][:-2] | |
else: | |
raiz = ''.join(sílabas[:-1])[:-1] + tilde.get(''.join(sílabas[:-1])[-1]) + sílabas[-1][:-2] | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'as' | |
afijo = 'tilde' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
else: | |
raiz = verbo[:-2] | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'as' | |
pres3s = raiz + 'a' | |
pres1p = raiz + 'amos' | |
pres2p = raiz + 'áis' | |
pres3p = raiz + 'an' | |
vocalicos = ('ai', 'au', 'ei', 'eu',) | |
if any(( | |
verbo[-3:] in ('iar', 'uar',), | |
any(vocalico in ''.join(sílabas[-2:]) for vocalico in vocalicos), | |
)): | |
afijo = 'regular1' | |
afijo = 'regular2' | |
assert pres1s in d['pres1s'], (d['pres1s'], 'pres1s not regular!') | |
assert pres2s in d['pres2s'], (d['pres2s'], 'pres2s not regular!') | |
assert pres3s in d['pres3s'], (pres3s, d['pres3s'], 'pres3s not regular!') | |
assert pres1p in d['pres1p'], (d['pres1p'], 'pres1p not regular!') | |
assert pres2p in d['pres2p'], (d['pres2p'], 'pres2p not regular!') | |
assert pres3p in d['pres3p'], (d['pres3p'], 'pres3p not regular!') | |
with open('pres2s.ar.{}.txt'.format(afijo), 'a') as f: | |
print(verbo, ''.join(sílabas[-2:]), sep='\t', file=f) | |
## continue # tmp!!! | |
# pres1s = raiz + 'o' | |
# pres2s = raiz + 'as' | |
assert pres1s in d['pres1s'], (d['pres1s'], pres1s) | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
return | |
def pret_ar(d, verbo, sílabas): | |
# pret3s ar | |
if False: | |
pass | |
elif verbo == 'dar': | |
pret3s = 'dio' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
elif len(verbo) <= 4 and verbo[-3] in ('i',): | |
# dar, ciar, fiar | |
pret3s = verbo[:-2] + 'o' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# elif verbo in ('andar', 'desandar'): | |
# conj = verbo[:-3] + verbo[-3] + 'uvo' | |
# assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# elif sílabas[-2:] == ['an', 'dar']: | |
# conj = ''.join(sílabas[:-1]) + sílabas[-1][:-2] + 'uvo' | |
# assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# with open('irregular.pret3s.dar.txt', 'a') as f: | |
# print(verbo, file=f) | |
elif sílabas[-2:] in (['es', 'tar'], ['an', 'dar'],): | |
raiz = verbo[:-3] + verbo[-3] | |
pret3s = raiz + 'uvo' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
else: | |
pret3s = verbo[:-2] +'ó' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s, 'pret3s not regular!') | |
## continue # tmp!!! | |
assert not verbo.endswith('uir') | |
with open('regular.pret3s.ar.txt', 'a') as f: | |
print(verbo, file=f) | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
return | |
def pret_erir(d, verbo, sílabas): | |
if False: | |
pass | |
elif verbo in ('ser', 'ir'): | |
pret3s = 'fue' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
elif verbo == 'ver': | |
pret3s = 'vio' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
elif verbo.endswith('tener'): | |
pret3s = verbo[:-4] + 'uvo' # como andar/anduvo | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# irregular | |
elif verbo.endswith('aber'): | |
if verbo[-5] == 'h': | |
assert verbo == 'haber' | |
pret3s = verbo[:-4] + 'ubo' | |
else: | |
pret3s = verbo[:-4] + 'upo' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# elif verbo.endswith('bucir'): | |
# conj = verbo[:-4] + 'ijo' | |
# assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# i > j, -c | |
elif verbo[-5:] in ('ducir',): | |
pret3s = verbo[:-3] + 'jo' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# irregular | |
elif verbo[-5:] == 'poner': | |
pret3s = verbo[:-4] + 'uso' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# e > i | |
elif verbo.endswith('querer'): # querer, malquerer | |
pret3s = verbo[:-6] + 'quiso' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# pret3s e > i, i > j, -c | |
elif verbo[-5:] in ('decir',): | |
pret3s = verbo[:-5] + 'dijo' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# pret3s e > i | |
elif verbo[-6:] in ('querir', 'rretir',): # requerir | |
pret3s = verbo[:-4] + i + verbo[-3:-2] + 'ió' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# pret3s e > i | |
elif verbo[-6:] in ('hervir',): # hervir | |
pret3s = verbo[:-5] + i + verbo[-4:-2] + 'ió' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# elif verbo[-6:] == 'querir': # requerir | |
# conj = verbo[:-4] + ie + verbo[-3] + 'es' | |
# assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# e > i, -i | |
elif verbo.endswith('venir'): # venir, avenir | |
pret3s = verbo[:-5] + 'vino' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# pret3s o > u (er/ir) | |
elif verbo == 'dormir': | |
pret3s = 'durm' + 'ió' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
elif verbo == 'morir': | |
pret3s = 'mur' + 'ió' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
elif verbo == 'poder': | |
pret3s = 'pudo' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# i > j | |
elif verbo[-5:] in ('traer',): | |
pret3s = verbo[:-2] + 'jo' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# -e | |
elif verbo[-4:] == 'reír': | |
pret3s = verbo[:-3] + 'ió' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# -i | |
elif verbo[-6:] in [ | |
'bullir', 'fallir', 'gullir', 'mullir', 'tullir', | |
'bruñir', 'gruñir', | |
]: | |
pret3s = verbo[:-2] + 'ó' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# ui > y (er/ir) | |
elif verbo[-4:] in endings_uir4: | |
pret3s = verbo[:-2].replace('ü', 'u') + 'yó' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
elif verbo[-4:] in ( | |
'caer', 'raer', | |
'leer', 'seer', 'veer', | |
'roer', | |
): | |
pret3s = verbo[:-2] + 'yó' | |
afijo = 'aer_eer_oer' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
elif verbo[-5:] in endings_uir5 + ['creer']: | |
pret3s = verbo[:-2] + 'yó' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# acer > izo (er/ir) | |
elif verbo[-5:] in ('haber', 'hacer', 'facer'): | |
# silent h... | |
if len(verbo) == 5: | |
pret3s = verbo[:-4] + 'izo' | |
elif verbo[-6] in 'ae' and verbo[-5] == 'h': | |
pret3s = verbo[:-4] + 'ízo' | |
else: | |
pret3s = verbo[:-4] + 'izo' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
# pret3s e > i (er/ir) | |
elif verbo[-5:] in endings_CeCir: | |
pret3s = verbo[:-4] + 'i' + verbo[-3:-2] + 'ió' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
elif verbo[-6:] in ('mentir', 'sentir', 'vertir', 'bestir',): | |
pret3s = verbo[:-5] + 'i' + verbo[-4:-2] + 'ió' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
elif verbo[-6:] in endings_CeCXir: | |
pret3s = verbo[:-5] + 'i' + verbo[-4:-2] + 'ió' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
elif verbo.endswith('henchir'): | |
pret3s = verbo[:-6] + 'i' + verbo[-5:-2] + 'ió' | |
assert pret3s in d['pret3s'], (d['pret3s'], pret3s) | |
else: | |
assert verbo[-4:] != 'llir' | |
assert verbo[-3:] != 'uir' | |
assert verbo[-3:] not in ('aer', 'eer', 'oer') | |
pret3s = verbo[:-2] + 'ió' | |
assert pret3s in d['pret3s'], (pret3s, 'pret3s not regular!') | |
## continue # tmp!!! | |
with open('regular.pret3s.er_ir.txt', 'a') as f: | |
print(verbo, file=f) | |
return | |
def pres_erir(d, verbo, sílabas, sílabas_sin_prefijos): | |
ue = 'ue' | |
ie = 'ie' | |
raiz = verbo[:-2] | |
if False: | |
pass | |
# irregular | |
elif verbo == 'ser': | |
pres1s = 'soy' | |
pres2s = 'eres' # not ses | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
afijo = 'irregular' | |
elif ''.join(sílabas_sin_prefijos) == 'ver': | |
pres1s = ''.join(sílabas[:-1]) + 'veo' # not vo or ve | |
if verbo == 'ver': | |
pres2s = ''.join(sílabas[:-1]) + 'ves' # regular | |
else: # rever | |
pres2s = ''.join(sílabas[:-1]) + 'vés' # regular | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
afijo = 'irregular' | |
elif verbo == 'ir': | |
pres1s = 'voy' # not not vo | |
pres2s = 'vas' # not ves | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
afijo = 'irregular' | |
# irregular ber | |
elif verbo == 'haber': | |
pres1s = 'he' | |
pres2s = 'has' # not habes | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
afijo = 'irregular' | |
elif verbo == 'caber': | |
pres1s = 'quepo' | |
pres2s = raiz + 'es' # regular! | |
afijo = 'irregular1sregular2s' | |
elif verbo == 'saber': | |
pres1s = 'sé' | |
pres2s = raiz + 'es' # regular! | |
afijo = 'irregular1sregular2s' | |
elif verbo[-5:] in ('beber', 'deber', 'ceder'): | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'es' # regular! | |
afijo = 'irregular1sregular2s' | |
elif verbo[-6:] in ('lamber', 'sorber',): | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'es' # regular! | |
afijo = 'irregular1sregular2s' | |
elif verbo[-4:] == 'caer': | |
pres1s = raiz + 'igo' | |
pres2s = raiz + 'es' # regular! | |
afijo = 'irregular1s' | |
elif verbo[-5:] == 'traer': | |
pres1s = raiz + 'igo' | |
pres2s = raiz + 'es' # regular! | |
afijo = 'irregular1sregular2s' | |
# https://www.spanishdict.com/guide/spelling-changes-in-the-present-tense | |
elif ''.join(sílabas[-2:]) in ( | |
'valer', | |
'tener', | |
'poner', | |
# 'asir', | |
# 'salir', | |
# 'oír', | |
): | |
sufijo = 'go' | |
pres1s = verbo[:-2] + sufijo | |
if verbo.endswith('tener'): | |
pres2s = verbo[:-4] + ie + verbo[-3] + 'es' | |
else: | |
pres2s = verbo[:-2] + 'es' | |
afijo = 'pres1sGO' | |
# https://www.spanishdict.com/guide/spelling-changes-in-the-present-tense | |
elif verbo[-3:] in ('cer', 'cir'): | |
if verbo[-5:] in ( | |
'hacer', 'facer', 'yacer', | |
): | |
sufijo = 'go' | |
elif verbo[-4] in 'aeiou' and ''.join(sílabas_sin_prefijos) != 'mecer': | |
sufijo = 'zco' # conocer | |
else: | |
sufijo = 'zo' | |
# er, pres1s, o > ue | |
if ''.join(sílabas[-2:]) in ( | |
'cocer', # cocer, recocer | |
'torcer', | |
# 'nocer', # conocer | |
): | |
index = verbo.rindex('o') | |
prefijo = verbo[:index] + ue + verbo[index + 1:-3] | |
# prefijo2s = verbo[:index] + ue + verbo[index + 1:-3] | |
sufijo = 'zo' | |
afijo = 'pres1scercir_OtoUE2s' | |
else: | |
prefijo = verbo[:-3] | |
assert raiz == prefijo + verbo[-3] | |
assert 'o' not in sílabas[-2] or verbo in ('conocer', 'reconocer', 'desconocer') | |
afijo = 'irregular1sregular2s' | |
pres1s = prefijo + sufijo | |
pres2s = prefijo + 'ces' | |
# elif verbo[-6:] in ('placer', 'checer',): | |
# pres1s = verbo[:-3] + 'zco' | |
# pres2s = raiz + 'es' # regular! | |
# afijo = 'irregular1sregular2s' | |
# elif ''.join(sílabas_sin_prefijos) in ( | |
# 'mecer', 'vencer', 'ejercer', | |
# ): # mecer, remecer, not estremecer | |
# pres1s = verbo[:-3] + 'zo' | |
# pres2s = raiz + 'es' # regular! | |
# afijo = 'irregular1sregular2s' | |
elif verbo[-3:] in ('ger', 'gir',): | |
raiz = verbo[:-3] | |
pres1s = raiz + 'jo' | |
pres2s = raiz + 'ges' | |
afijo = 'pres1sgergir' | |
# er/ir, pres2s, o > ue | |
# elif verbo[-6:] in ('volver', 'solver',): # volver, not resolver | |
# pres2s = verbo[:-5] + 'uelves' | |
# assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
elif ''.join(sílabas[-2:]) in ( | |
'cocer', | |
'poder', | |
'doler', 'moler', 'soler', 'oler', | |
'mover', | |
'morir', | |
'morder', | |
'dormir', | |
'volver', | |
'solver', | |
): | |
index = verbo[:-2].rindex('o') | |
raiz = verbo[:index] + ue + verbo[index + 1:-2] | |
if verbo == 'oler': | |
prefijo = 'h' | |
else: | |
prefijo = '' | |
pres1s = prefijo + raiz + 'o' | |
pres2s = prefijo + raiz + 'es' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
afijo = 'pres1sOtoUEpres2sOtoUE' | |
# ui > uy (er/ir) | |
elif verbo[-4:] in endings_uir4: # atribuir (not delinquir) | |
if verbo[-4] == 'h' and len(verbo) > 4: # rehuir | |
assert verbo == 'rehuir' | |
pres2s = verbo[:-2].replace('u', 'ú') + 'yes' | |
else: | |
pres2s = verbo[:-2].replace('ü', 'u') + 'yes' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
elif verbo[-5:] in endings_uir5: | |
# atribuir (not delinquir) | |
pres2s = verbo[:-2] + 'yes' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# assert d['pres2s'] == verbo[:-2].replace('ü', 'u') + 'yes', pres2s | |
# er/ir, pres2s, e > ie | |
elif verbo[-4:] == 'reír': # reír, sonreír | |
pres1s = verbo[:-4] + 'rió' | |
pres2s = verbo[:-4] + 'ríes' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# er/ir, pres2s, e > ie | |
elif verbo[-3:] in ( | |
'rir', 'nir', 'tir', | |
'der', 'eer', 'jer', 'ler', 'mer', 'ner', 'per', 'rer', 'ser', 'ter', 'ver', | |
): | |
# ) or ''.join(sílabas[-2:]) in ( | |
# 'leer', 'creer', 'seer', 'veer', | |
# 'herir', 'ferir', 'gerir', 'jerir', | |
# 'venir', | |
# 'heder', | |
# 'poder', | |
# 'tejer', | |
# 'tener', | |
# # raiz = verbo[:-4] + ie + verbo[-3:-2] | |
# # pres1s = raiz + 'o' # heder | |
# # pres2s = raiz + 'es' | |
# # assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# 'cender', | |
# 'conder', # esconder escondo escondes | |
# 'fender', # defender defiendo defiendes, ofender ofendo ofendes | |
# 'hender', | |
# 'pender', | |
# 'ponder', # corresponder correspondo correspondes | |
# 'perder', | |
# 'tender', # contender | |
# 'vender', # vender vendo vendes | |
# 'cerner', | |
# 'verter', | |
# 'hendir', | |
# 'cernir', | |
# 'mentir', | |
# 'sentir', | |
# 'vertir', | |
# 'hervir', | |
# 'prender', # desprender | |
# 'rromper', | |
# ): | |
# # pres2s = verbo[:-5] + ie + verbo[-4:-2] + 'es' | |
# # assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# no e > ie stem change | |
if verbo in ( | |
'creer', | |
'arder', | |
'ofender', # not defender | |
'aprehender', | |
'pretender', | |
'vender', | |
'esconder', | |
'joder', | |
'temer', | |
'barrer', | |
'toser', | |
'competer', | |
'precaver', | |
) or ''.join(sílabas[-2:]) in ( | |
'pender', 'prender', | |
'vender', # vender, revender | |
'leer', # leer, releer | |
'creer', # creer, decreer | |
'seer', # poseer, sobreseer, desposeer | |
'veer', # proveer, desproveer | |
'tejer', # tejer, entretejer | |
'peler', # repeler, impeler | |
'lamer', # lamer, relamer | |
'comer', # comer, carcomer | |
'ponder', # corresponder, responder | |
'rromper', # corromper | |
'romper', # romper | |
'correr', # correr, acorrer | |
'coser', # coser, recoser | |
'meter', # meter, remeter | |
): | |
# 'prender', 'aprender', 'desaprender', 'reprender', 'emprender', 'reemprender', 'comprender', 'sorprender', | |
# ): | |
raiz = verbo[:-2] | |
afijo = 'pres1sOending' | |
# e > ie stem change | |
else: | |
assert sílabas[-2] in ( | |
'he', # heder | |
'cen', # encender | |
'fen', | |
'hen', | |
'ten', # tender | |
'per', # perder | |
'cer', # cerner | |
'que', # querer | |
'ver', # verter | |
) and sílabas[-1] in ( | |
'der', | |
'ner', | |
'rer', # querer | |
'ter', # verter | |
) | |
if verbo.endswith('prender'): | |
stop5 | |
index = verbo[:-2].rindex('e') | |
raiz = verbo[:index] + ie + verbo[index + 1:-2] | |
afijo = 'EtoIE' | |
pres1s = raiz + 'o' | |
pres2s = raiz + 'es' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
assert pres1s in d['pres1s'], (d['pres1s'], pres1s) | |
elif verbo[-6:] in ('querir', 'querer',): # requerir | |
raiz = verbo[:-4] + ie + verbo[-3:-2] | |
pres2s = raiz + 'es' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# elif verbo[-4:] in ('erer'): # querer, zaherir | |
# conj = verbo[:-4] + ie + verbo[-3:-2] + 'es' | |
# assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# elif verbo[-5:] in ('entir', 'ertir',): # mentir, pervertir | |
# assert d['pres2s'] == verbo[:-5] + ie + verbo[-4:-2] + 'es', pres2s | |
# elif verbo[-4:] in ('enir', 'ener'): # venir, tener | |
# assert d['pres2s'] == verbo[:-4] + ie + verbo[-3] + 'es', pres2s | |
# elif verbo[-4:] == 'rter': # verter (not cometer) | |
# assert d['pres2s'] == verbo[0] + 'iertes', pres2s | |
# pres2s e > é | |
elif verbo.endswith('rever'): | |
pres2s = verbo[:-2] + 'es'.replace('e', 'é') | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# pres2s u > ú | |
elif verbo != 'unir' and verbo.endswith('unir') and verbo[-5] == 'e': # reunir, not desunir | |
pres2s = verbo[:-4] + 'únes' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# pres2s e > i (er/ir) | |
elif verbo[-6:] in endings_CeCXir + ['bestir']: | |
pres2s = verbo[:-5] + i + verbo[-4:-2] + 'es' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
elif verbo[-6:] in ( | |
'rretir', | |
): # derretir | |
pres2s = verbo[:-4] + i + verbo[-3:-2] + 'es' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
elif verbo[-7:] in ('henchir',): | |
try: | |
if verbo[-8] == 'e': | |
vocal = 'e' | |
else: | |
vocal = None | |
except IndexError: | |
vocal = None | |
if vocal == 'e': | |
pres2s = verbo[:-6] + 'í' + verbo[-5:-2] + 'es' | |
else: | |
pres2s = verbo[:-6] + 'i' + verbo[-5:-2] + 'es' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# pres2s e > i (er/ir) CeCir | |
elif verbo[-5:] in endings_CeCir: # impedir (not trasgredir) | |
assert d['pres2s'] == verbo[:-4] + 'i' + verbo[-3] + 'es', pres2s | |
# elif verbo[-5:] in ('eguir', 'ervir',): # proseguir | |
# assert d['pres2s'] == verbo[:-5] +'i'+ verbo[-4:-2] +'es', pres2s | |
## elif verbo[-4:] in ('reír',): # sonreír | |
## assert d['pres2s'] == verbo[:-3] + ie + 'es', pres2s | |
# i > ie (adquirir, inquirir, re-adquirir) | |
elif verbo[-4:] == 'irir': # adquirir | |
pres2s = verbo[:-4] + ie + verbo[-3] + 'es' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# pres2s i > í (er/ir) | |
elif verbo[-5:] == 'hibir' and verbo[-6] == 'o': | |
pres2s = verbo[:-5] + 'híbes' | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
# elif verbo[-4:] in ('oler', 'over', 'oder', 'orir'): # moler (not valer), poder (not interceder), mover | |
# assert d['pres2s'] == verbo[:-4] + ue + verbo[-3] + 'es', pres2s | |
else: # comer | |
assert verbo[-3:] != 'uir' | |
assert verbo[-3:] != 'aer' # caer, traer | |
assert verbo[-3:] != 'ber' # caber | |
assert verbo[-3:] != 'cer' # hacer, satisfacer | |
pres1s = raiz + 'e' | |
pres2s = raiz + 'es' | |
pres3s = raiz + 'o' | |
pres1p = raiz + 'emos' | |
pres2p = raiz + 'eis' | |
pres3p = raiz + 'en' | |
assert pres1s in d['pres1s'], (d['pres1s'], 'pres1s not regular!') | |
assert pres2s in d['pres2s'], (d['pres2s'], 'pres2s not regular!') | |
assert pres3s in d['pres3s'], (d['pres3s'], 'pres3s not regular!') | |
assert pres1p in d['pres1p'], (d['pres1p'], 'pres1p not regular!') | |
assert pres2p in d['pres2p'], (d['pres2p'], 'pres2p not regular!') | |
assert pres3p in d['pres3p'], (d['pres3p'], 'pres3p not regular!') | |
## continue # tmp!!! | |
with open('regular.pres2s.er_ir.txt', 'a') as f: | |
print(verbo, file=f) | |
afijo = 'regular' | |
# pres1s = raiz + 'e' | |
assert pres1s in d['pres1s'], (d['pres1s'], pres1s) | |
assert pres2s in d['pres2s'], (d['pres2s'], pres2s) | |
with open('pres.er_ir.{afijo}.txt'.format(afijo=afijo), 'a') as f: | |
print(verbo, file=f) | |
return | |
def Any(verb): | |
S = 0 | |
A = 0 | |
pos = [ | |
'tener','estar','venir','haber','hacer', | |
'salir','caber','valer','querer','poner','traer','decir', | |
'poder','saber','abrir','cubrir','escribir','freir', | |
'morir','resolver','romper','volver', | |
] | |
while pos[S] not in verb and S<len(pos)-1: | |
S += 1 | |
B = len(pos[S]) | |
while verb[A:B] != pos[S] and B<len(verb) and pos[S] in verb: | |
A += 1 | |
B += 1 | |
if verb[A:B] in pos: | |
stem = verb[0:A] | |
return stem | |
return False | |
def find_syllables_test(): | |
for palabra in ( | |
'amigo', 'mañana', 'enero', 'dinero', | |
'leo', 'caer', 'lee', | |
'cinco', | |
'calle', 'muchacho', 'cigarro', | |
'hablar', 'atlas', 'isla', 'perla', 'atlantico', 'encontrar', | |
'juicio', 'puerta', 'hueso', 'silabación', 'increíble', | |
'día', 'leído', 'flúido', | |
'instante', 'constante', | |
'expresar', 'conseguir', 'desorden', # prefixes | |
'sobreestimar', # prefixes | |
'Uruguay', 'Paraguay', # https://en.wikipedia.org/wiki/Triphthong | |
#'guayaba', # triphtong sin acento | |
#'cambiáis', 'cambiéis', 'situáis', 'guiáis', 'enviáis', 'estudiéis', | |
'redargüir', | |
'comandar', | |
): | |
sílabas = '/'.join(find_syllables(palabra)) | |
print(palabra, sílabas) | |
assert sílabas in ( | |
'a/mi/go', 'ma/ña/na', 'e/ne/ro', 'di/ne/ro', | |
'le/o', 'ca/er', 'le/e', | |
'cin/co', | |
'ca/lle', 'mu/cha/cho', 'ci/ga/rro', | |
'ha/blar', 'at/las', 'is/la', 'per/la', 'at/lan/ti/co', 'en/con/trar', | |
'jui/cio', 'puer/ta', 'hue/so', 'si/la/ba/ción', 'in/cre/í/ble', | |
'dí/a le/í/do', 'flú/i/do', | |
'cons/tan/te', 'ins/tan/te', | |
'ex/pre/sar', 'con/se/guir', 'des/or/den', | |
'dí/a', 'le/í/do', 'flú/i/do', | |
'cons/tan/te', 'ins/tan/te', | |
'ex/pre/sar', 'con/se/guir', 'des/or/den', # prefixes | |
'sobre/es/ti/mar', 'so/bre/es/ti/mar', # prefixes | |
'U/ru/guay', 'Pa/ra/guay', 'gu/aya/ba', 'cam/biáis', 'cam/biéis', 'si/tuáis', 'gu/iáis', 'en/viáis', 'es/tu/diéis', | |
're/dar/güir', | |
'co/man/dar', | |
), (palabra, sílabas) | |
return | |
def find_syllables(word): | |
## https://www.spanishdict.com/guide/spanish-syllables-and-syllabification-rules | |
## 1) Consonant Plus Vowel | |
## Whenever possible, you should break up words so that each syllable contains a consonant followed by a vowel. A consonant between two vowels belongs to the syllable with the second vowel. | |
## 2) Two Consecutive Consonants | |
## Two consecutive consonants will generally belong to separate syllables. However, if the second consonant in a consonant pair is r or l, the consonant pair is not separated into different syllables. | |
## Words that begin with prefixes often violate the above rules. For example the syllabification of enloquecer is en-lo-que-cer. | |
## 3) Three Consecutive Consonants | |
## When three consonants appear together, the first one will generally belong to a separate syllable. | |
## 4) Strong and Weak Vowels | |
##Spanish has both strong vowels (a, e, o) and weak vowels (i, u). Here are some rules on how the combinations of these vowels are divided into syllables. | |
##Two weak vowels together form a diphthong and are not separated into different syllables. Example: | |
##fui | |
##A weak vowel and a strong vowel together form a diphthong and are not separated into different syllables. Example: | |
##Juan | |
##Two strong vowels together form a hiatus and are separated into different syllables. Example: | |
##Le-o | |
## A tilde placed over a letter changes the above pronunciation rules, and the accented letter must be separated from any surrounding vowels. Example: mí-o | |
## https://quizlet.com/12460213/chapter-1-part-4-dividing-syllables-rules-in-spanish-pgs-16-18-flash-cards/ | |
## 1) When dividing words into syllables the fundamental rule is to make each syllable end in a vowel and join a consonant occurring between vowels to the following vowel. a/mi/go ma/ña/na e/ne/ro di/ne/ro | |
## 2) Separate two strong vowels. le/o ca/er le/e | |
## 3) Usually, separate two consonants between vowels. cin/co | |
## 4) Consider ch, ll, and rr to be one letter and never separate them. ca/lle mu/cha/cho ci/ga/rro | |
## 5) Do not separate a consonant followed by the letter R or L, except r/l, s/l, t/l, n/r, s/r. ha/blar (not sep) at/las (sep) is/la per/la at/lan/ti/co | |
## 6) Do not separate the vowels of the diphthong or triphthong if accent marks are not used over the vowels. jui/cio puer/ta hue/so si/la/ba/ción (not sep) in/cre/í/ble (sep) | |
## 7) Divide syllables between vowels when an accent mark is placed over the weak vowel of the diphthong or triphthong or over the first of two weak vowels. dí/a le/í/do flú/i/do | |
## 8) If more than two consonants occur between vowels, join the final consonant to the next vowel. cons/tan/te ins/tan/te | |
## 9) A prefix is a separate syllable. ex/pre/sar con/se/guir des/or/den | |
##traslocar | |
##tras/lo/car | |
## si/la/ba/ción (weak strong, rising io diphtong in radio, why not separated?, dipthong over strong!) | |
## in/cre/í/ble (strong weak, accent mark and thus separated, dipthong over weak!) - in is a prefix? | |
## why is con not a prefix in cons/tan/te and in not in ins/tan/te? but con in con/se/guir and ex in ex/pre/sar and in in in/cre/í/ble? http://etimologias.dechile.net/?constante | |
## silabación | |
## increíble | |
## instante | |
## conseguir | |
## constante | |
## tripthong guayaba | |
s = '' | |
vowel = None | |
vowels = '' | |
consonants = '' | |
print(word) | |
m = re.match('^' + '|^'.join(prefijos) + '', word) | |
if m and word != 'enero': | |
end = m.end() | |
# cons-tan-te and ads-cri-bir? but not con-se-guir | |
if word[end] == 's' and word[end + 1] not in 'aeiouü': | |
breaks = [end + 1] | |
start = end + 1 | |
else: | |
breaks = [end] | |
start = end | |
else: | |
breaks = [] | |
start = 0 | |
for i, x in enumerate(word): | |
## Adjust for existence of prefix. | |
if i < start: | |
continue | |
##for x in 'increíble': | |
if x in 'aeiouáéíóúAEIOUü': | |
if not vowel is None: | |
## Consecutive Vowels | |
if i - vowel == 1: | |
if len(vowels) > 2: | |
print(vowels) | |
stoptmp | |
## print(i, x, vowels) | |
# 6b) Do not separate the vowels of the diphthong or *triphthong* if accent marks are not used over the vowels. | |
# if word[vowel : vowel+3] in ( | |
# 'uai', | |
# ): | |
# vowel = i | |
# vowels += x | |
# stop1 | |
# continue | |
if False: | |
pass | |
# 6b) Do not separate the vowels of the diphthong or *triphthong* if accent marks are not used over the vowels. | |
elif vowels + x in ( | |
'uai', | |
): | |
vowel = i | |
vowels += x | |
print('c', breaks) | |
## 1) Separate two strong vowels. | |
elif vowels + x in ( | |
'aa', 'ae', 'ao', | |
'ea', 'ee', 'eo', | |
'oa', 'oe', 'oo', | |
): | |
breaks.append(vowel + 1) | |
print('a', breaks) | |
# 6a) Do not separate the vowels of the *diphthong* or triphthong if accent marks are not used over the vowels. | |
elif vowels + x in ( | |
# falling (diptongo decreciente) | |
'ai', 'ei', 'oy', 'uy', | |
'au', # pausa | |
'eu', 'ou', 'ay', | |
# rising (diptongo creciente) | |
'ia', 'ie', 'io', 'iu', 'ua', 'ue', | |
'ui', # fuimos | |
'üi', # redagüir? | |
'uo', | |
): | |
vowel = i | |
vowels += x | |
print('b', breaks) | |
continue | |
## 7) Divide syllables between vowels when an accent mark is placed over the weak vowel of the diphthong or triphthong or over the first of two weak vowels. | |
elif vowels + x in ( | |
'aí', 'eí', 'úi', 'aú', 'eú', 'oú', | |
'ía', 'íe', 'ío', 'íu', 'úa', 'úe', 'úi', 'úo', | |
): | |
breaks.append(vowel + 1) | |
else: | |
vowel = i | |
vowels += x | |
continue | |
## Two strong vowels together form a hiatus and are separated into different syllables. | |
## breaks.append(vowel + 1) | |
## Consonant Plus Vowel (rule 1) | |
elif i - vowel == 2: | |
breaks.append(vowel + 1) | |
print('d', breaks) | |
elif i - vowel in (3, 4, 5): | |
## Two Consecutive Consonants | |
if i - vowel == 3: | |
b = 1 | |
## Three Consecutive Consonants. | |
elif i - vowel == 4: | |
b = 2 | |
## Four Consecutive Consonants. | |
elif i - vowel == 5: | |
b = 3 | |
else: | |
print(i - vowel, word, i, x, breaks, start) | |
stop22 | |
## print(consonants) | |
## Consider ch, ll, and rr to be one letter and never separate them. | |
if consonants[-2:] in ('ch', 'll', 'rr'): | |
breaks.append(vowel + b) | |
## Do not separate a consonant followed by the letter R or L, except r/l, s/l, t/l, n/r, s/r. | |
# Do not seperate ha/blar | |
elif consonants[-2:][-1] in ('r', 'l'): | |
## except r/l, s/l, t/l, n/r, s/r. | |
if consonants[-2:] in ('rl', 'sl', 'tl', 'nr', 'sr'): | |
breaks.append(vowel + b + 1) | |
else: | |
breaks.append(vowel + b) | |
else: | |
breaks.append(vowel + b + 1) | |
print('e', breaks) | |
# word was broken left of the vowel | |
vowel = i | |
vowels = x | |
consonants = '' | |
## elif any(( | |
## (word.startswith(consonants) and consonants + vowels in prefixes), | |
## (word.startswith(vowels) and vowels + consonants in prefixes), | |
## )): | |
## breaks.append(i) | |
## vowel = None | |
## vowels = '' | |
## consonants = '' | |
## m = | |
## print(m.start()) | |
#### m = re.match(r'|'.join(prefixes), word) | |
#### print(m.start()) | |
## stop77 | |
else: | |
consonants += x | |
s = word | |
for pos in reversed(breaks): | |
s = s[:pos] + '/' + s[pos:] | |
return s.split('/') | |
if __name__ == '__main__': | |
find_syllables_test() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment