Skip to content

Commit e048805

Browse files
committed
Add an option to make the srparser the default server model
1 parent 8adcbfe commit e048805

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/edu/stanford/nlp/pipeline/StanfordCoreNLP.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ tokenize.language = en
3131
# coref.algorithm = statistical
3232
# coref.md.type = dependency
3333
# coref.statistical.rankingModel = edu/stanford/nlp/models/coref/statistical/ranking_model.ser.gz
34+
35+
36+
# the server will use this by default if -srparser is set
37+
srparser.model = edu/stanford/nlp/models/srparser/englishSR.ser.gz

src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ public class StanfordCoreNLPServer implements Runnable {
9090
protected static String blockList = null;
9191
@ArgumentParser.Option(name="stanford", gloss="If true, do special options (domain blockList, timeout modifications) for public Stanford server")
9292
protected boolean stanford = false;
93+
@ArgumentParser.Option(name="srparser", gloss="If true, use the srparser by default if possible. Should save speed & memory on large queries")
94+
protected boolean srparser = false;
9395

9496
/** List of server specific properties **/
9597
private static final List<String> serverSpecificProperties = ArgumentParser.listOptions(StanfordCoreNLPServer.class);
@@ -521,6 +523,13 @@ private Properties getProperties(HttpExchange httpExchange) throws UnsupportedEn
521523
// don't enforce requirements for non-English
522524
if (!LanguageInfo.getLanguageFromString(language).equals(LanguageInfo.HumanLanguage.ENGLISH))
523525
props.setProperty("enforceRequirements", "false");
526+
// check if the server is set to use the srparser, and if so,
527+
// set the parse.model to be srparser.model
528+
// also, check properties for the srparser.model prop
529+
// perhaps some languages don't have a default set for that
530+
if (srparser && languageSpecificProperties.containsKey("srparser.model")) {
531+
props.setProperty("parse.model", languageSpecificProperties.getProperty("srparser.model"));
532+
}
524533
} catch (IOException e) {
525534
err("Failure to load language specific properties: " + languagePropertiesFile + " for " + language);
526535
}

0 commit comments

Comments
 (0)