def _term_frequency(X):
    """
    Count the number of occurrences of each term in X.
    """
    term_freq = (
        X[["token", "count"]]
        .groupby(["token"])
        .sum()
    )
    return term_freq["count"].values