poemecanic~20171217-110800.py 547 B

123456789101112131415161718192021
  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. sentenceEnders = re.compile('[.!?]')
  9. sentenceList = sentenceEnders.split(paragraph)
  10. return sentenceList
  11. with open("how_2_use_drill.txt", "r" ) as source:
  12. for line in source:
  13. sentences = splitParagraphIntoSentences(line)
  14. for s in sentences:
  15. print s.strip()
  16. def splitParagraphIntoSentences(paragraph):
  17. print