<commit_before>from ..core.operations import Add, Mul, Pow
from ..core.symbol import Symbol
from ..core.numbers import Number, Rational
from ..core.function import Function


def basic_console(u, prior_presedence=0):
    if isinstance(u, (Add, Mul, Pow)):
        result = format_operator(u)

        if u.precedence <= prior_presedence:
            result = '(' + result + ')'

        return result

    if isinstance(u, Symbol):
        return u.name

    if isinstance(u, Number):
        result = str(u.value)

        if isinstance(u, Rational):
            result = '(' + result + ')'

        return result

    if isinstance(u, Function):
        return u.name + '(' + str(u.args)[1:-1] + ')'

    else:
        return u


def format_operator(u):
    l = [basic_console(x, u.precedence) for x in joinit(u.args, u.symbol)]
    return ''.join(l)


def joinit(iterable, delimiter):
    it = iter(iterable)
    yield next(it)
    for x in it:
        yield delimiter
        yield x<commit_msg>more natuaral formatting<commit_after>from ..core.operations import Add, Mul, Pow
from ..core.symbol import Symbol
from ..core.numbers import Number, Rational
from ..core.function import Function


def basic_console(u, prior_presedence=0):
    if isinstance(u, (Add, Mul, Pow)):
        result = format_operator(u)

        if u.precedence <= prior_presedence:
            result = '(' + result + ')'

        return result

    if isinstance(u, Symbol):
        return u.name

    if isinstance(u, Number):
        result = str(u.value)

        if isinstance(u, Rational):
            result = '(' + result + ')'

        return result

    if isinstance(u, Function):
        return u.name + '(' + str(u.args)[1:-1] + ')'

    else:
        return u


def format_operator(u):
    if isinstance(u, Mul):
        l = [basic_console(x, u.precedence) for x in joinit(u.args, '')]
        l = ['-' if x == '-1' else x for x in l]
    elif isinstance(u, Add):
        l = [basic_console(x, u.precedence) for x in joinit(u.args, ' ' + u.symbol + ' ')]
    else:
        l = [basic_console(x, u.precedence) for x in joinit(u.args, u.symbol)]

    s = ''.join(l)
    return s.replace('+ -', '- ')



def joinit(iterable, delimiter):
    it = iter(iterable)
    yield next(it)
    for x in it:
        yield delimiter
        yield x
{'fraction_non_alphanumeric': 0.13462365591397848, 'fraction_numerical': 0.003010752688172043, 'mean_word_length': 2.31811697574893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5088135', 'n_tokens_mistral': 771, 'n_tokens_neox': 736, 'n_words': 213}