如何创建空扫描功能?这是我的lexicon.rb
文件
require 'ex48/lexicon.rb'
require "test/unit"
class TestNAME < Test::Unit::TestCase
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']])
end
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']])
end
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']])
end
def test_nouns()
assert_equal(Lexicon.scan("bear"), [['noun', 'bear']])
result = Lexicon.scan("bear princess")
assert_equal(result, [['noun', 'bear'],
['noun', 'princess']])
end
def test_numbers()
assert_equal(Lexicon.scan("1234"), [['number', 1234]])
result = Lexicon.scan("3 91234")
assert_equal(result, [['number', 3],
['number', 91234]])
end
def test_errors()
assert_equal(Lexicon.scan("ASDFADFASDF"), [['error', 'ASDFADFASDF']])
result = Lexicon.scan("bear IAS princess")
assert_equal(result, [['noun', 'bear'],
['error', 'IAS'],
['noun', 'princess']])
end
end
以下是步骤:
lexicon.rb
文件,创建一个空扫描功能。无论如何,如何创建空扫描功能?任何答案都没问题。
答案 0 :(得分:2)
添加代码
def
scan()
end
答案 1 :(得分:2)
功能
def
(your code)
end
所以扫描功能是
def
scan ()
end
答案 2 :(得分:1)
def扫描 端
将上述功能添加到文件中。
答案 3 :(得分:1)
require 'ex48/lexicon.rb'
require "test/unit"
class TestNAME < Test::Unit::TestCase
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']])
end
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']])
end
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']])
end
def test_nouns()
assert_equal(Lexicon.scan("bear"), [['noun', 'bear']])
result = Lexicon.scan("bear princess")
assert_equal(result, [['noun', 'bear'],
['noun', 'princess']])
end
def test_numbers()
assert_equal(Lexicon.scan("1234"), [['number', 1234]])
result = Lexicon.scan("3 91234")
assert_equal(result, [['number', 3],
['number', 91234]])
end
def test_errors()
assert_equal(Lexicon.scan("ASDFADFASDF"), [['error', 'ASDFADFASDF']])
result = Lexicon.scan("bear IAS princess")
assert_equal(result, [['noun', 'bear'],
['error', 'IAS'],
['noun', 'princess']])
end
def scan()
end
end
我明白了。我添加了
def
scan()
end
答案 4 :(得分:1)
添加 def scan()结束 希望有所帮助