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')])
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')])
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')])
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"})
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_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, [])
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')
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')])
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)
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')
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')])
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(): blank=[] sentence = [('verb', 'eat'), ('stop', 'a'), ('noun', 'bagel')] parser.skip(sentence, 'verb') assert_equal(sentence, [('stop', 'a'),('noun', 'bagel')])
def test_skip(): test_sentence = lexicon.scan("in the north") result = parser.skip(test_sentence, 'stop') assert_equal(test_sentence, [('direction', 'north')])
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')])
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)
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')])
def test_skip(): word_list1 = lexicon.scan("open the door") result = parser.skip(word_list1, 'stop') assert_equal(result, None)
def test_skip(): assert_equal(parser.skip(word_list, 'noun'), None)
def test_skip(): assert_equal(parser.skip([['verb', 'go'], ['direction', 'north']], 'verb'), ['verb', 'go'])
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')
def test_skip(): wordlist = [('stop', 'the'), ('noun', 'bear')] result = parser.skip(wordlist, 'stop') assert_equal(result, None) assert_equal(wordlist, [('noun', 'bear')])
def test_skip(): assert_equal(parser.skip([('stop', 'the'), ('direction', 'north')], 'stop'), None)
def test_skip(): assert_equal(parser.skip(word_list,'stop'),None)
def test_skip_with_no_matches(): wordlist = [('stop', 'the')] result = parser.skip(wordlist, 'noun') assert_equal(result, None) assert_equal(wordlist, [('stop', 'the')])
def test_skip(): word_list = [('stop', 'the'), ('noun', 'princess')] assert_equal(parser.skip(word_list, 'stop'), None) assert_equal(word_list, [('noun', 'princess')])
def test_skip(): word_list = lexicon.scan("the bear eat princess") parser.skip(word_list, 'stop') print(word_list, ">>>>ignore here")
def test_skip(): assert_equal(parser.skip([('verb', 'kill')], 'verb'), ('verb', 'kill'))
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')])
def test_skip(): assert_equal(parser.skip(word_list1, 'stop'), None)
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)
def test_skip(self): word_list = [('stop', 'the'), ('noun', 'floor')] parser.skip(word_list, 'stop') self.assertEqual(word_list, [('noun', 'floor')])
def test_skip(): word_list = [('noun', 'princess'), ('verb', 'throws'), ('object', 'coins')] skip_working = parser.skip(word_list, 'noun')