def to_prefix_notation()

in utils/express_utils.py [0:0]


def to_prefix_notation(str_):
    """
    A simple utils method that converts the input string A(B,C(D),E) into the more
    familiar EXR format: (A B (C D ) E ). One extra processing is the upper-casing of
    of non-terminal nodes to match the EXR format convention.
    :param str_: input string to be converted
    :return: str after conversion
    """
    res = []
    str_ = str_.replace(')',' )').replace('(','( ').replace(',', ' ')
    for word in str_.split():
        if word.endswith('('):
            word = '(' + word.strip('(').upper()
        res.append(word)
    return ' '.join(res)