edu.stanford.nlp.coref.statistical.StatisticalCorefProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stanford-corenlp Show documentation
Show all versions of stanford-corenlp Show documentation
Stanford CoreNLP provides a set of natural language analysis tools which can take raw English language text input and give the base forms of words, their parts of speech, whether they are names of companies, people, etc., normalize dates, times, and numeric quantities, mark up the structure of sentences in terms of phrases and word dependencies, and indicate which noun phrases refer to the same entities. It provides the foundational building blocks for higher level text understanding applications.
package edu.stanford.nlp.coref.statistical;
import java.util.Arrays;
import java.util.Properties;
import edu.stanford.nlp.coref.CorefProperties;
import edu.stanford.nlp.util.PropertiesUtils;
/**
* Manages the properties for training and running statistical coreference systems.
* @author Kevin Clark
*/
public class StatisticalCorefProperties {
public static String trainingPath(Properties props) {
return props.getProperty("coref.statistical.trainingPath");
}
private static String getDefaultModelPath(Properties props, String modelName) {
return "edu/stanford/nlp/models/coref/statistical/" + modelName +
(CorefProperties.conll(props) ? "_conll" : "") + ".ser.gz";
}
public static String classificationModelPath(Properties props) {
return PropertiesUtils.getString(props, "coref.statistical.classificationModel",
getDefaultModelPath(props, "classification_model"));
}
public static String rankingModelPath(Properties props) {
return PropertiesUtils.getString(props, "coref.statistical.rankingModel",
getDefaultModelPath(props, "ranking_model"));
}
public static String anaphoricityModelPath(Properties props) {
return PropertiesUtils.getString(props, "coref.statistical.anaphoricityModel",
getDefaultModelPath(props, "anaphoricity_model"));
}
public static String clusteringModelPath(Properties props) {
return PropertiesUtils.getString(props, "coref.statistical.clusteringModel",
getDefaultModelPath(props, "clustering_model"));
}
public static String wordCountsPath(Properties props) {
return PropertiesUtils.getString(props, "coref.statistical.wordCounts",
"edu/stanford/nlp/models/coref/statistical/word_counts.ser.gz");
}
public static double[] pairwiseScoreThresholds(Properties props) {
String thresholdsProp = props.getProperty("coref.statistical.pairwiseScoreThresholds");
if (thresholdsProp != null) {
String[] split = thresholdsProp.split(",");
if (split.length == 4) {
return Arrays.stream(split).mapToDouble(Double::parseDouble).toArray();
}
}
double threshold = PropertiesUtils.getDouble(
props, "coref.statistical.pairwiseScoreThresholds", 0.35);
return new double[] {threshold, threshold, threshold, threshold};
}
public static double minClassImbalance(Properties props) {
return PropertiesUtils.getDouble(props, "coref.statistical.minClassImbalance", 0);
}
public static int maxTrainExamplesPerDocument(Properties props) {
return PropertiesUtils.getInt(props, "coref.statistical.maxTrainExamplesPerDocument",
Integer.MAX_VALUE);
}
}