Created
January 6, 2020 05:59
-
-
Save santhalakshminarayana/2cf51686173446651833793d7651095b to your computer and use it in GitHub Desktop.
Quotes Reading - Medium
This file contains hidden or 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
quotes = [] | |
max_len = 0 | |
min_len = 5 | |
sent_len_dic = defaultdict(int) | |
with open('quotes.txt', 'r') as f: | |
while True: | |
quote = f.readline() | |
if not quote: | |
break | |
words = quote.split(' ') | |
sent_len = len(words) | |
if sent_len < min_len: | |
continue | |
max_len = sent_len if sent_len > max_len else max_len | |
sent_len_dic[sent_len] += 1 | |
flag = False | |
for i in range(0,10): | |
if str(i) in quote: | |
flag = True | |
break | |
if flag == True: | |
continue | |
quote = quote.replace(',', ' ,').replace('.', ' .').replace('_','').strip('\n') + ' ;' | |
quotes.append(quote.lower()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment