Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JsonRpc client in python

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'
like image 369
Evan Avatar asked Oct 21 '22 00:10

Evan


1 Answers

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

like image 117
AmanRaj Avatar answered Oct 22 '22 12:10

AmanRaj