Improve short-story.py script
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Anthony Wang 2024-03-06 12:26:09 -05:00
parent 967dae2561
commit e399274ba7
Signed by: a
SSH key fingerprint: SHA256:B5ADfMCqd2M7d/jtXDoihAV/yfXOAbWWri9+GdCN4hQ

View file

@ -1,15 +1,20 @@
from collections import Counter
from re import sub
from os import system
from os.path import isfile
def cnt(filename):
c = Counter()
with open(filename) as f:
for w in f.read().split():
for w in f.read().split('.*')[1].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('/tmp/mine')
B = cnt('content/posts/short-story-2.md')
print(A.keys(), B.keys())
print('-------------- OVERUSED')
for b in B.keys():