<commit_before>import re
import matlab2cpp as mc
import armadillo as arma

def add_indenting(text):
    """Add identing to text
    """

    lines = text.split("\n")

    indent = 0
    for i in xrange(len(lines)):
        line = lines[i]

        # Fix indentation and linesplit
        if line in ("}", "} ;") or line[:4] == "} //":
            indent -= 1
            line = "  "*indent + line

        elif line == "{":
            line = "  "*indent + line
            indent += 1
        else:
            line = "  "*indent + line
        lines[i] = line

    text = "\n".join(lines)

    return text


def number_fix(text):
    """Code has allot of '-1' statements in indexing. This code substitutes
explicit number subtractions with the single index equivalent.

Examples:
    >>> print number_fix("a(8-1, 5-1)")
    a(7, 4)
    """
    # Cosmetic fix
    for p0,p1,p2 in set(re.findall(r"(([ ,(\[])(-?\d+)-1)", text)):
        val = int(p2)-1
        val = p1+str(val)
        text = val.join(text.split(p0))

    for p0,p1,p2 in \
            set(re.findall(r"(([+\- ])(\d+)-1)", text)):
        if p1=="-":     val = int(p2)+1
        else:           val = int(p2)-1
        if val:         val = p1+str(val)
        else:           val = ""
        text = val.join(text.split(p0))

    text = re.sub(r"\+-", r"-", text)
    return text


def strip(text):
    """Remove trailing spaces and linefeeds.
    """
    if not text: return text

    start = 0
    while text[start] in "\n ":<commit_msg>Modified the regular expression in number_fix in _program.py a = 1-1/2 was "fixed" to a = 0/2. Now it is "unfixed" -> a = 1-1/2<commit_after>import re
import matlab2cpp as mc
import armadillo as arma

def add_indenting(text):
    """Add identing to text
    """

    lines = text.split("\n")

    indent = 0
    for i in xrange(len(lines)):
        line = lines[i]

        # Fix indentation and linesplit
        if line in ("}", "} ;") or line[:4] == "} //":
            indent -= 1
            line = "  "*indent + line

        elif line == "{":
            line = "  "*indent + line
            indent += 1
        else:
            line = "  "*indent + line
        lines[i] = line

    text = "\n".join(lines)

    return text


def number_fix(text):
    """Code has allot of '-1' statements in indexing. This code substitutes
explicit number subtractions with the single index equivalent.

Examples:
    >>> print number_fix("a(8-1, 5-1)")
    a(7, 4)
    """
    # Cosmetic fix
    for p0,p1,p2 in set(re.findall(r"(([ ,(\[])(-?\d+)-1(?![*/]))", text)):
        val = int(p2)-1
        val = p1+str(val)
        text = val.join(text.split(p0))

    for p0,p1,p2 in \
            set(re.findall(r"(([+\- ])(\d+)-1(?![*/]))", text)):
        if p1=="-":     val = int(p2)+1
        else:           val = int(p2)-1
        if val:         val = p1+str(val)
        else:           val = ""
        text = val.join(text.split(p0))

    text = re.sub(r"\+-", r"-", text)
    return text


def strip(text):
    """Remove trailing spaces and linefeeds.
    """
    if not text: return text

    start = 0
    while text[start] in "\n ":
{'fraction_non_alphanumeric': 0.168467895740623, 'fraction_numerical': 0.02288620470438652, 'mean_word_length': 1.8274932614555257, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 10, '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': '6247054', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1087, 'n_words': 306}