<commit_before>import factor_test as factor


def resolve_factor(line):
    line = line.replace(' ', '')
    l = line.split('=')
    factor_name = l[0]
    if len(l) == 1:
        base_factor_name = factor_name
        method = None
    else:
        l = l[1][:-1].split('(')
        method = [l[0]]
        l = l[1].split(',')
        base_factor_name = l[0]
        method += l[1:]
    return factor_name, base_factor_name, method


def resolve_condition(line):
    line = line.replace(' ', '')
    l = line.split('=')
    condition_name = l[0]
    l = l[1][-1].split('(')
    method = [l[0]]
    l = l[1].split(',')
    method += [l]
    return condition_name, method


if __name__=='__main__':
    input_factors = 'MA5 = MA(close,5)\nMA10 = MA(close, 10)'
    input_condition = 'gx = CROSS(MA5, MA10)'

    input_factors_lines = input_factors.split('\n')
    for line in input_factors_lines:
        print resolve_factor(line)

    input_condition_lines = input_condition.split('\n')
    for line in input_condition_lines:
        print resolve_condition(line)<commit_msg>factor_method<commit_after>import factor_test as factor


def resolve_factor(line):
    line = line.replace(' ', '')
    l = line.split('=')
    factor_name = l[0]
    if len(l) == 1:
        base_factor_name = factor_name
        method = None
    else:
        l = l[1][:-1].split('(')
        method = [l[0]]
        l = l[1].split(',')
        base_factor_name = l[0]
        method += l[1:]
    return factor_name, base_factor_name, method


def resolve_condition(line):
    line = line.replace(' ', '')
    l = line.split('=')
    condition_name = l[0]
    l = l[1][:-1].split('(')
    method = [l[0]]
    l = l[1].split(',')
    method += [l]
    return condition_name, method


if __name__ == '__main__':
    input_factors = 'MA5 = MA(close,5)\nMA10 = MA(close, 10)'
    input_condition = 'gx = CROSS(MA5, MA10)'

    input_factors_lines = input_factors.split('\n')
    for line in input_factors_lines:
        if len(line)>1:
            print resolve_factor(line)

    input_condition_lines = input_condition.split('\n')
    for line in input_condition_lines:
        if len(line)>1:
            print resolve_condition(line)
{'fraction_non_alphanumeric': 0.1551334237901402, 'fraction_numerical': 0.020805065581184983, 'mean_word_length': 2.7051926298157456, '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': '6499052', 'n_tokens_mistral': 797, 'n_tokens_neox': 766, 'n_words': 164}