'Returns a FreqDist containing only data with counts below a given
threshold, as well as a mapping (None -> count_removed).'

def _freq_threshold(self, fdist, threshold):

    res = FreqDist()
    num_removed = 0
    for tok in fdist:
        count = fdist[tok]
        if (count < threshold):
            num_removed += 1
        else:
            res[tok] += count
    res[None] += num_removed
    return res
