示例#1
0
def test_forward_scope_should_move_right():
    scopes = [Scope('NEG', scope_direction=ScopeDirection.RIGHT, order=1)]
    scoper = Scoper(scopes)

    tokens = ['', '', 'NEG', '', '', '', '', '']

    scope_tags = scoper.tag(tokens)
    assert scope_tags == ['', '', 'NEG', 'NEG', 'NEG', 'NEG', 'NEG', 'NEG']
示例#2
0
def test_backward_scope_should_move_left():
    scopes = [Scope('NEG', scope_direction=ScopeDirection.LEFT, order=1)]
    scoper = Scoper(scopes)

    tokens = ['', '', 'NEG', '', '', '', '', '']

    scope_tags = scoper.tag(tokens)
    assert scope_tags == ['NEG', 'NEG', 'NEG', '', '', '', '', '']
示例#3
0
def test_forward_scope_should_move_both_directions():
    scopes = [
        Scope('NEG', scope_direction=ScopeDirection.TWOWAY, order=1),
    ]
    scoper = Scoper(scopes)

    tokens = ['', '', 'NEG', '', '', '', '', '']

    scope_tags = scoper.tag(tokens)
    assert scope_tags == [
        'NEG', 'NEG', 'NEG', 'NEG', 'NEG', 'NEG', 'NEG', 'NEG'
    ]
示例#4
0
def test_backward_scope_should_stop():
    scopes = [
        Scope('NEG',
              scope_direction=ScopeDirection.LEFT,
              order=1,
              stop_when=['TRANS'])
    ]
    scoper = Scoper(scopes)

    tokens = ['TRANS', 'PHRASE', 'NEG', '', '', '', '', '']

    scope_tags = scoper.tag(tokens)
    assert scope_tags == ['', 'NEG', 'NEG', '', '', '', '', '']
示例#5
0
def test_should_exit_after_max_travel_distance_hit():
    scopes = [
        Scope('NEG',
              scope_direction=ScopeDirection.LEFT,
              order=1,
              stop_when=['TRANS'],
              max_travel_distance=2)
    ]
    scoper = Scoper(scopes)

    tokens = ['TRANS', 'PHRASE', '', '', '', '', 'NEG', '']

    scope_tags = scoper.tag(tokens)
    assert scope_tags == ['', '', '', '', 'NEG', 'NEG', 'NEG', '']