5

I am trying to use StanfordParser through python and i am using this implementation of it which is basically a remote server that responds to json requests from what i understand. They recommend the following implementation template for the client side after launching the server

import jsonrpc
from simplejson import loads
server = jsonrpc.ServerProxy(jsonrpc.JsonRpc20(), jsonrpc.TransportTcpIp(addr=("127.0.0.1", 8080)))

result = loads(server.parse("Hello world.  It is so beautiful"))
print "Result", result

however i have no experience using jsonrpc and i just installed it using pip install json-rpc. That doesnt seem to have worked though because when i try to run the sample client i get the following exception.

Traceback (most recent call last):
  File "/root/PycharmProjects/testingStanfordParser/parser.py", line 1, in <module>
    import jsonrpc
  File "/usr/local/lib/python2.7/dist-packages/jsonrpc/__init__.py", line 6, in <module>
    from .manager import JSONRPCResponseManager
  File "/usr/local/lib/python2.7/dist-packages/jsonrpc/manager.py", line 12, in <module>
    from .jsonrpc1 import JSONRPC10Response
  File "/usr/local/lib/python2.7/dist-packages/jsonrpc/jsonrpc1.py", line 3, in <module>
    from .base import JSONRPCBaseRequest, JSONRPCBaseResponse
  File "/usr/local/lib/python2.7/dist-packages/jsonrpc/base.py", line 1, in <module>
    from .utils import JSONSerializable
  File "/usr/local/lib/python2.7/dist-packages/jsonrpc/utils.py", line 31, in <module>
    class DatetimeDecimalEncoder(json.JSONEncoder):
AttributeError: 'module' object has no attribute 'JSONEncoder'
2
  • 1
    My bad, they give their own version of jsonrpc.py with the extra method :) Commented Oct 9, 2014 at 6:32
  • You should make the comment an answer, because it's the correct answer Commented Dec 10, 2015 at 19:23

1 Answer 1

3

As mentioned, they have their own implementation of jsonrpc.py. It can be downloaded the below link.

https://github.com/dasmith/stanford-corenlp-python/blob/master/jsonrpc.py

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.