3.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/usr/bin/python
  2. # this is a shebang: https://en.wikipedia.org/wiki/Shebang_%28Unix%29
  3. import random
  4. #prefixes = prefixe1+ prefixe2+ prefixe3+ prefixe4 : chaîne de caractère / phrase
  5. #print ( type(nom_du_variable)) :pour savoir quel type d'objet
  6. prefixes = [
  7. "mono",
  8. "uni",
  9. "anti",
  10. "sub",
  11. "cyber",
  12. "para",
  13. "auto",
  14. "post",
  15. "inter",
  16. "homo"
  17. ]
  18. print (prefixes)
  19. #jusque là c'est bon
  20. #print (prefixe1)
  21. #intégrer une sentence
  22. #myfile = open ("which_spites.txt", 'r')
  23. #sentence = myfile.read()
  24. #myfile.close()
  25. phrase = "Thus have I politicly begun my reign, And 'tis my hope to end successfully.\
  26. My falcon now is sharp and passing empty. And till she stoop she must not be full-gorg'd, for then she never looks upon her lure. Another way I have to man my haggard, to make her come, and know her keeper's call, that is, to watch her, as we watch these kites that bate and beat, and will not be obedient. She eat no meat to-day, nor none shall eat; last night she slept not, nor to-night she shall not; as with the meat, some undeserved fault I'll find about the making of the bed; and here I'll fling the pillow, there the bolster, this way the coverlet, another way the sheets; Ay, and amid this hurly I intend that all is done in reverend care of her and, in conclusion, she shall watch all night; and if she chance to nod I'll rail and brawl and with the clamour keep her still awake. This is a way to kill a wife with kindness, and thus I'll curb her mad and headstrong humour. He that knows better how to tame a shrew, now let him speak; 'tis charity to show."
  27. print("1ere réplique:", phrase)
  28. nouvelle_phrase = []
  29. sortie = ''
  30. lettres_seules = []
  31. longueur_mini = 5
  32. mots = phrase.split()
  33. print("réplique séparé:",mots)
  34. for mot in mots:
  35. # si le mot est assez long
  36. if ( len(mot) >= longueur_mini ) :
  37. print('mot à préfixer : ' + mot)
  38. nouvelle_phrase.append( random.choice( prefixes ) + mot )
  39. else:
  40. nouvelle_phrase.append( mot )
  41. # lettres_seules = list(mot)
  42. # print("tentative de lettre:", lettres_seules)
  43. # print (len(mot))
  44. # length = len(mot)
  45. # if length >= 4 :
  46. print(nouvelle_phrase)
  47. print('---')
  48. for mot in nouvelle_phrase:
  49. sortie = sortie + mot + ' '
  50. print(sortie)
  51. #for mot in mots:
  52. #length >= 4= list (mot)
  53. # mots_length4= length >= 4= list (mot)
  54. # print ("listes mots choisis:", mots_length4)
  55. #
  56. # nouveau_mot= prefixe+mot
  57. # print(nouveau_mot)
  58. # nouvelle_phrase.append(nouveau_mot)
  59. #len(mot) : "combien de lettres compose chaque mot?"
  60. #length = len(mot) : "LA LONGUEUR DU MOT"
  61. #if length >= 4 : "si mon mot est plus grand que 4..."
  62. #print (length, mot) "... me le montrer" : rajouter un script dans le script pour l'ensemble des actions; trouver, déinir, classer...
  63. #définir la liste de mot correspondante:
  64. #c'est devenu les mots de plus de ' lettres'
  65. #print(nouvelle_phrase)
  66. #print("phrase mono-", " ".join(nouvelle_phrase))
  67. #séparer chaque mot
  68. #choix d'un prefixe parmis le stack de prefixe
  69. #indiquer au prefixe qu'il precede le mot
  70. #pour export
  71. with open('export.txt','w')as f:
  72. f.write(dictee_genetic)