Skip to content

Instantly share code, notes, and snippets.

@rocapp
Created January 16, 2017 16:44
Show Gist options
  • Save rocapp/5ada903e83cf0b1da848aa05820147b8 to your computer and use it in GitHub Desktop.
Save rocapp/5ada903e83cf0b1da848aa05820147b8 to your computer and use it in GitHub Desktop.
def get_best(file):
words = list()
with open(file, 'r') as f:
bf = json.load(f)
sbf = sorted(bf.items(), key=itemgetter(1), reverse=True)
sbf = [bb[0] for bb in sbf]
return sbf[0:int(len(sbf)/2.0)] # chooses the top half
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment