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 442433f

Browse files
Merge pull request #20 from laiviet/master
Parallelize corenlp server
2 parents c47c072 + 0ece430 commit 442433f

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

‎corenlp/client.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,26 @@ class CoreNLPClient(RobustService):
122122
DEFAULT_ANNOTATORS = "tokenize ssplit lemma pos ner depparse".split()
123123
DEFAULT_PROPERTIES = {}
124124

125-
def __init__(self, start_server=True, endpoint="http://localhost:9000",
126-
timeout=5000, annotators=DEFAULT_ANNOTATORS,
127-
properties=DEFAULT_PROPERTIES, stdout=sys.stdout,
128-
stderr=sys.stderr):
125+
def __init__(self, start_server=True,
126+
endpoint="http://localhost:9000",
127+
timeout=5000,
128+
threads=5,
129+
annotators=DEFAULT_ANNOTATORS,
130+
properties=DEFAULT_PROPERTIES,
131+
stdout=sys.stdout,
132+
stderr=sys.stderr
133+
):
134+
129135
if start_server:
130136
host, port = urlparse(endpoint).netloc.split(":")
131137
assert host == "localhost", "If starting a server, endpoint must be localhost"
132138

133139
assert os.getenv("CORENLP_HOME") is not None, "Please define $CORENLP_HOME where your CoreNLP Java checkout is"
134-
start_cmd = "java -cp '{corenlp_home}/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port {port} -timeout {timeout}".format(
140+
start_cmd = "java -cp '{corenlp_home}/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port {port} -timeout {timeout} -threads {threads}".format(
135141
corenlp_home=os.getenv("CORENLP_HOME"),
136142
port=port,
137-
timeout=timeout)
143+
timeout=timeout,
144+
threads=threads)
138145
stop_cmd = None
139146
else:
140147
start_cmd = stop_cmd = None

0 commit comments

Comments
(0)

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