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 pathlib import Path
|
||||||
from typing import Counter
|
from typing import Counter
|
||||||
|
|
||||||
|
PARENS = list("()[]{}<>")
|
||||||
|
SMILEYS = [":D", "D:"]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
parser.add_argument("path", type=Path)
|
parser.add_argument("path", type=Path)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
chars = Counter[str]()
|
count = Counter[str]()
|
||||||
with open(args.path) as f:
|
with open(args.path) as f:
|
||||||
print("Reading lines")
|
print("Reading lines")
|
||||||
for line in f:
|
for line in f:
|
||||||
content = json.loads(line)["content"]
|
content: str = json.loads(line)["content"]
|
||||||
chars += Counter(content)
|
count += Counter(content)
|
||||||
|
for smiley in SMILEYS:
|
||||||
|
count[smiley] += content.count(smiley)
|
||||||
|
|
||||||
for c in "()[]{}<>":
|
for paren in PARENS:
|
||||||
print(f"{c} - {chars[c]:6}")
|
print(f" {paren} - {count[paren]:6}")
|
||||||
|
for smiley in SMILEYS:
|
||||||
|
print(f"{smiley} - {count[smiley]:6}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue