import requests
from typing import Counter


def get_freq(urn, top=50, cutoff=3):
    """Get frequency list for urn"""
    if isinstance(urn, list):
        urn = urn[0]
    r = requests.get("https://api.nb.no/ngram/urnfreq", json={'urn':urn, 'top':top, 'cutoff':cutoff})
    return Counter(dict(r.json()))