Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8d9f542

Browse files
Update client.py
Adding threads argument to parallelize the CoreNLP parsing
1 parent 3981973 commit 8d9f542

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎corenlp/client.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,22 @@ class CoreNLPClient(RobustService):
116116
DEFAULT_ANNOTATORS = "tokenize ssplit lemma pos ner depparse".split()
117117
DEFAULT_PROPERTIES = {}
118118

119-
def __init__(self, start_server=True, endpoint="http://localhost:9000", timeout=5000, annotators=DEFAULT_ANNOTATORS, properties=DEFAULT_PROPERTIES):
119+
def __init__(self, start_server=True,
120+
endpoint="http://localhost:9000",
121+
timeout=5000,
122+
threads=5,
123+
annotators=DEFAULT_ANNOTATORS,
124+
properties=DEFAULT_PROPERTIES):
120125
if start_server:
121126
host, port = urlparse(endpoint).netloc.split(":")
122127
assert host == "localhost", "If starting a server, endpoint must be localhost"
123128

124129
assert os.getenv("CORENLP_HOME") is not None, "Please define $CORENLP_HOME where your CoreNLP Java checkout is"
125-
start_cmd = "java -cp '{corenlp_home}/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port {port} -timeout {timeout}".format(
130+
start_cmd = "java -cp '{corenlp_home}/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port {port} -timeout {timeout} -threads {threads}".format(
126131
corenlp_home=os.getenv("CORENLP_HOME"),
127132
port=port,
128-
timeout=timeout)
133+
timeout=timeout,
134+
threads=threads)
129135
stop_cmd = None
130136
else:
131137
start_cmd = stop_cmd = None

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /