jpype

Different / better approaches for calling python function from Java

那年仲夏 提交于 2019-11-29 15:09:51
I am quite new to python and am trying to call python's function from java. My primary requirements are these: call should be transparent, in the sense that it should not require modifying .py file simply to enable it to be called from java. I might be given any python file with some functions inside it. I should be able to call any of these functions without requiring to modify .py file. I want to be able to send arguments of both primitive types ( int , String , floats etc.) or non primitive types ( HashMap , ArrayList ) from java to python function and receive back the returned object

JPype class not found

别等时光非礼了梦想. 提交于 2019-11-29 13:03:00
JPype is an amazing project since I allows to instantiate a JVM directly from Python . Unfortunately, I got stuck in the first baby steps. I have A.java source code ( located in C:\tmp folder ): class A { public A() { super(); } public String sayHi() { return("Hello"); } } Which was compiled to a class, using: javac A.java Thus, A.class is located in C:\tmp folder. I have the following Python source code: import os import jpype jpype.startJVM(jpype.getDefaultJVMPath(), '-ea', '-Djava.class.path=c:\\tmp') A = jpype.JClass("A") a = A() print a.sayHi() jpype.shutdownJVM() When I run it, I get the

Window离线环境下如何安装pyhanlp

心不动则不痛 提交于 2019-11-29 02:08:22
Hanlp在离线环境下的安装我是没有尝试过的,分享SunJW_2017的这篇文章就是关于如何在离线环境下安装hanlp的。我们可以一起来学习一下! HanLP是一款优秀的中文自然语言处理工具,可以实现包括分词、词性标注、实体识别在内容诸多功能,详情见其项目主页。另外,该工具包还提供了python3的接口,在线安装很方便,但有时需要部署在内网机等没有网络环境的机器上,比较繁琐,整理步骤如下: 1、安装jpype1,这是pyhanlp的依赖包,可以下载编译好的.whl文件,地址在这,选择对应自己python版本和操作系统版本的后,用pip install *.whl进行安装即可。 2、安装java环境,由于HanLP是用java开发的,因此调用python的接口时机器上应该配置了java环境,可以在网上搜索安装。 3、在pyhanlp的项目主页下载完整的.zip压缩包,解压后进入文件夹执行python setup.py install。 4、下载data-for-1.7.0.zip和hanlp-1.7.0.-release.zip,解压后分别获得data文件夹和hanlp.properties、hanlp-1.7.0.jar文件。 5、进入python包的安装目录,以Anaconda为例,进入该安装目录下的./lib/site-packages/pyhanlp-0.1.44-py3.6

[NLP的那些坑] HanLP

戏子无情 提交于 2019-11-29 00:34:26
问题1. D:\Anaconda3\lib\site-packages\jpype\_core.py:210: UserWarning: D:\Java\jdk1.8\jre\bin\server\jvm.dll ------------------------------------------------------------------------------- Deprecated: convertStrings was not specified when starting the JVM. The default behavior in JPype will be False starting in JPype 0.8. The recommended setting for new code is convertStrings=False. The legacy value of True was assumed for this session. If you are a user of an application that reported this warning, please file a ticket with the developer. --------------------------------------------------------

JPype class not found

混江龙づ霸主 提交于 2019-11-28 06:27:55
问题 JPype is an amazing project since I allows to instantiate a JVM directly from Python . Unfortunately, I got stuck in the first baby steps. I have A.java source code ( located in C:\tmp folder ): class A { public A() { super(); } public String sayHi() { return("Hello"); } } Which was compiled to a class, using: javac A.java Thus, A.class is located in C:\tmp folder. I have the following Python source code: import os import jpype jpype.startJVM(jpype.getDefaultJVMPath(), '-ea', '-Djava.class

自然语言处理工具python调用hanlp中文实体识别

。_饼干妹妹 提交于 2019-11-27 18:13:45
Hanlp作为一款重要的中文分词工具,在GitHub的用户量已经非常之高,应该可以看得出来大家对于hanlp这款分词工具还是很认可的。本篇继续分享一篇关于hanlp的使用实例即Python调用hanlp进行中文实体识别。 想要在python中调用hanlp进行中文实体识别,Ubuntu 16.04的系统环境 1.安装jpype1,在cmd窗口输入 pip install jpype1 2.下载hanlp的安装包 在https://github.com/hankcs/HanLP/releases (1)下载新的 hanlp-1.7.1-release.zip文件,里面包含hanlp-1.7.1.jar , hanlp-1.7.1-sources.jar , hanlp.properties (2)点击data-for-1.7.1.zip下载。(底下第8条) 注:如果你在http://hanlp.linrunsoft.com/services.html点击下载hanlp.jar,下载下来的是hanlp-1.2.8.jar。之后在使用过程中可能会出现“字符类型对应表加载失败”的错误,查看相应路径下也没有CharType.dat.yes文件。原因可能是hanlp-1.2.8版本过低,使用新版本应该不会出现这个问题。 3.新建一个文件夹Hanlp,放文件hanlp-1.7.1

How do I install a Python package with a .whl file?

ぃ、小莉子 提交于 2019-11-25 22:28:01
问题 I\'m having trouble installing a Python package (specifically, JPype1 0.5.7) on my Windows machine, and would like to install it with Christoph Gohlke\'s Window binaries. (Which, to my experience, alleviated much of the fuss for many other package installations.) However, while Christoph used to provide .exe files in the past, recently it seems he\'s uploading .whl files instead. http://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype But how do I install .whl files? Notes: I\'ve found documents on