def clean_text(text):
    """
    Return a text suitable for SPDX license identifier detection cleaned
    from certain leading and trailing punctuations and normalized for spaces.
    """
    text = ' '.join(text.split())
    punctuation_spaces = "!\"#$%&'*,-./:;<=>?@[\\]^_`{|}~\t\r\n "
    # remove significant expression punctuations in wrong spot: leading parens
    # at head and closing parens or + at tail.
    leading_punctuation_spaces = punctuation_spaces + ")+"
    trailng_punctuation_spaces = punctuation_spaces + "("
    return text.lstrip(leading_punctuation_spaces).rstrip(trailng_punctuation_spaces)