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'
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With