示例#1
0
def test_peek():
    word_list = [('noun', 'princess'), ('stop', 'to')]
    assert_equal(parser.peek(word_list), 'noun')
    word_list.pop(0)
    assert_equal(parser.peek(word_list), 'stop')
    word_list.pop()
    assert_equal(parser.peek(word_list), None)
示例#2
0
def test_peek():
    a_word_list = lexicon.scan("I can't live without you.")
    assert_equal(parser.peek(a_word_list), 'error')
    b_word_list = lexicon.scan("north will be you next aim.")
    assert_equal(parser.peek(b_word_list), 'direction')
    c_word_list = lexicon.scan("go forward, just like I did.")
    assert_equal(parser.peek(c_word_list), 'verb')
    d_word_list = lexicon.scan("bear will not bear everything.")
    assert_equal(parser.peek(d_word_list), 'noun')
示例#3
0
def peek_tests():
    word_list = [('type_a', 'word_a'), ('type_b', 'word_b')]
    assert_equals(parser.peek(word_list), 'type_a')

    word_list = [('type_b', 'word_b')]
    assert_equals(parser.peek(word_list), 'type_b')

    word_list = []
    assert_equals(parser.peek(word_list), None)
示例#4
0
def test_peek():
	a_word_list = lexicon.scan("I can't live without you.")
	assert_equal(parser.peek(a_word_list), 'error')
	b_word_list = lexicon.scan("north will be you next aim.")
	assert_equal(parser.peek(b_word_list), 'direction')
	c_word_list = lexicon.scan("go forward, just like I did.")
	assert_equal(parser.peek(c_word_list), 'verb')
	d_word_list = lexicon.scan("bear will not bear everything.")
	assert_equal(parser.peek(d_word_list), 'noun')
def test_peek():
    word_list = []
    assert None == parser.peek(word_list)

    word_list = lexicon.scan("princess kill bear")

    assert "noun" == parser.peek(word_list)

    assert_equal(parser.peek([('verb', 'run'), ('direction', 'north')]),
                 'verb')
def test_skip():
    word_list = lexicon.scan("the door up in the north")
    parser.skip(word_list, 'noun')
    # should be 'the'
    assert_equal('stop', parser.peek(word_list))
    parser.skip(word_list, 'stop')
    # should be 'door'
    assert_equal('noun', parser.peek(word_list))
    # parser.skip([], None) infinite loop
    parser.skip(word_list, None)
    parser.skip([], {'noun'})
def test_skip():
    word_list = lexicon.scan("the door up in the north")
    parser.skip(word_list, "noun")
    # should be 'the'
    assert_equal("stop", parser.peek(word_list))
    parser.skip(word_list, "stop")
    # should be 'door'
    assert_equal("noun", parser.peek(word_list))
    # parser.skip([], None) infinite loop
    parser.skip(word_list, None)
    parser.skip([], {"noun"})
示例#8
0
def test_peek():
    #one word
    line1 = "bear"
    word_tuples1 = lexicon.scan(line1)
    word_type1 = parser.peek(word_tuples1)
    assert_equal("noun", word_type1)

    #multiple words
    #actually this only check the first word i.e. bear
    line2 = "bear ate the princess"
    word_tuples2 = lexicon.scan(line2)
    assert_equal("noun", parser.peek(word_tuples2)) 
示例#9
0
def test_peek():  #peek returns first word's type
    word_list = lexicon.scan('princess go north to the door')
    print(word_list)
    assert_equal(parser.peek(word_list), 'noun')
    word_list = lexicon.scan('bear go down and eat the princess')
    print(word_list)
    assert_equal(parser.peek(word_list), 'noun')
    word_list = lexicon.scan('go up to open the cabinet')
    print(word_list)
    assert_equal(parser.peek(word_list), 'verb')
    word_list = lexicon.scan('east of the door')
    print(word_list)
    assert_equal(parser.peek(word_list), 'direction')
    assert_equal(parser.peek(None), None)
def test_peek():
    # Test for when there's one token
    word_type = parser.peek([('noun', 'bear')])
    assert_is_not_none(word_type)
    assert_equal('noun', word_type)

    # Test for when there are multiple tokens
    word_type = parser.peek([('noun', 'bear'), ('stop', 'the')])
    assert_is_not_none(word_type)
    assert_equal('noun', word_type)

    # Test for when there are no tokens
    word_type = parser.peek([])
    assert_is_none(word_type)
示例#11
0
def test():
    assert_equal(parser.peek(lexicon.scan('go kill the princess')), 'verb')
    assert_equal(parser.match(lexicon.scan('go kill the princess'), 'verb'),
                 ('verb', 'go'))
    assert_equal(parser.skip(lexicon.scan('go kill the princess'), 'verb'),
                 None)
    assert_equal(parser.parse_verb(lexicon.scan('go kill the princess')),
                 ('verb', 'go'))
    assert_raises(parser.ParserError, parser.parse_verb, ('noun', 'princess'))
    assert_equal(parser.parse_object(lexicon.scan('the princess')),
                 ('noun', 'princess'))
    assert_equal(parser.parse_object(lexicon.scan('the north')),
                 ('direction', 'north'))
    assert_raises(parser.ParserError, parser.parse_object,
                  lexicon.scan('go kill the princess'))
    subj = 'bear'
    assert_equal(
        parser.parse_sentence(
            lexicon.scan('the bear eat the princess')).subject, subj)
    ver = 'eat'
    assert_equal(
        parser.parse_sentence(lexicon.scan('the bear eat the princess')).verb,
        ver)
    obj = 'princess'
    assert_equal(
        parser.parse_sentence(
            lexicon.scan('the bear eat the princess')).object, obj)
示例#12
0
def test_peek():
    assert_equal(parser.peek(lexicon.scan("north")), 'direction')
    assert_equal(parser.peek(lexicon.scan("go")), 'verb')
    assert_equal(parser.peek(lexicon.scan("the")), 'stop')
    assert_equal(parser.peek(lexicon.scan("bear")), 'noun')
    assert_equal(parser.peek(lexicon.scan("55")), 'number')
    assert_equal(parser.peek(lexicon.scan("erheh")), 'error')
示例#13
0
def test_peek():
    assert_equal(parser.peek(lexicon.scan("north")), 'direction')
    assert_equal(parser.peek(lexicon.scan("go")), 'verb')
    assert_equal(parser.peek(lexicon.scan("the")), 'stop')
    assert_equal(parser.peek(lexicon.scan("bear")), 'noun')
    assert_equal(parser.peek(lexicon.scan("55")), 'number')
    assert_equal(parser.peek(lexicon.scan("erheh")), 'error')
示例#14
0
def parse_skip_tests():
    word_list = [('type_a', 'word_a'), ('type_a', 'word_a'), ('type_b', 'word_b')]
    parser.skip(word_list, 'type_a')
    assert_equals(parser.peek(word_list), 'type_b')
    parser.skip(word_list, 'type_b')
    assert_equals(parser.peek(word_list), None)
示例#15
0
def test_peek():
    assert_equal(parser.peek([('verb', 'run')]), 'verb')
    assert_equal(parser.peek([('noun', 'bear'), ('verb', 'eat')]), 'noun')
    assert_equal(parser.peek(None), None)
示例#16
0
def test_seek():
    peak = parser.peek(('test_peak', 'is the second key'))
    assert_equal(peak, 't')
示例#17
0
def test_peek():
    assert_equal(parser.peek([]), None)
    assert_equal(parser.peek([('direction', 'north')]), 'direction')
def test_peek():
    assert_equal(parser.peek(lexi), 'noun')
    assert_equal(parser.peek([]), None)
示例#19
0
def test_peek():
    assert_equal(parser.peek(word_list), 'noun')
示例#20
0
def test_peek():
    result = parser.peek([('verb', 'hit')])
    assert_equal(result, 'verb')
示例#21
0
def test_skip():
    word_list = lexicon.scan('the bear is go to the east')
    # word_list.extend(lexicon.sentence)#拼接字符串
    # print(word_list)
    parser.skip(word_list, 'stop')
    assert_equal(parser.peek(word_list), 'noun')
示例#22
0
def test_peek():
    assert_equal(parser.peek([]), None)
    assert_equal(parser.peek([('noun', 'Boss')]), 'noun')
示例#23
0
def test_peek():
    word_list = lexicon.scan('princess')
    assert_equal(parser.peek(word_list), 'noun')
    assert_equal(parser.peek(None), None)
示例#24
0
def test_peek():
    word_list1 = [("noun", "bear")]
    word_list2 = [("verb", "eat"), ("direction", "north")]
    assert_equal(parser.peek(word_list1), "noun")
    assert_equal(parser.peek(word_list2), "verb")
    assert_equal(parser.peek([]), None)
def test_peek(): #word_list[('noun', 'princess')]
	word_list = lexicon.scan('princess')
	test = parser.peek(word_list)
	assert_equal(test, 'noun')
	assert_equal(None, None)
示例#26
0
def test_peek():
  assert_equal(parser.peek(lexicon.scan(test_sentence)), ('error'))
示例#27
0
def test_parse_object():
    word_list = lexicon.scan("go to the north door")
    next_word = parser.peek(word_list)
    assert_raises(Exception, parser.parse_object, [('verb', "go"),
                                                   ('stop', "to"),
                                                   ('stop', "the")])
示例#28
0
def test_peek():
    assert_equal(parser.peek([]), None)
    assert_equal(parser.peek([('noun', 'Boss')]), 'noun')
示例#29
0
def test_skip():
    word_list = lexicon.scan('the bear is go to the east')
    # word_list.extend(lexicon.sentence)#拼接字符串
    # print(word_list)
    parser.skip(word_list, 'stop')
    assert_equal(parser.peek(word_list), 'noun')
示例#30
0
def test_peek():
	vector = [('verb', 'go')]
	assert_equal(parser.peek(vector), 'verb')
def test_peek():
    word_list = lexicon.scan('princess')
    assert_equal(parser.peek(word_list), 'noun')
    assert_equal(parser.peek(None), None)
示例#32
0
def test_peek():
    assert_equal(parser.peek([['verb', 'go'], ['direction', 'north']]), 'verb')
示例#33
0
def test_peek():
    assert_equal(parser.peek([('stop', '***Yes stop**8'), ('hello', 'Just hello!')]), 'stop')
示例#34
0
def test_peek():
    word_list = lexicon.scan("bear princess")
    result = parser.peek(word_list)
    assert_equal(result, 'noun')
    assert_equal(parser.peek([]), None)
def test_peek():
    assert_equal(parser.peek(lexicon.scan("go")), 'verb')
    result = parser.peek(lexicon.scan("princess"))
    assert_equal(result, 'noun')
示例#36
0
def test_peek():
    assert_equal(parser.peek([('verb', 'run'), ('direction', 'north')]), 'verb')
    assert_equal(parser.peek([('stop', 'the'), ('direction', 'north')]), 'stop')
    peek = parser.peek([])
    assert_equal(peek, None)
示例#37
0
def test_peek():
    word_list = lexicon.scan("bear princess")
    result = parser.peek(word_list)
    assert_equal(result, 'noun')
    assert_equal(parser.peek([]), None)
示例#38
0
def test_peek():
    assert_equal(parser.peek([('direction', 'north')]), 'direction')
    result = parser.peek([('direction', 'north'), ('noun', 'bear')])
    assert_equal(result, 'direction')
    assert_equal(parser.peek([]), None)
示例#39
0
def test_peek():
	blank=[]
	assert_equal(parser.peek(blank),(None))
	assert_equal(parser.peek([('verb', 'eat'), ('stop','a'), ('noun', 'bagel')]), ('verb'))
	assert_equal(parser.peek([('error', 'Purple_monkey_dishwasher')]),('error'))
示例#40
0
def test_peek():
    assert_equal(parser.peek(word_list), 'stop')
    assert_equal([parser.peek(s) for s in PHRASE_LIST], ['verb','noun','verb','error'])
示例#41
0
def test_peek():
	word_list = [('verb', 'go'), ('direction', 'north'), ('stop', 'at'), ('noun', 'door')]
	assert_equal(parser.peek(word_list), 'verb')
	empty_word_list = []
	assert_equal(parser.peek(empty_word_list), None)
示例#42
0
def test_peek():
    assert_equal(parser.peek([('direction', 'north')]), 'direction')
    result = parser.peek([('direction', 'north'), ('verb', 'kill'),
                          ('direction', 'east')])
    assert_equal(result, 'direction')
def test_peek():
    word_list = lexicon.scan("bear eat cabinet")
    assert_equal("noun", parser.peek(word_list))
    word_list = lexicon.scan("eat north")
    assert_equal("verb", parser.peek(word_list))
示例#44
0
def test_skip():
    word_list = lexicon.scan("princess kill bear")
    word_type = ['noun', 'verb', 'noun']
    wrd_type = word_type[0]
    assert_equal(parser.peek(word_list), wrd_type)
示例#45
0
def test_peek():
	assert_equal(parser.peek(word_list), 'stop')
	assert_equal(parser.peek([]), None)
def test_peek():
	s1 = [('noun', 'bear'), ('verb', 'kill'), ('direction', 'north')]
	p1 = parser.peek(s1)
	p2 = parser.peek(s1)
	assert_equal =(p1, 'noun')
	assert_equal = (p2, 'noun')
示例#47
0
def test_peek():
    word_list = []
    word_list = lexicon.scan("princess kill bear")
    word = word_list[0]
    assert_false(parser.peek(None))
    assert_true(parser.peek(word_list))
示例#48
0
def test_peek():
	assert_equal(parser.peek(lexicon.scan("north south east west")), "direction")
	assert_equal(parser.peek(lexicon.scan("moo ias blargh")), 'error')
示例#49
0
def test_parse_verb():
    word_list = lexicon.scan("kill the bear")
    assert_equal(parser.peek(word_list), 'verb')
    assert_raises(Exception, parser.parse_verb, [('stop', "the"),
                                                 ('noun', "bear")])
示例#50
0
def test_peek():
    assert_equal(parser.peek([('verb', 'run')]), 'verb')
    assert_equal(parser.peek([('noun', 'bear'), ('verb', 'eat')]), 'noun')
    assert_equal(parser.peek(None), None)
示例#51
0
def test_parse_subject():
    word_list = "princess kill bear"
    next_word = parser.peek(word_list)
    assert_raises(Exception, parser.parse_subject, [('stop', "the")])
def test_peek():
    sentence = lexicon.scan("eat all the things")
    assert_equal(parser.peek(sentence), "verb")
    assert_equal(parser.peek([]), None)
示例#53
0
def test_peek():
    assert_equal(
        parser.peek([('stop', '***Yes stop**8'), ('hello', 'Just hello!')]),
        'stop')
def test_peek():
    assert_equal(parser.peek(word_list_1), 'noun')
    assert_equal(parser.peek(word_list_2), 'noun')    
    assert_equal(parser.peek(''), None)
示例#55
0
def test_peek():
    word_list = []
    assert None == parser.peek(word_list)

    word_list = lexicon.scan("princess kill bear")
    assert "noun" == parser.peek(word_list)
示例#56
0
def test_peek():
	assert_equal(parser.peek([]), None)
	assert_equal(parser.peek([('verb', 'run')]), 'verb')
	assert_equal(parser.peek(input), 'noun')
	assert_equal(parser.peek(input[1:2]), 'verb')
	assert_equal(parser.peek(input[2:3]), 'stop')