Exemplo n.º 1
0
def for_split_to_str(test_data, estimated_words):
    result = split_to_str(test_data)
    assert result.pop(0) == 'code'
    texts = []
    nums = []
    while result:
        nums.append(result.pop(0))
        texts.append(result.pop(0))

    for ew, w in zip(estimated_words, texts):
        assert ew == w
Exemplo n.º 2
0
def for_split_to_str(test_data, estimated_words):
    result = split_to_str(test_data)
    assert result.pop(0) == 'code'
    texts = []
    nums = []
    while result:
        nums.append(result.pop(0))
        texts.append(result.pop(0))

    for ew, w in zip(estimated_words, texts):
        assert ew == w
Exemplo n.º 3
0
def parse_added_lines(added_lines, method_name):
    tmp = '\n'.join([line for lineno, line in added_lines])
    seq = split_to_str(tmp)
    seq = tokenizer.parse(seq)
    seq = search_method(method_name).parse(seq)
    seq = seq_split_nodes_of_label(seq, "null")[0]
    if len(list(seq_outermost_node_iter(seq, 'target_method'))) == 0:
        return []
    for expression in parsing_expressions:
        seq = expression.parse(seq)
        seq = seq_split_nodes_of_label(seq, "null")[0]

    num_args_list = set()
    for pos, invoke_seq in seq_outermost_node_iter(seq, 'method_invoke'):
        params = len(list(seq_outermost_node_iter(invoke_seq, 'param')))
        num_args_list.add(params)

    return num_args_list
Exemplo n.º 4
0
def parse_added_lines(added_lines, method_name):
    tmp = '\n'.join([line for lineno, line in added_lines])
    seq = split_to_str(tmp)
    seq = tokenizer.parse(seq)
    seq = search_method(method_name).parse(seq)
    seq = seq_split_nodes_of_label(seq, "null")[0]
    if len(list(seq_outermost_node_iter(seq, 'target_method'))) == 0:
        return []
    for expression in parsing_expressions:
        seq = expression.parse(seq)
        seq = seq_split_nodes_of_label(seq, "null")[0]

    num_args_list = set()
    for pos, invoke_seq in seq_outermost_node_iter(seq, 'method_invoke'):
        params = len(list(seq_outermost_node_iter(invoke_seq, 'param')))
        num_args_list.add(params)

    return num_args_list