def remove_under_k(seq, k):
    """ remove tokens that repeat less then k times in a row
    >> remove_under_k("a a a a b c c c", 1) ==> a a a a c c c """
    seq = seq.strip().split(" ")
    result = []

    freqs = [(k,len(list(g))) for k, g in groupby(seq)]
    for c, f in freqs:
        if f > k:
            result += [c for _ in range(f)]
    return " ".join(result) + "\n" #, reps
remove tokens that repeat less then k times in a row
>> remove_under_k("a a a a b c c c", 1) ==> a a a a c c c
examples/emotion_conversion/preprocess/build_translation_manifests.py