Improve short-story.py script
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
967dae2561
commit
e399274ba7
|
@ -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():
|
||||
|
|
Loading…
Reference in a new issue