poemecanic.sync-conflict-20171217-115720-XDN4NNH.py 1013 B

123456789101112131415161718192021222324252627282930313233343536373839
  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'drill')
  10. #sépare les phrases en se repérant le regex
  11. #sentenceList = prose.split(paragraph)
  12. return prose
  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. # '''définir une fonction qui sépare les paragraphes
  20. # en phrases dans une list'''
  21. # def splitParagraphIntoSentences(paragraph):
  22. # #utiliser la librairie regex
  23. # import re
  24. # sentenceEnders = re.compile('[.!?]')
  25. # return sentenceEnders
  26. # with open("how_2_use_drill.txt", "r" ) as source:
  27. # for line in source:
  28. # sentences = splitParagraphIntoSentences(line)
  29. # for s in sentences:
  30. # print s.strip()