8000 rename server.py to corenlpy.py · TPNguyen/stanford-corenlp-python@1deab19 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1deab19

Browse files
committed
rename server.py to corenlpy.py
1 parent 1516899 commit 1deab19

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ In other words:
2323

2424
Then, to launch a server:
2525

26-
python server.py
26+
python corenlp.py
2727

2828
Optionally, you can specify a host or port:
2929

30-
python server.py -H 0.0.0.0 -p 3456
30+
python corenlp.py -H 0.0.0.0 -p 3456
3131

3232
That will run a public JSON-RPC server on port 3456.
3333

@@ -59,7 +59,7 @@ Produces a list with a parsed dictionary for each sentence:
5959

6060
To use it in a regular script or to edit/debug, load the module instead:
6161

62-
from server import *
62+
from corenlp import *
6363
corenlp = StanfordCoreNLP()
6464
corenlp.parse("Parse an imperative sentence, damnit!")
6565

server.py renamed to corenlp.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def parse_parser_results(text):
6666
if len(split_entry) == 3:
6767
rel, left, right = map(lambda x: remove_id(x), split_entry)
6868
tmp['tuples'].append(tuple([rel,left,right]))
69-
print "\n", rel, left, right
7069
elif "Coreference links" in line:
7170
state = 5
7271
elif state == 5:
@@ -132,9 +131,13 @@ def parse(self, text):
132131
with one dictionary entry for each parsed sentence, in JSON format.
133132
"""
134133
print "Request", text
135-
print self._server.sendline(text)
136-
# How much time should we give the parser to parse it?it
137-
#
134+
self._server.sendline(text)
135+
# How much time should we give the parser to parse it?
136+
# the idea here is that you increase the timeout as a
137+
# function of the text's length.
138+
139+
# anything longer than 5 seconds requires that you also
140+
# increase timeout=5 in jsonrpc.py
138141
max_expected_time = min(5, 2 + len(text) / 200.0)
139142
print "Timeout", max_expected_time
140143
end_time = time.time() + max_expected_time
@@ -165,11 +168,8 @@ def parse(self, text):
165168
'-H', '--host', default='127.0.0.1',
166169
help='Host to serve on (default localhost; 0.0.0.0 to make public)')
167170
options, args = parser.parse_args()
168-
#parser.print_help()
169171
server = jsonrpc.Server(jsonrpc.JsonRpc20(),
170172
jsonrpc.TransportTcpIp(addr=(options.host, int(options.port))))
171-
4E9E corenlp = StanfordCoreNLP()
172-
server.register_function(corenlp.parse)
173-
#server.register_instance(StanfordCoreNLP())
173+
server.register_instance(StanfordCoreNLP())
174174
print 'Serving on http://%s:%s' % (options.host, options.port)
175175
server.serve()

0 commit comments

Comments
 (0)
0