You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromcollectionsimportCounterfromdataclassesimportdataclass, fieldimportunicodedata@dataclassclassCharCounter():
char_counter: Counter=field(init=False, repr=False)
def__post_init__(self):
"""Do post init."""self.char_counter=Counter()
deffit(self, text: str):
"""Fit counter with text."""self.char_counter.update(text)
# print top n uncommen characters in char_counterdefprint_top_n(self, n: int=10):
"""Print top n uncommen characters in char_counter."""rare_chars=self.char_counter.most_common()[-n:]
# print rare chars with their count unicode and hex representationforchar, countinrare_chars:
print(f">{char}< {hex(ord(char))}{unicodedata.category(char)}")
No description provided.
The text was updated successfully, but these errors were encountered: