diff options
author | Anthony Wang | 2024-03-07 16:20:00 -0500 |
---|---|---|
committer | Anthony Wang | 2024-03-07 16:20:00 -0500 |
commit | 69d774d92bdf54d0c882b661c65bf2f49ac996ce (patch) | |
tree | 8a1e3deb8292207cbb8f3b11351da58ba53b6f49 /static | |
parent | 195b9cf859fa1f49be57b22c737329fa4f6c812b (diff) |
Move shell logic outside of short-story.py
Diffstat (limited to 'static')
-rw-r--r-- | static/src/short-story.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/static/src/short-story.py b/static/src/short-story.py index 5716318..91748f4 100644 --- a/static/src/short-story.py +++ b/static/src/short-story.py @@ -1,28 +1,27 @@ +# Example usage: +# python static/src/short-story.py (curl -s https://raw.githubusercontent.com/awestover/skyspace/master/posts/misc/src/02-25-24.md | tail -n +10 | psub) (tail -n +13 content/posts/short-story-2.md | psub) + from collections import Counter from re import sub -from os import system -from os.path import isfile +from sys import argv def cnt(filename): c = Counter() with open(filename) as f: - for w in f.read().split('.*')[1].split(): + for w in f.read().split(): c[sub(r'[^a-zA-Z]', '', w).lower()] += 1 return c -if not isfile('/tmp/orig'): - system('echo ".*" > /tmp/orig && curl https://raw.githubusercontent.com/awestover/skyspace/master/posts/misc/src/02-25-24.md | tail -n +10 >> /tmp/orig') - -A = cnt('/tmp/orig') -B = cnt('content/posts/short-story-2.md') +A = cnt(argv[1]) +B = cnt(argv[2]) 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]) +# print('-------------- UNDERUSED') +# for a in A.keys(): +# if A[a] > B[a]: +# print(a, A[a], B[a]) # for i in range(A[a]-B[a]): # print(a, end=' ') |