Skip to content

Instantly share code, notes, and snippets.

@BasementCat
Forked from anonymous/sentences.py
Created January 12, 2013 03:51
Show Gist options
  • Save BasementCat/4515964 to your computer and use it in GitHub Desktop.
Save BasementCat/4515964 to your computer and use it in GitHub Desktop.
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):
queue=lines.pop()
for realLine in lines:
#feed line to bot here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment