def reduce_lengthening(text):
    """
    Replace repeated character sequences of length 3 or greater with sequences of length 3.
    """
    pattern = regex.compile(r"(.)\1{2,}")
    return pattern.sub(r"\1\1\1", text)

    Replace repeated character sequences of length 3 or greater with sequences of length 3.
    
dpkd/transformers/src/transformers/models/bertweet/tokenization_bertweet.py