Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / sentences.py
Created January 12, 2013 03:50
Split up text into sentences (roughly)
import re
with open("infile.txt", "r") as fp:
queue=""
match=r"[?!.]+\s+"
for rawLine in fp:
rawLine=" ".join((queue, rawLine))
queue=""
lines=rawLine.split(match)
if re.search(match+"$", rawLine):