Skip to content

Instantly share code, notes, and snippets.

@h2rashee
Created November 1, 2014 18:08
Show Gist options
  • Save h2rashee/806f25f4fd95c2a1abfc to your computer and use it in GitHub Desktop.
Save h2rashee/806f25f4fd95c2a1abfc to your computer and use it in GitHub Desktop.
Given a stream of text, add a newline after any form of end of sentence punctuation
import fileinput
endOfSentence = ['.', '!', '?']
def charInWord(word):
for char in endOfSentence:
if char in word:
return True
return False
for line in fileinput.input():
for word in line.split():
if charInWord(word):
print word
else:
print word,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment