Skip to content

Instantly share code, notes, and snippets.

@alexeytal
Created November 10, 2016 20:09
Show Gist options
  • Save alexeytal/02587532050da697b99009133cc54510 to your computer and use it in GitHub Desktop.
Save alexeytal/02587532050da697b99009133cc54510 to your computer and use it in GitHub Desktop.
import sys
import argparse
parser=argparse.ArgumentParser()
parser.add_argument('-f',help="cutoff", type=int, default=0)
parser.add_argument('file',help="inputfile", type=str)
options=parser.parse_args()
with open(options.file, 'r') as f:
dict = {}
text = f.read()
text = text.replace(',',' ')
text = text.replace('.', ' ')
text = text.split()
for i in range(len(text)):
dict[text[i]] = dict.get(text[i],0) + 1
for k,v in dict.items():
if (v>options.f):
print(k, v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment