Move shell logic outside of short-story.py
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
195b9cf859
commit
69d774d92b
|
@ -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=' ')
|
||||
|
|
Loading…
Reference in a new issue