コード例 #1
0
ファイル: test_ae.py プロジェクト: xgeric/redshift
def test_init_valid(string):
    state = PyState(string)
    assert state.is_valid('S')
    assert not state.is_valid('D')
    assert not state.is_valid('R-OBJ')
    assert not state.is_valid('L-SUBJ')
コード例 #2
0
ファイル: test_ae.py プロジェクト: xgeric/redshift
def test_right_valid(string):
    state = PyState(string, transitions=['S'])
    assert state.is_valid('R-OBJ')
コード例 #3
0
ファイル: test_ae.py プロジェクト: xgeric/redshift
def test_sunk_left(string, gold):
    state = PyState(string, gold=gold)
    state.transition('S')
    state.transition('L-SUBJ')
    state.transition('S')
    state.transition('S')
    assert not state.is_gold('S')
    state.transition('S')
    # Now have (is, a, test) on stack --- this is wrong
    assert state.is_gold('L-SUBJ')
    assert state.is_gold('L-ROOT')
    assert state.is_gold('L-OTHER')
    assert not state.is_gold('R-OTHER')
    assert not state.is_gold('R-OBJ')
    assert not state.is_gold('D')
    assert not state.is_gold('S')
    state.transition('L-SUBJ')
    assert state.is_gold('L-SUBJ')
    assert state.is_gold('L-ROOT')
    assert state.is_gold('L-OTHER')
    state.transition('L-ROOT')
    assert state.top == 2
    assert state.is_gold('R-OTHER')
コード例 #4
0
ファイル: test_ae.py プロジェクト: xgeric/redshift
def test_sunk_right(string, gold):
    state = PyState(string, gold=gold)
    state.transition('S')
    assert state.top == 1
    assert not state.is_gold('R-OBJ')
    assert state.top == 1
    state.transition('R-OBJ')
    assert state.top == 2
    assert not state.is_gold('D')
    state.transition('D')
    assert not state.is_gold('R-OBJ')
    state.transition('R-OBJ')
    assert state.is_gold('D')
    assert not state.is_gold('L-OTHER')
    assert not state.is_valid('L-OTHER')
コード例 #5
0
ファイル: test_ae.py プロジェクト: xgeric/redshift
def test_init_oracle(string, gold):
    state = PyState(string, gold=gold)
    assert state.is_gold('S')
    assert not state.is_gold('D')
    assert not state.is_gold('R-OBJ')
    assert not state.is_gold('L-SUBJ')
コード例 #6
0
ファイル: test_ae.py プロジェクト: DennisDeSwart/redshift
def test_init_valid(string):
    state = PyState(string)
    assert state.is_valid('S')
    assert not state.is_valid('D')
    assert not state.is_valid('R-OBJ')
    assert not state.is_valid('L-SUBJ')
コード例 #7
0
ファイル: test_ae.py プロジェクト: DennisDeSwart/redshift
def test_left_invalid(string):
    state = PyState(string, transitions=['S', 'R-OBJ'])
    assert not state.is_valid('L-SUBJ')
コード例 #8
0
ファイル: test_ae.py プロジェクト: xgeric/redshift
def test_reduce_valid(string):
    state = PyState(string, transitions=['S', 'R-OBJ'])
    assert state.is_valid('D')
コード例 #9
0
ファイル: test_ae.py プロジェクト: DennisDeSwart/redshift
def test_reduce_invalid(string):
    state = PyState(string, transitions=['S'])
    assert not state.is_valid('D')
コード例 #10
0
ファイル: test_ae.py プロジェクト: DennisDeSwart/redshift
def test_reduce_valid(string):
    state = PyState(string, transitions=['S', 'R-OBJ'])
    assert state.is_valid('D')
コード例 #11
0
ファイル: test_ae.py プロジェクト: DennisDeSwart/redshift
def test_left_valid(string):
    state = PyState(string, transitions=['S'])
    assert state.is_valid('L-SUBJ')
コード例 #12
0
ファイル: test_ae.py プロジェクト: DennisDeSwart/redshift
def test_right_valid(string):
    state = PyState(string, transitions=['S'])
    assert state.is_valid('R-OBJ')
コード例 #13
0
ファイル: test_ae.py プロジェクト: DennisDeSwart/redshift
def test_sunk_right(string, gold):
    state = PyState(string, gold=gold)
    state.transition('S')
    assert state.top == 1
    assert not state.is_gold('R-OBJ')
    assert state.top == 1
    state.transition('R-OBJ')
    assert state.top == 2
    assert not state.is_gold('D')
    state.transition('D')
    assert not state.is_gold('R-OBJ')
    state.transition('R-OBJ')
    assert state.is_gold('D')
    assert not state.is_gold('L-OTHER')
    assert not state.is_valid('L-OTHER')
コード例 #14
0
ファイル: test_ae.py プロジェクト: xgeric/redshift
def test_left_valid(string):
    state = PyState(string, transitions=['S'])
    assert state.is_valid('L-SUBJ')
コード例 #15
0
ファイル: test_ae.py プロジェクト: DennisDeSwart/redshift
def test_init_oracle(string, gold):
    state = PyState(string, gold=gold)
    assert state.is_gold('S')
    assert not state.is_gold('D')
    assert not state.is_gold('R-OBJ')
    assert not state.is_gold('L-SUBJ')
コード例 #16
0
ファイル: test_ae.py プロジェクト: xgeric/redshift
def test_reduce_invalid(string):
    state = PyState(string, transitions=['S'])
    assert not state.is_valid('D')
コード例 #17
0
ファイル: test_ae.py プロジェクト: DennisDeSwart/redshift
def test_gold_reduce_oracle(string, gold):
    state = PyState(string, gold=gold)
    state.transition('S')
    state.transition('L-SUBJ')
    state.transition('S')
    state.transition('S')
    state.transition('L-OTHER')
    state.transition('R-OBJ')
    assert not state.is_gold('R-OTHER')
    assert not state.is_gold('S')
    assert state.is_gold('D')
    assert not state.is_gold('L-ROOT')
    assert not state.is_gold('R-OBJ')
コード例 #18
0
ファイル: test_ae.py プロジェクト: xgeric/redshift
def test_left_invalid(string):
    state = PyState(string, transitions=['S', 'R-OBJ'])
    assert not state.is_valid('L-SUBJ')
コード例 #19
0
ファイル: test_edit_ae.py プロジェクト: xgeric/redshift
def state(string, gold):
    return PyState(string, gold=gold, left_labels=[b'DET', b'ROOT', b'OTHER'],
                   right_labels=[b'OBJ', b'OTHER'], dfl_labels=[b'FILL', b'ERASE'])
コード例 #20
0
ファイル: test_ae.py プロジェクト: xgeric/redshift
def test_gold_reduce_oracle(string, gold):
    state = PyState(string, gold=gold)
    state.transition('S')
    state.transition('L-SUBJ')
    state.transition('S')
    state.transition('S')
    state.transition('L-OTHER')
    state.transition('R-OBJ')
    assert not state.is_gold('R-OTHER')
    assert not state.is_gold('S')
    assert state.is_gold('D')
    assert not state.is_gold('L-ROOT')
    assert not state.is_gold('R-OBJ')
コード例 #21
0
ファイル: test_ae.py プロジェクト: DennisDeSwart/redshift
def test_sunk_left(string, gold):
    state = PyState(string, gold=gold)
    state.transition('S')
    state.transition('L-SUBJ')
    state.transition('S')
    state.transition('S')
    assert not state.is_gold('S')
    state.transition('S')
    # Now have (is, a, test) on stack --- this is wrong
    assert state.is_gold('L-SUBJ')
    assert state.is_gold('L-ROOT')
    assert state.is_gold('L-OTHER')
    assert not state.is_gold('R-OTHER')
    assert not state.is_gold('R-OBJ')
    assert not state.is_gold('D')
    assert not state.is_gold('S')
    state.transition('L-SUBJ')
    assert state.is_gold('L-SUBJ')
    assert state.is_gold('L-ROOT')
    assert state.is_gold('L-OTHER')
    state.transition('L-ROOT')
    assert state.top == 2
    assert state.is_gold('R-OTHER')