<commit_before># encoding: utf-8
import sys
import copy
import random
import datetime
import multiprocessing
from jellyfish import jaro_winkler

fmap = {
    '+': lambda *args: sum(args),
    '-': lambda x,y: x-y,
    '*': lambda x,y: x*y,
    #'/': lambda x,y: x/y,
    #'val': lambda: random.uniform(1,9)
}
def execute(ftree, kwargs={}):
    if type(ftree) in (int, float):
        return ftree
    if type(ftree) in (str, unicode):
        return kwargs[ftree]
    if len(ftree) in [0,1]:
        if kwargs:
            return kwargs.values()[0]
        return None if not ftree else ftree[0]

    f = ftree[0]
    fargs = [execute(arg, kwargs) for arg in ftree[1:]]
    return fmap[f](*fargs)

def gen_random_tree(args):
    if len(args) == 1:
        return args[0]
    tree = [random.choice(fmap.keys())]
    if random.random() > 0.5:
        args.append(random.uniform(1,9))
    left = gen_random_tree(args[:len(args)/2])
    right = gen_random_tree(args[:len(args)/2])
    leafes = [left, right]
    random.shuffle(leafes)
    tree.extend(leafes)
    return tree
<commit_msg>[ProjetoDissertacao] Coloca mais informação de debug nos operadores<commit_after># encoding: utf-8
import sys
import copy
import random
import datetime
import multiprocessing
from jellyfish import jaro_winkler

fmap = {
    '+': lambda *args: sum(args),
    '-': lambda x,y: x-y,
    '*': lambda x,y: x*y,
    #'/': lambda x,y: x/y,
    #'val': lambda: random.uniform(1,9)
}
def execute(ftree, kwargs={}):
    if type(ftree) in (int, float):
        return ftree
    if type(ftree) in (str, unicode):
        return kwargs[ftree]
    if len(ftree) in [0,1]:
        if kwargs:
            return kwargs.values()[0]
        return None if not ftree else ftree[0]

    f = ftree[0]
    fargs = [execute(arg, kwargs) for arg in ftree[1:]]
    return fmap[f](*fargs)

def gen_random_tree(args):
    if len(args) == 1:
        return args[0]
    tree = [random.choice(fmap.keys())]
    if random.random() > 0.5:
        args.append(random.uniform(1,9))
    left = gen_random_tree(args[:len(args)/2])
    right = gen_random_tree(args[:len(args)/2]]
    if None in left or None in right:
        import pdb;pdb.set_trace()
    leafes = [left, right]
    random.shuffle(leafes)
    tree.extend(leafes)
    return tree

{'fraction_non_alphanumeric': 0.14609681639773223, 'fraction_numerical': 0.014827736589620584, 'mean_word_length': 2.9483648881239244, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '923433', 'n_tokens_mistral': 847, 'n_tokens_neox': 840, 'n_words': 217}