我们如何从Java运行python脚本(使用nltk和scrapy) [英] how can we run python script(which uses nltk and scrapy) from java

查看:105
本文介绍了我们如何从Java运行python脚本(使用nltk和scrapy)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了在项目中使用scrapy,nltk和simplejson的python脚本,但是我需要从Java运行它们,因为我的指导者希望将它们部署在服务器上,而我花的时间却很少.不用说在Java和jython中的runtime.exec()上,不用说从Java运行系统命令也不是那么简单.

I have written python scripts that use scrapy,nltk and simplejson in my project but i need to run them from java as my mentor wants to deploy them on a server and i have very less time to do this.I took a glance at runtime.exec() in java and jython, needless to say that running system commands from java doesn't look simple either.

所以我想知道从java作为系统命令-'python example.py'使用runtime.exec()还是使用jython运行python脚本会更简单和实际可行,还是有更简单的解决方法知道是否有人使用Jython运行了从Java使用nltk的python代码以及他们是否遇到任何问题也将非常高兴.请尽快帮助我,欢迎对此提出任何想法和建议.

So I would like to know if running the python scripts from java as system command -'python example.py ' using runtime.exec() or alternatively using jython would be more simpler and actually feasible or whether there is a simpler workaround .It would also be great to know if anyone had run python code that uses nltk from java using Jython and whether they encountered any problems.Please help me as I have to do this as asap.Any thoughts and suggestions regarding this are welcome.

提前感谢!

推荐答案

Jepp 项目可让您从Java调用python脚本.它提供了一种简单的机制,可将变量传递到脚本中并提取回值.我已经在一些项目中使用了成功的

The Jepp project lets you call python scripts from Java. It provides an easy mechanism to pass variables into a script and extract values back. I've used on a few projects with good success

这篇关于我们如何从Java运行python脚本(使用nltk和scrapy)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆