dasmith / stanford-corenlp-python

Python wrapper for Stanford CoreNLP tools v3.4.1
GNU General Public License v2.0
612 stars 229 forks source link

Import stanford-corenlp-python as a module #14

Open matteorr opened 10 years ago

matteorr commented 10 years ago

When I try importing the corenlp class from a python script (exampleRun.py) that is not in the same stanford-corenlp-pyhton directory like this:

from corenlp import * corenlp = StanfordCoreNLP("path_to_stanford-corenlp-full-2014-08-27/")

the following error is raised from pexpect:

Loading Models: 0/5
Traceback (most recent call last): File "/home/matteorr/Project1/exampleRun.py", line 4, in corenlp = StanfordCoreNLP("/home/matteorr/stanford-corenlp-pyhton/stanford-corenlp-full-2014-08-27/") File "/home/matteorr/stanford-corenlp-pyhton/corenlp.py", line 168, in init self.corenlp.expect("done.", timeout=20) # Load pos tagger model (~5sec) File "/usr/lib/python2.7/dist-packages/pexpect.py", line 1311, in expect return self.expect_list(compiled_pattern_list, timeout, searchwindowsize) File "/usr/lib/python2.7/dist-packages/pexpect.py", line 1325, in expect_list return self.expect_loop(searcher_re(pattern_list), timeout, searchwindowsize) File "/usr/lib/python2.7/dist-packages/pexpect.py", line 1396, in expect_loop raise EOF (str(e) + '\n' + str(self)) pexpect.EOF: End Of File (EOF) in read_nonblocking(). Exception style platform. <pexpect.spawn object at 0x7f7106fb3650> version: 2.3 ($Revision: 399 $) command: /usr/bin/java args: ['/usr/bin/java', '-Xmx1800m', '-cp', '/home/matteorr/stanford-corenlp-pyhton/stanford-corenlp-full-2014-08-27/stanford-corenlp-3.4.1.jar:/home/matteorr/stanford-corenlp-pyhton/stanford-corenlp-full-2014-08-27/stanford-corenlp-3.4.1-models.jar:/home/matteorr/stanford-corenlp-pyhton/stanford-corenlp-full-2014-08-27/joda-time.jar:/home/matteorr/stanford-corenlp-pyhton/stanford-corenlp-full-2014-08-27/xom.jar:/home/matteorr/stanford-corenlp-pyhton/stanford-corenlp-full-2014-08-27/jollyday.jar', 'edu.stanford.nlp.pipeline.StanfordCoreNLP', '-props', 'default.properties'] searcher: searcher_re: 0: re.compile("done.") buffer (last 100 chars): before (last 100 chars): va:448) at edu.stanford.nlp.util.StringUtils.argsToProperties(StringUtils.java:869) ... 2 more

after: <class 'pexpect.EOF'> match: None match_index: None exitstatus: None flag_eof: True pid: 28392 child_fd: 3 closed: False timeout: 30 delimiter: <class 'pexpect.EOF'> logfile: None logfile_read: None logfile_send: None maxread: 2000 ignorecase: False searchwindowsize: None delaybeforesend: 0.05 delayafterclose: 0.1 delayafterterminate: 0.1

The same script, run in the same directory as corenlp works fine. Is this expected behavior or is something wrong?

Thanks in advance for your help. I apologize if this was not the correct place post this issue.

Best regards,

matteorr

buptkang commented 9 years ago

I had the same issue like you. Please give any advise.

Thanks.

m-ochi commented 9 years ago

me too.

deepak216 commented 9 years ago

i think by default corenlp.py is installed in your python library so remove that corenlp.py and then run your program

yarax commented 9 years ago

+1 to the issue

yarax commented 9 years ago

Any recipes? Because rpc seems good

LeoKotschenreuther commented 8 years ago

I have the same issue, any updates?

killertester101 commented 8 years ago

Same here.!

ynakashio commented 7 years ago

me too.....

willlauer commented 7 years ago

I get the same issue when running my program from the same directory as corenlp.py

JohnnyLim commented 6 years ago

I found that the file default.properties wasn't in my project repo, and I added this file to the project. Then the problem was solved.