0

I am dealing with NLP in python. There is a NLP tool namely Zemberek for turkish language. But it is written in java. So I have to use jython to be able to import these classes. I installed jython 2.7. Also, I installed Eclipse Mars as an IDE for java. On the Internet I found the following link to use Jython in an IDE. I installed PyDev and configured it properly as explained in the link.

http://www.jython.org/jythonbook/en/1.0/JythonIDE.html

import sys
import os

import java.lang.System.out
import java.util.Arrays
import java.util.List

zembereksourcedir = ?

sys.path.append(zembereksourcedir +'/jar/zemberek-tr-2.1.1.jar')
sys.path.append(zembereksourcedir +'/jar/zemberek-cekirdek-2.1.1.jar')

from net.zemberek.erisim import Zemberek
from net.zemberek.tr.yapi import TurkiyeTurkcesi

zemberek = Zemberek(TurkiyeTurkcesi())
for st in ["ebeni","ırz"]:
    kok = zemberek.kokBulucu().kokBul(st) # array(net.zemberek.yapi.Kok, [ev ISIM , evli ISIM ])
    print str(list(kok))
    k = str(list(kok)).split()[0][1:]
    print k

The code that I am trying to run is given above.(can be found in the following link https://gist.github.com/ferayebend/5331379) But the problem is that even if I specifiy the paths correctly it gives an error.

ImportError: No module named Zemberek

I applied the steps correctly to create projects which is also explained in the link above. But I still could not solve the problem. Any help would be much appreciated.

Ersin
  • 151
  • 1
  • 2
  • 5

1 Answers1

0

Instead of adding it to sys.path, you should add it as a library either in the Jython Interpreter configuration (window > preferences > pydev > interpreters > jython interpreter > new jar/zip(s)) or if it's in a folder in the project, right-click project > properties > pydev - pythonpath > external libraries > add zip/jar/egg.

The reason is that just adding to sys.path doesn't work, you also need to add those jars to the CLASSPATH for java/jython to find it (which PyDev will do for you if you specify it in the proper way).

Fabio Zadrozny
  • 24,814
  • 4
  • 66
  • 78