You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@
4
4
This is a fork of Dustin Smith's [stanford-corenlp-python](https://github.com/dasmith/stanford-corenlp-python), a Python interface to [Stanford CoreNLP](http://nlp.stanford.edu/software/corenlp.shtml). It can either use as python package, or run as a JSON-RPC server.
5
5
6
6
## Edited
7
+
* Added multi-threaded load balancing
7
8
* Update to Stanford CoreNLP v3.2.0
8
9
* Fix many bugs & improve performance
9
10
* Using jsonrpclib for stability and performance
@@ -38,6 +39,10 @@ Optionally, you can specify a host or port:
38
39
39
40
python corenlp/corenlp.py -H 0.0.0.0 -p 3456
40
41
42
+
For additional concurrency, you can add a load-balancing layer on top:
That will run a public JSON-RPC server on port 3456.
42
47
And you can specify Stanford CoreNLP directory:
43
48
@@ -53,6 +58,24 @@ Assuming you are running on port 8080 and CoreNLP directory is `stanford-corenlp
53
58
result = loads(server.parse("Hello world. It is so beautiful"))
54
59
print "Result", result
55
60
61
+
If you are using the load balancing component, then you can use the following approach:
62
+
63
+
import jsonrpclib
64
+
from simplejson import loads
65
+
server = jsonrpclib.Server("http://localhost:8080")
66
+
67
+
result = loads(server.send("Hello world. It is so beautiful"))
68
+
print "Result", server.getForKey(result['key'])
69
+
70
+
# asynchronous parsing and retrieval
71
+
sents = [ 'add in as many sentences as you want', 'your mileage may vary' ]
72
+
for sent in sents:
73
+
server.send(sent)
74
+
# this approach is non-blocking
75
+
print server.getCompleted()
76
+
# this approach waits for all in-progress parses to finish (i.e. blocks)
77
+
print server.getAll()
78
+
56
79
That returns a dictionary containing the keys `sentences` and (when applicable) `corefs`. The key `sentences` contains a list of dictionaries for each sentence, which contain `parsetree`, `text`, `tuples` containing the dependencies, and `words`, containing information about parts of speech, NER, etc:
0 commit comments