From 2bef4bdb49ce79133583846bcca3fc4b32179370 Mon Sep 17 00:00:00 2001 From: Dima Date: Fri, 5 Jun 2015 10:44:51 -0700 Subject: [PATCH] added param and using more standard os.path.join --- corenlp.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/corenlp.py b/corenlp.py index 753e51c..95722e5 100644 --- a/corenlp.py +++ b/corenlp.py @@ -150,7 +150,7 @@ def __init__(self, corenlp_path=None): props = "-props default.properties" # add and check classpaths - jars = [corenlp_path + jar for jar in jars] + jars = [os.path.join(corenlp_path, jar) for jar in jars] for jar in jars: if not os.path.exists(jar): logger.error("Error! Cannot locate %s" % jar) @@ -250,11 +250,13 @@ def parse(self, text): help='Port to serve on (default: 8080)') parser.add_option('-H', '--host', default='127.0.0.1', help='Host to serve on (default: 127.0.0.1. Use 0.0.0.0 to make public)') + parser.add_option('-P', '--path', default=None, + help='Path to the dir containing the Stanford parser .jar file') options, args = parser.parse_args() server = jsonrpc.Server(jsonrpc.JsonRpc20(), jsonrpc.TransportTcpIp(addr=(options.host, int(options.port)))) - nlp = StanfordCoreNLP() + nlp = StanfordCoreNLP(options.path) server.register_function(nlp.parse) logger.info('Serving on http://%s:%s' % (options.host, options.port))