嗨,我正在使用 NLTK 学习自然语言处理。我正在尝试实现本书的 babelize_shell() 示例。我正在做的是执行 babelize_shell(),然后我输入我的字符串,然后是书中所述的德语,然后是运行。
我得到的错误是:
Traceback (most recent call last):
File "<pyshell#148>", line 1, in <module>
babelize_shell()
File "C:\Python27\lib\site-packages\nltk\misc\babelfish.py", line 175, in babelize_shell
for count, new_phrase in enumerate(babelize(phrase, 'english', language)):
File "C:\Python27\lib\site-packages\nltk\misc\babelfish.py", line 126, in babelize
phrase = translate(phrase, next, flip[next])
File "C:\Python27\lib\site-packages\nltk\misc\babelfish.py", line 106, in translate
if not match: raise BabelfishChangedError("Can't recognize translated string.")
BabelfishChangedError: Can't recognize translated string.
这是一个示例会话:
>>> babelize_shell()
NLTK Babelizer: type 'help' for a list of commands.
Babel> how long before the next flight to Alice Springs?
Babel> german
Babel> run
0> how long before the next flight to Alice Springs?
1> wie lang vor dem folgenden Flug zu Alice Springs?
2> how long before the following flight to Alice jump?
3> wie lang vor dem folgenden Flug zu Alice springen Sie?
4> how long before the following flight to Alice do you jump?
5> wie lang, bevor der folgende Flug zu Alice tun, Sie springen?
6> how long, before the following flight to Alice does, do you jump?
7> wie lang bevor der folgende Flug zu Alice tut, tun Sie springen?
8> how long before the following flight to Alice does, do you jump?
9> wie lang, bevor der folgende Flug zu Alice tut, tun Sie springen?
10> how long, before the following flight does to Alice, do do you jump?
11> wie lang bevor der folgende Flug zu Alice tut, Sie tun Sprung?
12> how long before the following flight does leap to Alice, does you?