Getting Python's nltk.wordnet module working for Jython

断了今生、忘了曾经 提交于 2019-12-01 08:36:54

Did you add C:\Python26\Lib\site-packages\nltk to sys.path as stated in your question? It should really be C:\Python26\Lib\site-packages, which is the directory containing nltk. If you don't want to add the entire site-packages, try moving the nltk folder to another folder.

rand_acs

I was using Eclipse, and including the path to the root dir (nltk or site-packages) did not work. However, making jar files of both the nltk directory and the yaml directory did work. Example,

jar -cf nltk.jar /Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/nltk
jar -cf yaml.jar /Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/yaml

Then in my Jython code I had to add the jar files, which I added to the project's lib dir,

sys.path.append("/Users/peter/phd/lib/yaml.jar")
sys.path.append("/Users/peter/phd/lib/nltk.jar")

In addition to this I had to use the Eclipse import archive file feature to get it to see the NLTK modules.

Had a bit of a struggle with this, so hope it saves someone else some time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!