Created
January 10, 2020 18:55
-
-
Save eHammarstrom/ead3f42083e437e3f357ddcf67de6c9a to your computer and use it in GitHub Desktop.
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 sys | |
if len(sys.argv) != 2: | |
exit(1) | |
text = open(sys.argv[1], 'r').read() | |
words = text.replace("\n", " ").split(" ") | |
for i in range(1, len(words)): | |
prev_word = words[i-1] | |
curr_word = words[i] | |
if prev_word == curr_word: | |
if curr_word in ['', ' ']: # skip some leftovers | |
continue | |
# print word and context | |
print('repeated word (', curr_word, ')', 'line: ', end='\n\t') | |
for j in range(5): | |
if (i-3+j) > 0: | |
print(words[i-3+j], end=' ') | |
print('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment