Created
November 1, 2014 18:08
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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