Exemplo n.º 1
0
def test_skip():
    assert_equal(parser.skip([],''), None)
    word_list = [('stop', 'the'),
                 ('stop', 'slow'),
                 ('verb', 'kill')]
    parser.skip(word_list, 'stop')
    assert_equal(word_list, [('verb', 'kill')])
Exemplo n.º 2
0
def test_skip():
    word_list = [('noun', 'player'), ('noun', 'princess'), ('stop', 'to')]
    parser.skip(word_list, 'stop')
    assert_equal(word_list, [('noun', 'player'), ('noun', 'princess'),
                             ('stop', 'to')])
    parser.skip(word_list, 'noun')
    assert_equal(word_list, [('stop', 'to')])
def test_skip():
    word_list = [('direction', 'north'), ('direction', 'sound')]
    parser.skip(word_list, 'direction')
    assert_equal(word_list, [])

    word_list2 = [('direction', 'north'), ('noun', 'princess'), ('direction', 'sound')]
    parser.skip(word_list2, 'direction')
    assert_equal(word_list2, [('noun', 'princess'), ('direction', 'sound')])
Exemplo n.º 4
0
def test_skip():
    wl1 = lexicon.scan("at the bear")
    parser.skip(wl1, 'stop')
    print(wl1)
    assert [('noun', "bear")] == wl1

    wl2 = lexicon.scan("scream at the bear")
    parser.skip(wl2, 'stop')
    print(wl2)
def test_skip():
    # test a standard use case
    sentence = lexicon.scan("the the in of go the")
    parser.skip(sentence, 'stop')
    assert_equal(sentence, [('verb', 'go'), ('stop', 'the')])

    # a case where nothing should happen
    sentence = lexicon.scan("the the in of go the")
    result = lexicon.scan("the the in of go the")
    parser.skip(sentence, 'verb')
    assert_equal(sentence, result)
def test_skip():
    word_list = [('stop', 'of'), ('stop', 'the'), ('direction', 'north')]
    result = parser.skip(word_list, 'stop')

    assert_equal(result, None)
    assert_equal(word_list, [('direction', 'north')])

    word_list2 = [('stop', 'of'), ('stop', 'the'), ('direction', 'north')]
    result2 = parser.skip(word_list2, 'stop')

    assert_equal(result2, None)
    assert_equal(word_list2, [('direction', 'north')])
Exemplo n.º 7
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)
def test_skip():
    word_list = [('verb', 'kill'),
                 ('stop', 'the'),
                 ('noun', 'bear')]

    word = parser.skip(word_list, 'verb')
    assert_equal(2, len(word_list))
    assert_equal([('stop', 'the'), ('noun', 'bear')], word_list)
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"})
Exemplo n.º 10
0
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'})
Exemplo n.º 11
0
def test_skip():
    word_list1 = [("verb", "eat"), ("direction", "north")]
    word_list2 = [("verb", "eat"), ("stop", "the"), ("stop", "at")]
    word_list3 = [("verb", "eat"), ("verb", "go"), ("noun", "bear")]
    word_list4 = []
    parser.skip(word_list1, "stop")
    parser.skip(word_list2, "stop")
    parser.skip(word_list3, "verb")
    parser.skip(word_list4, "verb")
    assert_equal(word_list1, [("verb", "eat"), ("direction", "north")])
    assert_equal(word_list2, [("verb", "eat"), ("stop", "the"),
                              ("stop", "at")])
    assert_equal(word_list3, [("noun", "bear")])
    assert_equal(word_list4, [])
Exemplo n.º 12
0
def test_skip():
    #word_list = []
    #assert None == parser.skip(word_list, 'stop')
    word_list = lexicon.scan("Bear kill the princess")
    print("WORD_LIST is ", word_list)
    #print("PEEK is ", parser.peek(word_list))
    #print("MATCH is", parser.match(word_list, 'noun'))
    #print("SKIP is ", parser.skip(word_list, 'noun'))
    assert ('noun', 'Bear') == parser.match(word_list, 'noun')
    assert ('verb', 'kill') == parser.match(word_list, 'verb')
    assert ('stop', 'the') == parser.match(word_list, 'stop')
    assert ('noun', 'princess') == parser.match(word_list, 'noun')
    assert None == parser.skip(word_list, 'stop')
Exemplo n.º 13
0
def test_skip():  #skip returns the first word's type and content
    word_list = lexicon.scan('bear eat door')
    parser.skip(word_list,
                'noun')  #if first is type, skip it, if not, stay the same
    assert_equal(word_list, [('verb', 'eat'), ('noun', 'door')])
    word_list = lexicon.scan('eat door')
    parser.skip(word_list,
                'noun')  #if first is type, skip it, if not, stay the same
    assert_equal(word_list, [('verb', 'eat'), ('noun', 'door')])
    word_list = lexicon.scan('east eat door')
    parser.skip(word_list,
                'noun')  #if first is type, skip it, if not, stay the same
    assert_equal(word_list, [('direction', 'east'), ('verb', 'eat'),
                             ('noun', 'door')])
    word_list = lexicon.scan('the eat door')
    parser.skip(word_list, 'stop')
    assert_equal(word_list, [('verb', 'eat'), ('noun', 'door')])
Exemplo n.º 14
0
def test_skip():
	vector = lexicon.scan('the')
	parser.skip(vector, 'stop')
	assert_equal(vector, [])
	vector2 = lexicon.scan('bear IAS princess')
	assert_equal(vector2, [('noun','bear'),
							('error','IAS'),
							('noun','princess')])
	parser.skip(vector2, 'noun')
	assert_equal(vector2, [('error','IAS'),
							('noun','princess')])
	parser.skip(vector2, 'error')
	assert_equal(vector2, [('noun','princess')])
def test_skip():
    #skip doesn't return anything
    assert_equal(parser.skip(word_list_2, 'noun'), None)
Exemplo n.º 16
0
def test_skip():
    #one word
    line1 = "bear"
    word_tuples1 = lexicon.scan(line1)
    parser.skip(word_tuples1, "verb")
    assert_equal(1, len(word_tuples1))
    parser.skip(word_tuples1, 'noun')
    assert_equal(0, len(word_tuples1))

    #multiple words
    line2 = "princess eat the princess" # eww
    word_tuples2 = lexicon.scan(line2)
    assert_equal(4, len(word_tuples2))
    parser.skip(word_tuples2, "verb")
    assert_equal(4, len(word_tuples2)) # no change
    parser.skip(word_tuples2, "noun")
    assert_equal(3, len(word_tuples2)) # chopped one i.e. princess
    parser.skip(word_tuples2, "verb")
    assert_equal(2, len(word_tuples2)) # chopped one i.e. eat 
    parser.skip(word_tuples2, "verb")
    assert_equal(2, len(word_tuples2)) # chopped none  
    parser.skip(word_tuples2, "stop")
    assert_equal(1, len(word_tuples2)) # chopped one i.e. the   
def test_skip(): #word_list[('stop', 'the')]
	word_list = lexicon.scan('the')
	s = parser.skip(word_list, word_type='stop')
	assert_equal = (parser.skip(word_list, word_type='stop'), 'stop')
Exemplo n.º 18
0
def test_skip():
    assert_equal(parser.skip([], ''), None)
    word_list = [('stop', 'the'), ('stop', 'slow'), ('verb', 'kill')]
    parser.skip(word_list, 'stop')
    assert_equal(word_list, [('verb', 'kill')])
Exemplo n.º 19
0
def test_skip():
     word_list = [('stop', 'will'), ('stop', 'the'), ('noun', 'bear')]
     
     parser.skip(word_list, 'stop')
     match = parser.match(word_list, 'noun')
     assert_equal(match, ('noun', 'bear'))
Exemplo n.º 20
0
def test_skip():
	blank=[]
	sentence = [('verb', 'eat'), ('stop', 'a'), ('noun', 'bagel')]
	parser.skip(sentence, 'verb')
	assert_equal(sentence, [('stop', 'a'),('noun', 'bagel')])
Exemplo n.º 21
0
def test_skip():
    test_sentence = lexicon.scan("in the north")
    result = parser.skip(test_sentence, 'stop')
    assert_equal(test_sentence, [('direction', 'north')])
Exemplo n.º 22
0
def test_skip():
	word_list = [('verb', 'go'), ('direction', 'north'), ('stop', 'at'), ('noun', 'door')]
	parser.skip(word_list, 'verb')
	assert_equal(word_list, [('direction', 'north'), ('stop', 'at'), ('noun', 'door')])
Exemplo n.º 23
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)
Exemplo n.º 24
0
def test_skip():
    word_list = lexicon.scan('bear eat door')
    assert_equal(word_list, [('noun', 'bear'), ('verb', 'eat'),
                             ('noun', 'door')])
    parser.skip(word_list, 'noun')
    assert_equal(word_list, [('verb', 'eat'), ('noun', 'door')])
Exemplo n.º 25
0
def test_skip():

    word_list1 = lexicon.scan("open the door")
    result = parser.skip(word_list1, 'stop')
    assert_equal(result, None)
Exemplo n.º 26
0
def test_skip():
    assert_equal(parser.skip(word_list, 'noun'), None)
Exemplo n.º 27
0
def test_skip():
    assert_equal(parser.skip([['verb', 'go'], ['direction', 'north']], 'verb'),
                 ['verb', 'go'])
Exemplo n.º 28
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')
Exemplo n.º 29
0
def test_skip():
    wordlist = [('stop', 'the'), ('noun', 'bear')]
    result = parser.skip(wordlist, 'stop')
    assert_equal(result, None)
    assert_equal(wordlist, [('noun', 'bear')])
Exemplo n.º 30
0
def test_skip():
    assert_equal(parser.skip([('stop', 'the'), ('direction', 'north')], 'stop'), None)
Exemplo n.º 31
0
def test_skip():
    assert_equal(parser.skip(word_list,'stop'),None)
Exemplo n.º 32
0
def test_skip_with_no_matches():
    wordlist = [('stop', 'the')]
    result = parser.skip(wordlist, 'noun')
    assert_equal(result, None)
    assert_equal(wordlist, [('stop', 'the')])
Exemplo n.º 33
0
def test_skip():
    word_list = [('stop', 'the'), ('noun', 'princess')]
    assert_equal(parser.skip(word_list, 'stop'), None)
    assert_equal(word_list, [('noun', 'princess')])
Exemplo n.º 34
0
def test_skip():
    word_list = lexicon.scan("the bear eat princess")
    parser.skip(word_list, 'stop')
    print(word_list, ">>>>ignore here")
Exemplo n.º 35
0
def test_skip():
	assert_equal(parser.skip([('verb', 'kill')], 'verb'), ('verb', 'kill'))
Exemplo n.º 36
0
def test_skip():
    raw_word_list = [('oh', 'run'), ('oh', 'go'), ('direction', 'up')]
    parser.skip(raw_word_list, 'oh')
    assert_equal(raw_word_list, [('direction', 'up')])
Exemplo n.º 37
0
def test_skip():
    assert_equal(parser.skip(word_list1, 'stop'), None)
Exemplo n.º 38
0
def test_skip():
    assert_equal(parser.skip([('direction', 'north')], 'direction'), None)
    result = parser.skip([('stop', 'the'), ('stop', 'in'),
                          ('direction', 'north'), ('direction', 'north')],
                         'stop')
    assert_equal(result, None)
Exemplo n.º 39
0
 def test_skip(self):
     word_list = [('stop', 'the'), ('noun', 'floor')]
     parser.skip(word_list, 'stop')
     self.assertEqual(word_list, [('noun', 'floor')])
Exemplo n.º 40
0
def test_skip():
    word_list = [('stop', 'will'), ('stop', 'the'), ('noun', 'bear')]

    parser.skip(word_list, 'stop')
    match = parser.match(word_list, 'noun')
    assert_equal(match, ('noun', 'bear'))
def test_skip():
    word_list = lexicon.scan('bear eat door')
    assert_equal(word_list, [('noun', 'bear'), ('verb', 'eat'), ('noun', 'door')])
    parser.skip(word_list, 'noun')
    assert_equal(word_list, [('verb', 'eat'), ('noun', 'door')])
Exemplo n.º 42
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')
Exemplo n.º 43
0
def test_skip():
   word_list = [('noun', 'princess'), ('verb', 'throws'), ('object', 'coins')]
   skip_working = parser.skip(word_list, 'noun')