You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
231 B

from collections import Counter
def count_tokens(records):
cnt = Counter()
for rec in records:
cnt.update(rec["tokens"])
return cnt
def top_n(counter_obj, n=8):
return counter_obj.most_common(n)