Beispiel #1
0
def test_nouns():
	a=lexicon()
	assert_equal(a.scan("bear"), [('noun', 'bear')])
	b=lexicon()
	result =b.scan("bear princess")
	assert_equal(result, [('noun', 'bear'),
						  ('noun', 'princess')])
Beispiel #2
0
def test_numbers():
	a=lexicon()
	assert_equal(a.scan("1234"), [('number',1234)])
	b=lexicon()
	result =b.scan("3 91234")
	assert_equal(result, [('number',3),
						  ('number',91234)])
Beispiel #3
0
def test_errors():
	a=lexicon()
	assert_equal(a.scan("asdfadfasdf"), [('error', 'asdfadfasdf')])
	b=lexicon()
	result =b.scan("bear ias princess")
	assert_equal(result, [('noun', 'bear'),
						  ('error', 'ias'),
						  ('noun', 'princess')])
Beispiel #4
0
def test_verbs():
	a=lexicon()
	assert_equal(a.scan("go"), [('verb', 'go')])
	b=lexicon()
	result =b.scan("go kill eat")
	assert_equal(result, [('verb', 'go'),
						  ('verb', 'kill'),
						  ('verb', 'eat')])
Beispiel #5
0
def test_stops():
	a=lexicon()
	assert_equal(a.scan("the"), [('stop', 'the')])
	b=lexicon()
	result =b.scan("the in of")
	assert_equal(result, [('stop', 'the'),
						  ('stop', 'in'),
						  ('stop', 'of')])
Beispiel #6
0
def test_stops():
    lex = lexicon()
    assert_equal(lex.scan("the"), [('stop', 'the')])
    result = lex.scan("the in of")
    assert_equal(result, [('stop', 'the'),
                          ('stop', 'in'),
                          ('stop', 'of')])
Beispiel #7
0
def test_errors():
    lex = lexicon()
    assert_equal(lex.scan("ASDFADFASDF"), [('error', 'ASDFADFASDF')])
    result = lex.scan("bear IAS princess")
    assert_equal(result, [('noun', 'bear'),
                          ('error', 'IAS'),
                          ('noun', 'princess')])
Beispiel #8
0
def test_directions():
  lex = lexicon()
  assert_equal(lex.scan("north"), [('direction', 'north')])
  result = lex.scan("north south east")
  assert_equal(result, [('direction', 'north'),
                        ('direction', 'south'),
                        ('direction', 'east')])
Beispiel #9
0
def test_verbs():
    lex = lexicon()
    assert_equal(lex.scan("go"), [('verb', 'go')])
    result = lex.scan("go kill eat")
    assert_equal(result, [('verb', 'go'),
                          ('verb', 'kill'),
                          ('verb', 'eat')])
Beispiel #10
0
from nose.tools import *
from ex48.lexicon import lexicon

lexicon = lexicon()


def test_direction():
    assert_equal(lexicon.scan("north"), [('direction', 'north')])
    result = lexicon.scan("north south east")
    assert_equal(result, [('direction', 'north'), ('direction', 'south'),
                          ('direction', 'east')])


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')])


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_nouns():
    assert_equal(lexicon.scan("bear"), [('noun', 'bear')])
    result = lexicon.scan("bear princess")
    assert_equal(result, [('noun', 'bear'), ('noun', 'princess')])

Beispiel #11
0
def test_directions():
	a=lexicon()
	assert_equal(a.scan("north"),[('direction','north')])
	b=lexicon()
	result=b.scan("north south east")
	assert_equal(result,[('direction','north'),('direction','south'),('direction','east')])
Beispiel #12
0
def test_numbers():
    lex = lexicon()
    assert_equal(lex.scan("1234"), [('number', 1234)])
    result = lex.scan("3 91234")
    assert_equal(result, [('number', 3),
                          ('number', 91234)])
Beispiel #13
0
def test_nouns():
    lex = lexicon()
    assert_equal(lex.scan("bear"), [('noun', 'bear')])
    result = lex.scan("bear princess")
    assert_equal(result, [('noun', 'bear'),
                          ('noun', 'princess')])
Beispiel #14
0
from nose.tools import *
from ex48.lexicon import lexicon

lexicon = lexicon()


def test_direction():
    assert_equal(lexicon.scan("north"), [("direction", "north")])
    result = lexicon.scan("north south east")
    assert_equal(result, [("direction", "north"), ("direction", "south"), ("direction", "east")])


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")])


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_nouns():
    assert_equal(lexicon.scan("bear"), [("noun", "bear")])
    result = lexicon.scan("bear princess")
    assert_equal(result, [("noun", "bear"), ("noun", "princess")])


def test_numbers():
Beispiel #15
0
from nose.tools import *
from ex48.lexicon import lexicon

lex = lexicon()


def test_directions():
    print lex.scan("north")
    assert_equal(lex.scan("north"), [('direction', 'north')])
    result = lex.scan("north south east")
    assert_equal(result, [('direction', 'north'), ('direction', 'south'),
                          ('direction', 'east')])


def test_verbs():
    assert_equal(lex.scan("go"), [('verb', 'go')])
    result = lex.scan("go kill eat")
    assert_equal(result, [('verb', 'go'), ('verb', 'kill'), ('verb', 'eat')])


def test_nouns():
    assert_equal(lex.scan("bear"), [('noun', 'bear')])
    result = lex.scan("bear princess")
    assert_equal(result, [('noun', 'bear'), ('noun', 'princess')])


def test_numbers():
    assert_equal(lex.scan("1234"), [('number', 1234)])
    result = lex.scan("3 91234")
    assert_equal(result, [('number', 3), ('number', 91234)])
Beispiel #16
0
def test_all(test_input, expected_output):
    test = lexicon()
    all = test.scan(test_input)
    assert all == expected_output