3~20171217-165354.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. "SUB-",
  13. "PARA-",
  14. "AUTO-",
  15. "POST-",
  16. "INTER-",
  17. "HOMO-"
  18. ]
  19. print (prefixes)
  20. #jusque là c'est bon
  21. #print (prefixe1)
  22. #intégrer une sentence
  23. #myfile = open ("which_spites.txt", 'r')
  24. #sentence = myfile.read()
  25. #myfile.close()
  26. phrase = "Thus have I politicly begun my reign, And 'tis my hope to end successfully.\
  27. 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."
  28. print("1ere réplique:", phrase)
  29. nouvelle_phrase = []
  30. sortie = ''
  31. lettres_seules = []
  32. longueur_mini = 4
  33. mots = phrase.split()
  34. print("réplique séparé:",mots)
  35. for mot in mots:
  36. # si le mot est assez long
  37. if ( len(mot) >= longueur_mini ) :
  38. print('mot à préfixer : ' + mot)
  39. nouvelle_phrase.append( random.choice( prefixes ) + mot )
  40. else:
  41. nouvelle_phrase.append( mot )
  42. # lettres_seules = list(mot)
  43. # print("tentative de lettre:", lettres_seules)
  44. # print (len(mot))
  45. # length = len(mot)
  46. # if length >= 4 :
  47. print(nouvelle_phrase)
  48. print('---')
  49. for mot in nouvelle_phrase:
  50. sortie = sortie + mot + ' '
  51. print(sortie)
  52. #for mot in mots:
  53. #length >= 4= list (mot)
  54. # mots_length4= length >= 4= list (mot)
  55. # print ("listes mots choisis:", mots_length4)
  56. #
  57. # nouveau_mot= prefixe+mot
  58. # print(nouveau_mot)
  59. # nouvelle_phrase.append(nouveau_mot)
  60. #len(mot) : "combien de lettres compose chaque mot?"
  61. #length = len(mot) : "LA LONGUEUR DU MOT"
  62. #if length >= 4 : "si mon mot est plus grand que 4..."
  63. #print (length, mot) "... me le montrer" : rajouter un script dans le script pour l'ensemble des actions; trouver, déinir, classer...
  64. #définir la liste de mot correspondante:
  65. #c'est devenu les mots de plus de ' lettres'
  66. #print(nouvelle_phrase)
  67. #print("phrase mono-", " ".join(nouvelle_phrase))
  68. #séparer chaque mot
  69. #choix d'un prefixe parmis le stack de prefixe
  70. #indiquer au prefixe qu'il precede le mot
  71. #pour export
  72. with open('export.txt','w')as f:
  73. f.write(dictee_genetic)