示例#1
0
def test_match():

    test_list = [('noun', 'princess')]
    test_expecting = 'noun'
    result = parser.match(test_list, test_expecting)
    assert_equal(result, ('noun', 'princess'))

    test_list = [('verb', 'go'),
                ('noun', 'princess'),
                ('direction', 'east')]
    test_expecting = 'verb'
    result = parser.match(test_list, test_expecting)    
    assert_equal(result, ('verb', 'go'))

    test_list = [('verb', 'go'),
                ('noun', 'princess'),
                ('direction', 'east')]
    test_expecting = 'stop'
    result = parser.match(test_list, test_expecting)    
    assert_equal(result, None)

    test_list = []
    test_expecting = 'stop'
    result = parser.match(test_list, test_expecting)
    assert_equal(result, None)
示例#2
0
def test_match():
    word_list = []
    assert None == parser.match(word_list, 'noun')

    word_list = lexicon.scan("bear eat princess")
    assert_equal(('noun', "bear"), parser.match(word_list, 'noun'))
    assert_equal(None, parser.match(word_list, 'noun'))
示例#3
0
def test_match():
    assert_equal(parser.match(lexicon.scan("kill stop bear"), "verb"),
                 ('verb', 'kill'))
    assert_equal(parser.match(lexicon.scan("Eat kill bear"), "verb"),
                 ('verb', 'Eat'))
    assert_equal(parser.match(lexicon.scan("kill stop bear"), "stop"), None)
    assert_equal(parser.match(lexicon.scan("bear walks in woods"), "noun"),
                 ('noun', 'bear'))
def test_match():
    words = ['one', 'two', 'three']
    scanner = lexicon.scan("bear go north")

    assert_equal(parser.match(words, 'o'), 'one')
    assert_equal(parser.match(scanner, 'noun'), ('noun', 'bear'))
    assert_equal(parser.match(scanner, None), None)
    assert_equal(parser.match(None, 'noun'), None)
    assert_equal(parser.match(None, None), None)
def test_match():
    word_list = []

    assert None == parser.match(word_list, 'noun')

    word_list = lexicon.scan('princess kill bear')
    assert ('noun', 'princess') == parser.match(word_list, 'noun')

    word_list = lexicon.scan('princess kill bear')
    assert None == parser.match(word_list, 'verb')
示例#6
0
def test_match():
    assert_equal(parser.match([('direction', 'north')], 'direction'),
                 ('direction', 'north'))
    assert_equal(parser.match([('direction', 'north')], 'verb'), None)
    assert_equal(
        parser.match([('verb', 'go'), ('direction', 'north')], 'verb'),
        ('verb', 'go'))
    assert_equal(
        parser.match([('stop', 'of'), ('number', 1234), ('noun', 'princess')],
                     'stop'), ('stop', 'of'))
    assert_equal(
        parser.match([('stop', 'of'), ('number', 1234), ('noun', 'princess')],
                     'verb'), None)
def test_match():
    # test an empty word_list returns None
    word_list = ()
    assert_equal(parser.match(word_list, 'verb'), None)
    
    # test a none empty word list but with a none matching word type returns None
    word_list = [('verb', 'run')]
    assert_equal(parser.match(word_list, 'noun'), None)
    
    # test a none empty word list with a matching word type returns correct word tuple and also pops off the word tuple
    word_list = [('verb', 'run'), ('noun', 'bear')]
    assert_equal(parser.match(word_list, 'verb'), ('verb', 'run'))
    assert_equal(parser.match(word_list, 'noun'), ('noun', 'bear'))
示例#8
0
def test_match():
	# matching with a list with 0 items
	assert_equal(parser.match([], "verb"), None)

	# matching with a list with 1 item (items are poped when match found 
	# -> list need to be reconstructed)
	word_list = lexicon.scan("north")
	assert_equal(parser.match(word_list, "direction"), ("direction", "north"))
	word_list = lexicon.scan("north")
	assert_equal(parser.match(word_list, "noun"), None)

	# matching with a list with many items
	word_list = lexicon.scan("haha go up quickly")
	assert_equal(parser.match(word_list, "error"), ("error", "haha"))
	word_list = lexicon.scan("haha go up quickly")
	assert_equal(parser.match(word_list, "verb"), None)
示例#9
0
def test_match():

    test_list = [('noun', 'princess')]
    test_expecting = 'noun'
    result = parser.match(test_list, test_expecting)
    assert_equal(result, ('noun', 'princess'))

    test_list = [('verb', 'go'), ('noun', 'princess'), ('direction', 'east')]
    test_expecting = 'verb'
    result = parser.match(test_list, test_expecting)
    assert_equal(result, ('verb', 'go'))

    test_list = [('verb', 'go'), ('noun', 'princess'), ('direction', 'east')]
    test_expecting = 'stop'
    result = parser.match(test_list, test_expecting)
    assert_equal(result, None)

    test_list = []
    test_expecting = 'stop'
    result = parser.match(test_list, test_expecting)
    assert_equal(result, None)
示例#10
0
def test_match():
    word_list = lexicon.scan('eat the bear bla')
    assert_equal(parser.match(word_list, 'verb'), ('verb', 'eat'))
    assert_equal(parser.match(word_list, 'noun'), None)
    assert_equal(parser.match([], 'verb'), None)
def test_match():
    word_list = [('noun', 'player')]
    assert_equal(parser.match(word_list, 'noun'), 'player')
    assert_equal(parser.match(None, 'noun'), None)
def test_match():
	word_list = [('noun', 'player')]
	assert_equal(parser.match(word_list, 'noun'), 'player')
	assert_equal(parser.match(None, 'noun'), None)
示例#13
0
def test_match():
    
    assert_equal(parser.match(word_list, word_type), ('verb', 'open'))
示例#14
0
def test_match():
	assert_equal(parser.match([('noun', 'princess')], 'noun'), ('noun', 'princess'))
示例#15
0
def testing_match():
    '''testing the match function.'''
    word_list = lexicon.scan('bear')
    assert_equal(parser.match(word_list, 'noun'), ('noun', 'bear'))
    assert_equal(parser.match(word_list, 'direction'), None)
    assert_equal(parser.match(None, 'verb'), None)
示例#16
0
def test_match():
    assert_equal(parser.match([('verb', 'kill')], 'verb'), ('verb', 'kill'))
    assert_equal(parser.match([('noun', 'carrbinet')], 'noun'), ('noun', 'carrbinet'))
    assert_equal(parser.match(None, 'verb'), None)
    assert_equal(parser.match([('verb', 'like')], 'noun'), None)
示例#17
0
def test_bad_match():
    x = parser.match([("noun", "bear")], "verb")
    assert_equal(x, None)
示例#18
0
def test_match():
    word_list = lexicon.scan("princess")
    assert_equal(parser.match(word_list, "noun"), ("noun", "princess"))
    assert_equal(parser.match(word_list, "stop"), None)
    assert_equal(parser.match(None, "noun"), None)
def TestMatch():
    inputsent = lexicon.scan("bear eat castle")
    assert_equal(('noun', 'bear'), parser.match(inputsent, 'noun'))
    assert_equal(None, parser.match(None, ''))
    assert_equal(None, parser.match(inputsent, 'failhere'))
示例#20
0
def test_match():
    word_list = lexicon.scan("bear eat cake")
    assert_equal(parser.match(word_list,"noun"),("noun","bear"))
    assert_equal(parser.match(word_list,"noun"),None)
    assert_equal(parser.match(None,"noun"),None)
示例#21
0
def test_match():
    word_list = [('noun', 'Dog'), ('verb', 'ran'), ('stop', 'to'), ('stop', 'the'), ('noun', 'cow')]
    assert_equal(parser.match(word_list, 'noun'), ('noun', 'Dog'))
示例#22
0
def test_match():
    assert_equal(parser.match([('direction', 'up')], 'direction'),
                 ('direction', 'up'))
    assert_equal(parser.match([('something', 'nope')], 'nah'), None)
示例#23
0
def test_match():
	word_list = lexicon.scan(sentence)
	assert_equal(parser.match(word_list, 'noun'), ('noun', 'princess'))
def test_match():
    word_list = lexicon.scan("open the door")
    assert_equal(parser.match(word_list, "verb"), ("verb", "open"))
    assert_equal(word_list, [("stop", "the"), ("noun", "door")])
示例#25
0
def test_match():
    wordlist = wordlist = [("verb", "kill"), ("stop", "the"),
                           ("noun", "princess")]
    assert_equal(parser.match(wordlist, "verb"), ("verb", "kill"))
    assert_equal(parser.match(wordlist, "stop"), ("stop", "the"))
    assert_equal(parser.match(wordlist, "run"), None)
示例#26
0
def test_match():
    x = parser.match([("noun", "bear")], "noun")
    assert_equal(x, ("noun", "bear"))
示例#27
0
def test_match():
  test = [('noun', 'bear')]
  assert_equal(parser.match(test, 'noun'), ('noun', 'bear'))
  assert_equal(parser.match(test, 'stop'), None)
  assert_equal(parser.match(None, 'noun'), None)
def test_match():
    word_list = lexicon.scan("open the door")
    assert_equal(parser.match(word_list, 'verb'), ('verb', 'open'))
    assert_equal(word_list, [('stop', 'the'), ('noun', 'door')])
示例#29
0
def test_match():
    word_list = lexicon.scan('princess')
    assert_equal(parser.match(word_list, 'noun'), ('noun', 'princess'))
    assert_equal(parser.match(word_list, 'stop'), None)
    assert_equal(parser.match(None, 'noun'), None)
示例#30
0
def test_match():
    assert_equal(parser.match([], 'verb'), None)  # Nothing expected
    result = parser.match([('verb', 'run'), ('direction', 'north')], 'verb')
    assert_equal(result, ('verb', 'run'))
    result = parser.match([('verb', 'run'), ('direction', 'north')], 'noun')
    assert result == None
示例#31
0
def test_match():
    word_list = lexicon.scan('princess')
    assert_equal(parser.match(word_list, 'noun'), ('noun', 'princess'))
    assert_equal(parser.match(word_list, 'stop'), None)
    assert_equal(parser.match(None, 'noun'), None)
def test_match():
	result = lexicon.scan("bear eat the xxx eat ... bear")
	sen = parser.match(result, "noun")
	assert_equal(sen, ("noun", "bear"))