NLTK Translate - alignment problems?

76 views
Skip to first unread message

Alexa Little

unread,
May 7, 2016, 6:54:38 PM5/7/16
to nltk-users
Hi! 
I'm trying to use NLTK's IBM models to build a translation system, which I'm applying to "translate" English orthography into ARPABET (and ultimately IPA).

Everything seems to train just fine, but when I try to extract the alignments I get an error:

C:\Users\Zelda>python ibm.py alexandrascmu.txt
['a', 'b', 'a', 'c', 'u', 's']
['AE', 'B', 'AH0', 'K', 'AH0', 'S']
Traceback (most recent call last):
  File "ibm.py", line 47, in <module>
    print test_sentence.alignment
  File "C:\Users\Zelda\Anaconda2\lib\site-packages\nltk\compat.py", line 671, in wrapper
    return method(self).encode('ascii', 'backslashreplace')
  File "C:\Users\Zelda\Anaconda2\lib\site-packages\nltk\compat.py", line 659, in wrapper
    return transliterate(method(self))
  File "C:\Users\Zelda\Anaconda2\lib\site-packages\nltk\translate\api.py", line 239, in __str__
    return " ".join("%d-%d" % p[:2] for p in sorted(self))
  File "C:\Users\Zelda\Anaconda2\lib\site-packages\nltk\translate\api.py", line 239, in <genexpr>
    return " ".join("%d-%d" % p[:2] for p in sorted(self))
TypeError: %d format: a number is required, not NoneType

When I check the models for probabilities, they do exist, but for whatever reason I'm not getting alignments.

Any ideas how to fix this?

Siyuan Wang

unread,
Jan 22, 2017, 10:48:27 AM1/22/17
to nltk-users

Hi Alexa,

I am having exactly the same error. Have you managed to fix the problem?

Thank you in advance!

Siyuan
Reply all
Reply to author
Forward
0 new messages