sinaahmadi/klpt

Error when trying example

lancioni opened this issue · 4 comments

When trying one of the transliteration examples in the main project page,

transliterate = Transliterate("Kurmanji", "Latin", target_script="Arabic"
transliterate.transliterate("rojhilata navîn")

I get the following error:
Traceback (most recent call last):
File "", line 1, in
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\klpt\transliterate.py", line 162, in transliterate
tokens_dict = self.to_pieces(token)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\klpt\transliterate.py", line 131, in to_pieces
tokens_dict[char_index-i] = tokens_dict[char_index-i] + token[char_index]
KeyError: 1

I am using Python 3.6.3 under Windows 10.

Thanks for support!

Giuliano

Thanks for raising the issue, Giuliano.

It is weird, as I cannot reproduce the same bug with your code.
Would you please try the following code or provide your entire code here?

>>> from klpt.transliterate import Transliterate
>>> transliterate = Transliterate("Kurmanji", "Latin", target_script="Arabic")
>>> transliterate.transliterate("rojhilata navîn")
'رۆژهلاتا ناڤین'

Strangely enough, it gave the error by writing exactly what you wrote:

immagine

On the other hand, it works in Linux Subsystem for Windows:

immagine

So, it seems to be a Windows issue, although the library was installed through pip with no complain. Strange!

This is really weird. I, unluckily, have not tested the library on Windows yet.
Thanks so much again for reporting it. I'll find a way to test it on Windows soon.