I need to write a script that generates different sentences as Jean sleeps, Jean's mother sleeps, Jean's mother's cousin sleeps. Jean's sister's husband's brother sleeps and so on. For that I wrote a code of eight functions as seen below. Now I would like to write a second step, which would ask to input a sentence using family members like "my cousin's mother sleeps", and show which steps were taken to generate the sentence. Here is what I have so far:
# _*_ coding: utf-8 _*_
import random
def etat7(chaine):
return chaine+"dort."
def etat6(chaine):
choix=random.choice(range(0,3))
if choix==0:
mot="Jean "
return etat7(chaine+mot)
elif choix==1:
mot="la "
return etat3(chaine+mot)
elif choix==2:
mot="l' "
return etat4(chaine+mot)
def etat5(chaine):
choix=random.choice(range(0,2))
if choix==0:
mot="de "
return etat6(chaine+mot)
if choix==1:
mot="du "
return etat2(chaine+mot)
def etat4(chaine):
choix=random.choice(range(0,2))
if choix==0:
mot="ancêtre "
return etat5(chaine+mot)
elif choix==1:
mot="oncle "
return etat5(chaine+mot)
def etat3(chaine):
choix=random.choice(range(0,3))
if choix==0:
mot="mère "
return etat5(chaine+mot)
elif choix==1:
mot="soeur "
return etat5(chaine+mot)
elif choix==2:
mot="nièce "
return etat5(chaine+mot)
def etat2(chaine):
choix=random.choice(range(0,3))
if choix==0:
mot="père "
return etat5(chaine+mot)
elif choix==1:
mot="frère "
return etat5(chaine+mot)
elif choix==2:
mot="neveu "
return etat5(chaine+mot)
def etat1(chaine):
choix=random.choice(range(0,3))
if choix==0:
mot="le "
return etat2(chaine+mot)
elif choix==1:
mot="la "
return etat3(chaine+mot)
elif choix==2:
mot="l' "
return etat4(chaine+mot)
print etat1("")
At this step i have a program that generates different sentences, but I don't understand how to proceed.
Thank you