I have made a Spanish verb conjugation function which has 2 parameters for the pronoun and verb as shown below:
def doConjugate(pronoun,verb):
if unidecode(verb).endswith("ar"):
arDict = {"yo": "o", "tú": "as", "usted": "a", "él": "a", "ella": "a", "nosotros": "amos", "vosotros": "áis", "ustedes": "an", "ellos": "an", "ellas": "an"}
verb = verb[:-2] + arDict[pronoun]
print(verb)
if unidecode(verb).endswith("er") or unidecode(verb).endswith("ir"):
erDict = {"yo": "o", "tú": "es", "usted": "e", "él": "e", "ella": "e", "nosotros": "emos", "vosotros": "éis", "ustedes": "en", "ellos": "en", "ellas": "en"}
irDict = {"nosotros": "imos", "vosotros": "ís"}
if (pronoun == "nosotros" or pronoun == "vosotros") and verb.endswith("ir"):
verb = verb[:-2] + irDict[pronoun]
else:
verb = verb[:-2] + erDict[pronoun]
print(verb)
Addionally, I have two text files. One with all of the verbs, and a second one with all of the pronouns. I want to make a for loop which takes the pronoun from one file and the verb from the another and conjugate it. However, I do not know how to do so.
Below is what it tried to do:
with open("words.txt") as file:
with open("pronouns.txt") as f:
for word in file:
for conjugates in f:
conjugated = doConjugate(conjugates,word)
print(conjugated)
However, in the terminal, instead of the conjugations, I just get the word "None" over and over. I am new to python and am requesting someone to show how to do this properly.