0

所以我正在尝试使用 nltk 和 babelfish 学习机器翻译,但是每当我尝试使用 babelfish 方法时,我都会不断收到这些错误:

>>> import yahoo
>>> import nltk
>>> from nltk.misc import babelfish
>>> babelfish.translate('cookbook', 'english', 'spanish')
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python2.7/dist-packages/nltk/misc/babelfish.py", line 106, in  translate
    if not match: raise BabelfishChangedError("Can't recognize translated string.")
    nltk.misc.babelfish.BabelfishChangedError: Can't recognize translated string.
>>> for text in babelfish.babelize('cookbook', 'english', 'spanish'):
...   print text
... 
cookbook
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/nltk/misc/babelfish.py", line 126, in babelize
phrase = translate(phrase, next, flip[next])
File "/usr/lib/python2.7/dist-packages/nltk/misc/babelfish.py", line 106, in translate
if not match: raise BabelfishChangedError("Can't recognize translated string.")
nltk.misc.babelfish.BabelfishChangedError: Can't recognize translated string.

我在这里做错了什么?

4

1 回答 1

1

代码没有问题,只是babelfishAPI 不再可用,这使得 babelfish 的 NLTK API 无效 =(

它也从最新版本的 NLTK 中删除,请参阅https://github.com/nltk/nltk/issues/265

于 2014-08-05T22:51:30.807 回答