Skip to content

Instantly share code, notes, and snippets.

@cronburg
Created March 11, 2016 15:39
Show Gist options
  • Save cronburg/867a071ac68d7b7cee02 to your computer and use it in GitHub Desktop.
Save cronburg/867a071ac68d7b7cee02 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import re
import sys
with open(sys.argv[1]) as f:
lines = f.readlines()
rx = re.compile(r"[\w\s]")
d = {}
for l in lines:
if l.startswith('#'): continue
alpha = len(rx.findall(l))
nonAlpha = len(l) - alpha
d[l] = nonAlpha / (1.0 * len(l))
xs = sorted(d.items(), key=lambda x:x[1])
xs.reverse()
for i in range(20):
print(xs[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment