0

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?

alvas
  • 115,346
  • 109
  • 446
  • 738
nickshoe
  • 17
  • 8

1 Answers1

2

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

alvas
  • 115,346
  • 109
  • 446
  • 738