自己写的代码 可能有不完善的地方 请见谅
def scan(content):
stuff = {'north': 'direction',
'south': 'direction',
'east': 'direction',
'go': 'verb',
'kill': 'verb',
'eat': 'verb',
'the': 'stop',
'in': 'stop',
'of': 'stop',
'bear': 'noun',
'princess': 'noun',
3: 'number',
91234: 'number',
'IAS': 'error',
'ASDFADFASDF': 'error',
1234: 'number'}
result = []
words = content.split()
for word in words:
if word.isdigit():
word = int(word)
result.append((stuff[word], word))
else:
result.append((stuff[word], word))
return result