from typing import List
import collections


def preprocess(tokens: List[str], fs=False):
    """Return text length, vocabulary size and optionally the frequency
    spectrum.

    :param fs: additionally calculate and return the frequency
               spectrum

    """
    txt_len = len(tokens)
    vocab_size = len(set(tokens))
    if fs:
        frequency_list = collections.Counter(tokens)
        freq_spectrum = dict(collections.Counter(frequency_list.values()))
        return txt_len, vocab_size, freq_spectrum
    return txt_len, vocab_size