poemecanic~20171217-170238.py 963 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. print(''.join(newtext))
  26. # with open('export.txt', 'w') as f:
  27. # f.write()