stanford corenlp not working

ε祈祈猫儿з 提交于 2019-12-03 16:16:05
icedwater

This is a record of my attempts to get corenlp-python, the python wrapper for CoreNLP running on Windows Server 2012, as-is.

Disclaimer: should you only need to run an executable, check this first. Consider subprocess.

Starting out

Since corenlp-python uses pexpect fairly heavily, and that library works on UNIX only, my first thought was to find a Windows port.

wexpect.py was fairly easy to find and claims to be a drop-in replacement for Pexpect (emphasis mine):

In order to use WExpect, you must install CygWin, and then install the WExpect script into your system (dropping the py file into your working directory is usually good enough). I’ve found the functionality is pretty much the same, so you should be able to use the PExpect manual and examples and apply them to this Microsoft Windows variant.

So I did just that, downloading and installing CygWin, then copying wexpect.py into C:\Python27\lib\ where all the other libraries were. I tried to import wexpect from a Python shell and got an error similar to when I first tried Pexpect on Windows:

ImportError: No module named pywintypes
This module requires the win32 python packages.

A critical module was not found. Probably this operating system does not
support it. Pexpect is intended for UNIX-like systems.

Et tu, wexpect?

No matter, this is standard frustration for finding equivalents. Press on.

I opened wexpect.py and saw that it would only try pywintypes on a Windows system. Logical, so I tried:

$ pip install -U pywintypes

...which failed, and led me to Google for the name of the python Win32 packages (this answer helped):

$ pip install -U pywin32

...which prompts for --allow-external and then --allow-unverified, both of which expect the package name, ergo:

$ pip install --allow-external pywin32 --allow-unverified pywin32 pywin32

Which, of course, does not work. No such package is found.

sf.net

So I head off to search for pywin32 on PyPI and realise that only a readme is left and I have to jump through four MORE hoops to get to something more substantial, then two more to find this list.

I downloaded Build 219 for Python 2.7 32-bit. At least now import wexpect doesn't puke.

What did you expect?

So I run the corenlp-python command again, and this time it's missing unidecode. This was easier to fix, and finally I got to a usable state - an error, no less, but familiar - where the path to the JARs was not correct.

OK.

When you run corenlp.py, since pexpect is invoked, remember to import wexpect as pexpect near the top and comment out the real import pexpect line, or you will get a NameError:

#import pexpect
import wexpect as pexpect

Even with Java installed, this does not seem to work, regardless of path.

$ python lib\corenlp\corenlp.py

It returns an ExceptionPexpect.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!