简体   繁体   English

小鸭,int() 参数必须是一个字符串,一个类似字节的 object 或一个数字,而不是 'java.lang.String',

[英]Duckling, int() argument must be a string, a bytes-like object or a number, not 'java.lang.String',

I want to use duckling for time entity extraction from any string.我想使用小鸭从任何字符串中提取时间实体。

I am trying to use basic code for using duckling.我正在尝试使用基本代码来使用小鸭。

from duckling import DucklingWrapper
d = DucklingWrapper()
print(d.parse_time(u'Let\'s meet at 11:45am'))

For this I am getting following error.为此,我收到以下错误。 int() argument must be a string, a bytes-like object or a number, not 'java.lang.String' int() 参数必须是字符串、类似字节的 object 或数字,而不是 'java.lang.String'

could anyone please help me with this?谁能帮我解决这个问题?

Short answer: force your jpype version to be below 0.8.简短回答:强制您的 jpype 版本低于 0.8。 ie pip install Jpype1==0.7.5即pip安装Jpype1==0.7.5

Longer answer: This is due to one of Duckling's dependency JPype.更长的答案:这是由于 Duckling 的依赖之一 JPype。 If you dive into the code, you'll see that when starting the JVM using JPype, an argument "convertStrings" needs to be passed.如果深入研究代码,您会发现在使用 JPype 启动 JVM 时,需要传递参数“convertStrings”。 Before V0.8 this argument was by default set to "true", but it was switch to "false" after that.在 V0.8 之前,此参数默认设置为“true”,但之后切换为“false”。 This should be an easy fix within Duckling if you can modify the package code.如果您可以修改 package 代码,这应该是 Duckling 中的一个简单修复。 If not, then downgrade your Jpype version will also work.如果没有,那么降级你的 Jpype 版本也可以。

Ref: https://jpype.readthedocs.io/en/latest/api.html参考: https://jpype.readthedocs.io/en/latest/api.html

This is an incompatibility issue between duckling and Jpype.这是duckling和Jpype的不兼容问题。

This worked for me:这对我有用:

pip install --force-reinstall JPype1==0.6.3

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 frida:错误:a():参数类型不匹配:重载('int','int','long','java.lang.String','java.lang.Object') - frida: Error: a(): argument types do not match any of: overload('int', 'int', 'long', 'java.lang.String', 'java.lang.Object') java.lang.IllegalArgumentException:“json”参数必须是以下实例:[class java.lang.String, class [B - java.lang.IllegalArgumentException: 'json' argument must be an instance of: [class java.lang.String, class [B Java.lang.String无法转换为int - Java.lang.String cannot be converted to int int无法转换为java.lang.String - int cannot be converted to java.lang.String Java &&错误“未为参数类型java.lang.String,java.lang.String定义运算符&&” - Java && Error “The operator && is undefined for the argument type(s) java.lang.String, java.lang.String” onDropdownRecyclerClick(int, java.lang.String) [不能应用于'(int)] - onDropdownRecyclerClick(int, java.lang.String) [cannot be applied to '(int)] 运算符|| 在Android应用中未为参数类型java.lang.String,java.lang.String定义 - The operator || is undefined for the argument type(s) java.lang.String, java.lang.String in Android app 将java.lang.String转换为java.lang.Number - Convert java.lang.String to java.lang.Number 无法将具有类'java.lang.String'的对象'url'强制转换为类'int'的Gradle Java - Cannot cast object 'url' with class 'java.lang.String' to class 'int' Gradle Java JAVA:不兼容的类型:int 无法转换为 java.lang.String - JAVA: Incompatible types: int cannot be converted to java.lang.String
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM