PredPatt
PredPatt copied to clipboard
Python2.7 vs 3 conflict in requirements--need version numbers
Hello,
It looks like PredPatt was written in Python2.7, but some of its required packages such as concrete and jpype1 require Python3 to install. I think I'd need to install previous versions of them to run PredPatt. Would you be able to provide us with specific version numbers with which PredPatt works?
Thank you!
Edit: Code in tutorial and using_predpatt.py
, written in Python 2, is now defunct--the authors now advise to build and use a RESTful API instead.
I'm able to install requirements with pip3, but get error messages like below when running using_predpatt.py
.
/home/aatlantise/anaconda3/lib/python3.8/site-packages/PyStanfordDependencies-0.3.1-py3.8.egg/StanfordDependencies/JPypeBackend.py:160: UserWarning: This jar doesn't support universal dependencies, falling back to Stanford Dependencies. To suppress this message, call with universal=False
warnings.warn("This jar doesn't support universal "
Traceback (most recent call last):
File "using_predpatt.py", line 8, in
I'm also having difficulties with the Dockerfile and building and running a container, not only from conflict between Python2.7 and 3 but also Debian 8 (Jessie) being outdated.
I've tried some manual fixes like installing Python3 and pip3, updating sources.list
. While these workarounds allow me to install concrete
but I have yet to successfully install jpype1
. I'll keep trying in the meantime, but any help is appreciated. :)
Just to explain the error message. JPype returns Java string class items when you call a Java function. Those can be converted to Python strings by calling str(x)
on the item. This older code is assuming that something it got from JPype was a Python string and likely stuck it in a dictionary which is then attempting to be serialized using Pickle. As Java classes do not serial it is an error. The solution is just to add str
call on the offending item before sticking it in the dictionary.
If this is too prohibitive the old (and very broken behavior) of JPype can be obtained by placing the argument convertStrings=True
in the JPype startJVM arguments. Though this is discouraged as it makes the module incompatible with other Python modules. It is best to fix the bug.
It looks like PredPatt was written in Python2.7
I think it should be fine with python 3, can you say more about what's going wrong here?
Re the jpype errors, I can confirm that wrapping the relevant line in UDParser.py seems to fix that error, i.e. s/self.cache[s] = x
/self.cache[s] = str(x)
. (I tested this just with one of the example calls in the tutorial.) However, there seem to be other places that assume the old behavior as well, so more fixes are needed, I immediately got another crash that looks similar. (Maybe it's also possible to pin some old version of jpype.) Thanks for clarifying this @Thrameos .
@Aatlantise since you seem to be working with PredPatt actively, if you were to make a PR that finds these cases and fixes them, I'd be able to merge it. Otherwise someone with commit access will eventually get to this, but fair warning, this package is in a kind of slow maintenance mode -- since everyone who knows the code well has gone on to other things. So I'm not sure how quick it will be.
Thank you both for your input! I appreciate the insight.
@Thrameos Thanks for your straightforward clarifications. I'm not too familiar with Java and JPype, but will give what you described a shot, and see where I can get.
@rawlins Hi Kyle! You were on the panel at my master's thesis defense last year. Thanks again for being there.
I was following the tutorial and using_predpatt.py
before realizing the the code there is now defunct. I'll fix my top comment. 😄
I was able to get a bit further down the road outside the container today--I'll continue working and submit a PR if I can.
Enjoy your weekends!
I'll continue working and submit a PR if I can
@Aatlantise friendly ping, any update? :)
In order to get PredPatt works, you will need
- JPype 0.7.4
- Python 3.6.2
- Download Parser, Grammar, CoreNLP manually -> Set fixed downloading location in
UDParser.py
- Add memory allocation param
-Xmx512m
toPopen
inUDParser.py
in order to start server. - JDK 1.8 required.
Tested in Windows 10 and Anaconda. :)