diff options
author | Anthony Wang | 2024-03-05 23:51:24 -0500 |
---|---|---|
committer | Anthony Wang | 2024-03-05 23:51:24 -0500 |
commit | 2ff6843a3a83bdc3e845a8d5c40de478cf5ae301 (patch) | |
tree | 38fd34e4bf5d9bf6171bb2e2403cc74d3fff18ea /static | |
parent | c3030893f317c6974a07b84b9ef45e47b90582a9 (diff) |
Short story 2
Diffstat (limited to 'static')
-rw-r--r-- | static/src/short-story.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/static/src/short-story.py b/static/src/short-story.py new file mode 100644 index 0000000..2748544 --- /dev/null +++ b/static/src/short-story.py @@ -0,0 +1,21 @@ +from collections import Counter +from re import sub + +def cnt(filename): + c = Counter() + with open(filename) as f: + for w in f.read().split(): + c[sub(r'[^a-zA-Z]', '', w).lower()] += 1 + return c + +A = cnt('/tmp/orig') +B = cnt('/tmp/mine') +print(A.keys(), B.keys()) +print('-------------- OVERUSED') +for b in B.keys(): + if A[b] < B[b]: + print(b, A[b], B[b]) +print('-------------- UNDERUSED') +for a in A.keys(): + if A[a] > B[a]: + print(a, A[a], B[a]) |