Created
September 7, 2016 04:14
-
-
Save natematias/6f42abf8faabc763d458fd41144b8c44 to your computer and use it in GitHub Desktop.
Find sentences with 140 characters or less
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 nltk | |
import sys | |
sent_detector = nltk.data.load('tokenizers/punkt/english.pickle') | |
fulltext = open(sys.argv[1], "r").read() | |
for sentence in sent_detector.tokenize(fulltext.strip()): | |
if(len(sentence) <= 140): | |
print(sentence) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment