import re


def make_clean_input(pattern):
    """
    Enforces that entities or words have parentheses around them and have trailing spaces
    >>> make_clean_input("@num{3}")
    '(@(num ) ){3}'
    >>> make_clean_input("num{3}")
    '(num ){3}'

    Entities can sometimes have underscores
    >>> make_clean_input("@NUM_PLURAL{3}")
    '(@(NUM_PLURAL ) ){3}'

    Entities or words should have at least one character
    >>> make_clean_input("a{10}")
    '(a ){10}'
    """
    entity_pattern = re.compile(r"(@[a-zA-Z\_][\w]*)")
    pattern = re.sub(
        entity_pattern, lambda match: "({} )".format(match.group()), pattern
    )

    word_pattern = re.compile(r"([a-zA-Z\_][\w]*)")
    pattern = re.sub(word_pattern, lambda match: "({} )".format(match.group()), pattern)
    return pattern