2015-07-13

PYTHON - Break a paragraph into a sentences list

import re
text = 'This is. A paragraph with. Three sentences.'
sentences = re.split(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s', text)
for item in sentences:
    print(item)

No comments:

Post a Comment