Skip to content

Instantly share code, notes, and snippets.

@santhalakshminarayana
Created January 6, 2020 05:59
Show Gist options
  • Save santhalakshminarayana/2cf51686173446651833793d7651095b to your computer and use it in GitHub Desktop.
Save santhalakshminarayana/2cf51686173446651833793d7651095b to your computer and use it in GitHub Desktop.
Quotes Reading - Medium
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