def test_erros(): assert_equal(lexicon.scan("ASDFADFSDF"), [('error', 'ASDFADFSDF')]) result = lexicon.scan("bear IAS princess") assert_equal(result, [('noun', 'bear'), ('error', 'IAS'), ('noun', 'princess')])
def test_directions(): assert_equal(lexicon.scan("north"), [('direction', 'north')]) result = lexicon.scan("north south east") assert_equal(result, [('direction', 'north'), ('direction', 'south'), ('direction', 'east')])
def test_numbers(): assert_equal(lexicon.scan("1234"), [('number', 1234)]) result = lexicon.scan("3 91234") assert_equal(result, [('number', 3), ('number', 91234)])
def test_nouns(): assert_equal(lexicon.scan("bear"), [('noun', 'bear')]) result = lexicon.scan("bear princess") assert_equal(result, [('noun', 'bear'), ('noun', 'princess')])
def test_stops(): assert_equal(lexicon.scan("the"), [('stop', 'the')]) result = lexicon.scan("the in of") assert_equal(result, [('stop', 'the'), ('stop', 'in'), ('stop', 'of')])
def test_verbs(): assert_equal(lexicon.scan("go"), [('verb', 'go')]) result = lexicon.scan("go kill eat") assert_equal(result, [('verb', 'go'), ('verb', 'kill'), ('verb', 'eat')])
from nose.tools import * from NAME.sentenc import * from NAME import lexicon object_verb = lexicon.scan("bear eat princess") verb = lexicon.scan("go north") verb1 = lexicon.scan("go north") verb_stop = lexicon.scan("go to the north") stop_start1 = lexicon.scan("the of north of") stop_start = lexicon.scan("the of north of") def test_sentence(): sentence = Sentence(("subject", "bear"), ("verb", "eat"), ("object", "princess")) assert_equal(sentence.subject, "bear") assert_equal(sentence.verb, "eat") assert_equal(sentence.object, "princess") def test_peek(): peek_o_v = peek(object_verb) peek_v = peek(verb) peek_v_s = peek(verb_stop) assert_equal(peek_o_v, "noun") assert_equal(peek_v, "verb") assert_equal(peek_v_s, "verb") def test_match(): match_o_v = match(object_verb, "noun")