python-duckling icon indicating copy to clipboard operation
python-duckling copied to clipboard

Incompatibility with recent versions of JPype

Open nishkalavallabhi opened this issue 3 years ago • 1 comments

I tried running duckling after installing a more recent version of JPype and started getting the following error when I tried using the parse_time function:

/usr/local/lib/python3.6/dist-packages/jpype/_jstring.py in getitem(self, i) 46 47 def getitem(self, i): ---> 48 if i < 0: 49 i += len(self) 50 if i < 0:

TypeError: '<' not supported between instances of 'slice' and 'int'

When I revert back to JPype 0.7.4 (the one I used before), it works, but I get a deprecation warning:

""/usr/local/lib/python3.6/dist-packages/jpype/_core.py:209: UserWarning: 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. """)"

It says I have to file a ticket with the developer if I notice this warning. Since current pip install for duckling installs JPype 1.0 and not older versions, it will throw the same error for many others. can you please take a look at this?

nishkalavallabhi avatar Jul 23 '20 16:07 nishkalavallabhi

The problem here is the developer is depending on Java strings automatically converting to Python strings which was deprecated behavior (with a warning issued for the last year). If that was desired behavior then convertStrings=True should be passed to startJVM. However, it would be better to just apply the required fix instead. At the line where the parse_time is raising just add "str()" prior to calling the slice operator.

I will place an issue on JPype that we should consider supporting slicing of strings on __getitem__

Thrameos avatar Aug 04 '20 03:08 Thrameos