Reputation: 17
so I'm trying to learn machine translation with nltk and babelfish, but I keep getting these errors whenever I try to use the babelfish methods:
>>> 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.
What am I doing wrong here?
Upvotes: 0
Views: 1252
Reputation: 122122
There is nothing wrong with the code, it's just that the babelfish
API is no longer available which makes the NLTK API to babelfish void =(
It is also removed from the latest version of NLTK, see https://github.com/nltk/nltk/issues/265
Upvotes: 2