diff --git a/count_parentheses.py b/count_parentheses.py index 54cac13..7dc6524 100644 --- a/count_parentheses.py +++ b/count_parentheses.py @@ -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__":