Error about json running project
Opened this issue · 2 comments
Traceback (most recent call last):
File "C:\Users\NB\Downloads\NLP-Question-Answer-System-master (1)\NLP-Question-Answer-System-master\simpleQueryAnswering.py", line 117, in
parse = json.loads(corenlp.parse(sentence))
File "C:\Python27\lib\json_init_.py", line 339, in loads
return _default_decoder.decode(s)
File "C:\Python27\lib\json\decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer
I got past the error in the following way:
Do the following steps somewhere outside this project folder:
sudo pip install pexpect unidecode
git clone git://github.com/dasmith/stanford-corenlp-python.git
cd stanford-corenlp-python
wget http://nlp.stanford.edu/software/stanford-corenlp-full-2014-08-27.zip
unzip stanford-corenlp-full-2014-08-27.zip
Now open simpleQueryAnswering.py and include these import statements:
import json
from jsonrpc import ServerProxy, JsonRpc20, TransportTcpIp
from simplejson import loads
and replace the line corenlp = StanfordCoreNLP()
with
server = ServerProxy(JsonRpc20(), TransportTcpIp(addr=("127.0.0.1", 8080)))
Then replace the line
parse = json.loads(corenlp.parse(sentence))
with
vparse = loads(server.parse(sentence))
and
for worddata in parse["sentences"][0]["words"]:
with
for worddata in vparse["sentences"][0]["words"]:
Now open a terminal in stanford-corenlp-python which you cloned earlier
Run: python corenlp.py
Now run your simpleQueryAnswering.py
That error won't come
But now I have no idea what kind of files it expects as input argument. If you have any idea on the same let me know.