让 Python 的 nltk.wordnet 模块为 Jython 工作

发布于 2024-09-10 07:52:36 字数 402 浏览 3 评论 0原文

我已阅读 Jython 的常见问题解答和这篇文章 Jython 和 python 模块,但我不确定我如何确定一个模块是纯粹用 C 还是 Python 编写的。

我面临的问题在这里提到 http://old.nabble .com/using-NLTK-in-Jython-td28520926.html

任何完成此操作的人都可以对此有所了解吗?我是 Jython 新手。

谢谢,

I've read through the FAQ for Jython and this post Jython and python modules but am not sure how I can determine if a module is written purely in C or Python.

The problem I'm facing is mentioned here http://old.nabble.com/using-NLTK-in-Jython-td28520926.html

Can anyone that has done this shed some light on this? I'm new to Jython.

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

擦肩而过的背影 2024-09-17 07:52:36

您是否按照问题中所述将 C:\Python26\Lib\site-packages\nltk 添加到 sys.path 中?它实际上应该是C:\Python26\Lib\site-packages,这是包含nltk的目录。如果您不想添加整个 site-packages,请尝试将 nltk 文件夹移动到另一个文件夹。

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.

眸中客 2024-09-17 07:52:36

我使用的是 Eclipse,并且包含根目录(nltk 或 site-packages)的路径不起作用。但是,制作 nltk 目录和 yaml 目录的 jar 文件确实有效。例如,

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

然后在我的 Jython 代码中,我必须添加 jar 文件,并将其添加到项目的 lib 目录中,

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

除此之外,我还必须使用 Eclipse 导入存档文件功能来让它查看 NLTK 模块。

对此有些挣扎,所以希望它可以节省其他人的时间。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文