poemecanic~20171217-105448.py 550 B

1234567891011121314151617181920
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. def splitParagraphIntoSentences(paragraph):
  4. ''' break a paragraph into sentences
  5. and return a list '''
  6. import re
  7. # to split by multile characters
  8. # regular expressions are easiest (and fastest)
  9. sentenceEnders = re.compile('[.!?]')
  10. sentenceList = sentenceEnders.split(paragraph)
  11. return sentenceList
  12. with open("how_2_use_drill.txt", "r" ) as source:
  13. for line in source:
  14. sentences = splitParagraphIntoSentences(line)
  15. for s in sentences:
  16. print s.strip()