projects
/
uwc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d5b2b99
)
uwc: python version
author
Richard Kojedzinszky
<krichy@cflinux.hu>
Fri, 26 Sep 2014 07:32:28 +0000
(09:32 +0200)
committer
Richard Kojedzinszky
<krichy@cflinux.hu>
Fri, 26 Sep 2014 07:32:28 +0000
(09:32 +0200)
uwc.py
[new file with mode: 0644]
patch
|
blob
diff --git a/uwc.py
b/uwc.py
new file mode 100644
(file)
index 0000000..
5367cba
--- /dev/null
+++ b/
uwc.py
@@ -0,0
+1,15
@@
+#!/usr/bin/env python
+
+import re
+import sys
+
+counts = {}
+word_re = re.compile(r"([a-z']+)", re.IGNORECASE)
+for line in sys.stdin:
+ for w in word_re.findall(line):
+ counts[w] = counts.get(w, 0) + 1
+
+
+words = sorted(counts, key=lambda x: counts[x])
+for w in words:
+ print w