poemecanic~20171217-105435.py 602 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. # import re
  4. # m = re.findall(r"")
  5. def splitParagraphIntoSentences(paragraph):
  6. ''' break a paragraph into sentences
  7. and return a list '''
  8. import re
  9. # to split by multile characters
  10. # regular expressions are easiest (and fastest)
  11. sentenceEnders = re.compile('[.!?]')
  12. sentenceList = sentenceEnders.split(paragraph)
  13. return 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. # print(line)