コード例 #1
0
ファイル: actions.py プロジェクト: nengnengwu/recodoc2
def process_matches(text, matches, single_refs, kinds, kinds_hierarchies,
                    save_index, find_context):
    filtered = set()
    index = 0
    avoided = False

    for match in matches:
        if is_valid_match(match, matches, filtered):
            (parent, children) = match
            content = text[parent[0]:parent[1]]
            if parent[2] == IGNORE_KIND:
                avoided = True
                continue
            main_reference = SingleCodeReference(content=content,
                                                 kind_hint=kinds[parent[2]])
            if save_index:
                main_reference.index = index
            if find_context:
                main_reference.sentence = find_sentence(
                    text, parent[0], parent[1])
                main_reference.paragraph = find_paragraph(
                    text, parent[0], parent[1])
            main_reference.save()
            single_refs.append(main_reference)

            # Process children
            process_children_matches(text, matches, children, index,
                                     single_refs, kinds, kinds_hierarchies,
                                     save_index, find_context)
            index += 1
        else:
            filtered.add(match)

    return avoided
コード例 #2
0
ファイル: actions.py プロジェクト: bartdag/recodoc2
def process_matches(text, matches, single_refs, kinds, kinds_hierarchies,
        save_index, find_context):
    filtered = set()
    index = 0
    avoided = False

    for match in matches:
        if is_valid_match(match, matches, filtered):
            (parent, children) = match
            content = text[parent[0]:parent[1]]
            if parent[2] == IGNORE_KIND:
                avoided = True
                continue
            main_reference = SingleCodeReference(
                    content=content,
                    kind_hint=kinds[parent[2]])
            if save_index:
                main_reference.index = index
            if find_context:
                main_reference.sentence = find_sentence(text, parent[0],
                        parent[1])
                main_reference.paragraph = find_paragraph(text, parent[0],
                        parent[1])
            main_reference.save()
            single_refs.append(main_reference)

            # Process children
            process_children_matches(text, matches, children, index,
                    single_refs, kinds, kinds_hierarchies, save_index,
                    find_context)
            index += 1
        else:
            filtered.add(match)

    return avoided
コード例 #3
0
ファイル: actions.py プロジェクト: nengnengwu/recodoc2
def process_children_matches(text, matches, children, index, single_refs,
                             kinds, kinds_hierarchies, save_index,
                             find_context):

    for i, child in enumerate(children):
        content = text[child[0]:child[1]]
        parent_reference = find_parent_reference(child[2], single_refs,
                                                 kinds_hierarchies)
        child_reference = SingleCodeReference(
            content=content,
            kind_hint=kinds[child[2]],
            child_index=i,
            parent_reference=parent_reference)
        if save_index:
            child_reference.index = index
        if find_context:
            child_reference.sentence = find_sentence(text, child[0], child[1])
            child_reference.paragraph = find_paragraph(text, child[0],
                                                       child[1])
        child_reference.save()
        single_refs.append(child_reference)
コード例 #4
0
ファイル: actions.py プロジェクト: bartdag/recodoc2
def process_children_matches(text, matches, children, index, single_refs,
        kinds, kinds_hierarchies, save_index, find_context):

    for i, child in enumerate(children):
        content = text[child[0]:child[1]]
        parent_reference = find_parent_reference(child[2], single_refs,
                        kinds_hierarchies)
        child_reference = SingleCodeReference(
                content=content,
                kind_hint=kinds[child[2]],
                child_index=i,
                parent_reference=parent_reference)
        if save_index:
            child_reference.index = index
        if find_context:
            child_reference.sentence = find_sentence(text, child[0],
                    child[1])
            child_reference.paragraph = find_paragraph(text, child[0],
                    child[1])
        child_reference.save()
        single_refs.append(child_reference)