Count smileys as well
This commit is contained in:
parent
a2e29d58d0
commit
c96717455c
1 changed files with 12 additions and 5 deletions
|
|
@ -3,21 +3,28 @@ from argparse import ArgumentParser
|
|||
from pathlib import Path
|
||||
from typing import Counter
|
||||
|
||||
PARENS = list("()[]{}<>")
|
||||
SMILEYS = [":D", "D:"]
|
||||
|
||||
|
||||
def main():
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("path", type=Path)
|
||||
args = parser.parse_args()
|
||||
|
||||
chars = Counter[str]()
|
||||
count = Counter[str]()
|
||||
with open(args.path) as f:
|
||||
print("Reading lines")
|
||||
for line in f:
|
||||
content = json.loads(line)["content"]
|
||||
chars += Counter(content)
|
||||
content: str = json.loads(line)["content"]
|
||||
count += Counter(content)
|
||||
for smiley in SMILEYS:
|
||||
count[smiley] += content.count(smiley)
|
||||
|
||||
for c in "()[]{}<>":
|
||||
print(f"{c} - {chars[c]:6}")
|
||||
for paren in PARENS:
|
||||
print(f" {paren} - {count[paren]:6}")
|
||||
for smiley in SMILEYS:
|
||||
print(f"{smiley} - {count[smiley]:6}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue