script1AM~20171217-160414.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import random
  4. occurences = ["What are the demands","There are no demands","The demands","Impossible demands", "Impossible demand","We demand the impossible","Impossible to demand"]
  5. democracy = "democracy"
  6. democracy_en_grand = democracy.upper()
  7. print(democracy_en_grand)
  8. liste = list( democracy )
  9. random.shuffle( liste )
  10. democracy_shuffled = ''.join( liste )
  11. print(democracy_shuffled)
  12. # read stopwords from file & save them in a list
  13. # read from file
  14. with open("occupy.txt", "r") as source:
  15. txt = source.readline()
  16. print(txt)
  17. if democracy in txt:
  18. newtxt = txt.replace(democracy, democracy_shuffled)
  19. print(newtxt)
  20. # # for each line
  21. # for line in source:
  22. # # clean returns
  23. # line = line.strip()
  24. # #print(line)
  25. # #split sentences into words
  26. # words = line.split()
  27. # print(" ".join(words))
  28. # #for each words ...
  29. # for word in words:
  30. # if word == "democracy":
  31. # word = word.upper()
  32. # print(word)
  33. # liste = list( word )
  34. # random.shuffle( liste )
  35. # word = ''.join( liste )
  36. # print(word)
  37. # print(" ".join(words))
  38. # #replace what are the demands
  39. # sentence = occurences[0]
  40. # print("sentence:", sentence)
  41. # sentence.replace("What are the demands"," what are the demands ")
  42. # print(sentence)
  43. # #replace there are no demands
  44. # #sentence.replace("there are no demands","therearenodemands")
  45. # #print(sentence)
  46. # #reverse order
  47. # #chaine = "impossible demands, impossible demand, impossible to demand"
  48. # #chaine = chaine [::-1]
  49. # #print(chaine)
  50. # # majuscule
  51. # #if sentence == "We demand the impossible":
  52. # #sentence = sentence.upper()
  53. # # écrire la nouvelle liste comme chaîne de caractères dans un fichier texte
  54. # with open('export.txt', 'w') as f:
  55. # f.write(script1)