Beispiel #1
0
def test_filter_graph_by_layers():
    p = pipeline.Pipeline(pipeline.create_components(components))
    p.keep_until(['srl'])
    assert p.nb_components() == 5
    p = pipeline.Pipeline(pipeline.create_components(components),
                          goal_layers=['srl'])
    assert p.nb_components() == 5
Beispiel #2
0
def test_filter_input_layers():
    p = pipeline.Pipeline(pipeline.create_components(components),
                          in_layers=['entities', 'coreferences'])
    assert p.nb_components() == 3
    assert 'opin' in p.graph.keys()
    assert 'nerc' in p.graph.keys()
    assert 'coref' in p.graph.keys()
Beispiel #3
0
def test_topological_sort():
    p = pipeline.Pipeline(pipeline.create_components([tok]))
    ptok = p.graph.get_vertex('tok').parents
    assert ptok[0].node.id == 'root'
    schedule = p.topological_sort()
    assert len(schedule) == 1

    p = pipeline.Pipeline(pipeline.create_components([tok, alpino]))
    ctok = p.graph.get_vertex('tok').children
    assert ctok[0].node.id == 'alpino'
    palp = p.graph.get_vertex('alpino').parents
    assert palp[0].node.id == 'tok'
    schedule = p.topological_sort()
    assert len(schedule) == 2

    p = pipeline.Pipeline(pipeline.create_components(components))
    assert p.nb_components() == len(components)
Beispiel #4
0
def test_pipeline_creation():
    ms = pipeline.create_components(components)
    pipe_graph = pipeline.build_pipeline(ms)
    assert len(pipe_graph.keys()) == len(components) + 1  # with root

    p = pipeline.Pipeline(pipeline.create_components(components))
    assert p.nb_components() == len(components)
    assert p.graph.get_vertex('tok').children[0].node.id == 'alpino'
Beispiel #5
0
def test_rescheduling():
    p = pipeline.Pipeline(pipeline.create_components(components))
    schedule = p.topological_sort()
    assert schedule[1].node.id == 'alpino'
    rescheduled = pipeline.reschedule([schedule[0]], schedule[2:])
    assert len(rescheduled) == 0
Beispiel #6
0
def test_cycle():
    p = pipeline.Pipeline(pipeline.create_components(cyclic_components))
    with pytest.raises(ValueError):
        p.topological_sort()
Beispiel #7
0
def test_unconnected_vertices():
    with pytest.raises(ValueError):
        pipeline.Pipeline(pipeline.create_components(unconnected_components))