poemecanic~20171217-174552.py 1012 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #ma fonction
  4. # def splitParagraphIntoSentences(paragraph):
  5. # ''' break a paragraph into sentences
  6. # and return a list '''
  7. # import re
  8. # #pour repérer l'expression régulière
  9. # prose = re.compile(r"\wrill[a-z0-9._-]*\s(\w*\s\w*\s\w*\s)")
  10. # #applique retour à la ligne en se repérant le regex
  11. # List = prose.split(paragraph)
  12. # return List
  13. # #appliquer le variable sentenceList
  14. # with open("how_2_use_drill.txt", "r" ) as source:
  15. # for line in source:
  16. # sentences = splitParagraphIntoSentences(line)
  17. # for s in sentences:
  18. # print s.strip()
  19. import re
  20. prose = re.compile(r"\w+.+rill+.+\s(\w*\s\w*\s\w*\s)\w*")
  21. prose2 = re.compile(r"(\w*\s\w*\s\w*)\s\w+.+rill+.+\s\w*")
  22. with open("how_2_use_drill.txt", "r" ) as source:
  23. for line in source:
  24. newtext = prose2.findall(line)
  25. # newtext = prose.findall(line)
  26. firstLine =
  27. print(''.join(newtext))
  28. # with open('export.txt', 'w') as f:
  29. # f.write()