示例#1
0
def test_CYK_true():
    mycnf = CNF.from_file("cnf.txt")
    input = "ab"
    
    actual = mycnf.CYK(input)
    print(actual)
    
    assert(actual)
示例#2
0
def test_CYK_false():
    mycnf = CNF.from_file("cnf.txt")
    input = "c"
    
    actual = mycnf.CYK(input)
    print(actual)
    
    assert(not actual)
示例#3
0
def test_Azimov_epsilon_2():
    mycnf = CNF.from_file("cnf3.txt")
    g = Graph()
    g.from_trans("hell2.txt")
    
    ans = mycnf.Azimov(g)
    expected = [(0, 0), (0, 1), (0, 3), (0, 4), (1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 3), (4, 4)]
    
    assert(ans == expected)
示例#4
0
def test_Azimov_loop():
    mycnf = CNF.from_file("cnf1.txt")
    g = Graph()
    g.from_trans("hell1.txt")
    
    ans = mycnf.Azimov(g)
    expected = [(0, 0)]
    
    assert(ans == expected)
示例#5
0
def test_Azimov_epsilon():
    mycnf = CNF.from_file("cnf.txt")
    g = Graph()
    g.from_trans("hell.txt")
    
    ans = mycnf.Azimov(g)
    expected = [(0, 0), (0, 2), (1, 1), (2, 2)]
    
    assert(ans == expected)
示例#6
0
def test_Azimov_default():
    mycnf = CNF.from_file("cnf2.txt")
    g = Graph()
    g.from_trans("hell.txt")
    
    ans = mycnf.Azimov(g)
    expected = [(0, 2)]
    
    assert(ans == expected)
示例#7
0
def test_Tenzor_epsilon_2():
    mycnf = CNF.from_file("cnf3.txt")
    g = Graph()
    g.from_trans("hell2.txt")
    
    rec_auto, heads = mycnf.to_recursive_automaton()
    
    ans = mycnf.Tenzor(g, rec_auto, heads)
    expected = [(0, 0), (0, 1), (0, 3), (0, 4), (1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 3), (4, 4)]
    
    assert(ans == expected)
示例#8
0
def test_Tenzor_loop():
    mycnf = CNF.from_file("cnf1.txt")
    g = Graph()
    g.from_trans("hell1.txt")
    
    rec_auto, heads = mycnf.to_recursive_automaton()
    
    ans = mycnf.Tenzor(g, rec_auto, heads)
    expected = [(0, 0)]
    
    assert(ans == expected)
示例#9
0
def test_read_from_file():
    mycnf = CNF.from_file("cnf.txt")
    print(mycnf)
    assert(mycnf.contains("ab") and mycnf.contains("aabb") and mycnf.contains(""))