from typing import Counter


def create_vocabulary(text: str, vocab_size=100000):
    """Create vocabulary dictionaries.

    Args:
        text(str): raw text.

    Returns:
        token2id(dict): token to id mapping.
        id2token(dict): id to token mapping.
    """
    token2id = {'<PAD>': 0, '<OOV>': 1}
    id2token = {0: '<PAD>', 1: '<OOV>'}
    freq = Counter(text)
    for token, _ in freq.most_common(vocab_size):
        tok_id = len(token2id)
        token2id[token] = tok_id
        id2token[tok_id] = token

    return token2id, id2token