/** * When conll() is true, coref models: * <ul> * <li>Use provided POS, NER, Parsing, etc. (instead of using CoreNLP annotators)</li> * <li>Use provided speaker annotations</li> * <li>Use provided document type and genre information</li> * </ul> */ public static boolean conll(Properties props) { return PropertiesUtils.getBool(props, "coref.conll", false); }
private void setProperties(Properties props) { trainingThreads = PropertiesUtils.getInt(props, "trainingThreads", trainingThreads); wordCutOff = PropertiesUtils.getInt(props, "wordCutOff", wordCutOff); initRange = PropertiesUtils.getDouble(props, "initRange", initRange); maxIter = PropertiesUtils.getInt(props, "maxIter", maxIter); batchSize = PropertiesUtils.getInt(props, "batchSize", batchSize); adaEps = PropertiesUtils.getDouble(props, "adaEps", adaEps); adaAlpha = PropertiesUtils.getDouble(props, "adaAlpha", adaAlpha); regParameter = PropertiesUtils.getDouble(props, "regParameter", regParameter); dropProb = PropertiesUtils.getDouble(props, "dropProb", dropProb); hiddenSize = PropertiesUtils.getInt(props, "hiddenSize", hiddenSize); embeddingSize = PropertiesUtils.getInt(props, "embeddingSize", embeddingSize); numPreComputed = PropertiesUtils.getInt(props, "numPreComputed", numPreComputed); evalPerIter = PropertiesUtils.getInt(props, "evalPerIter", evalPerIter); clearGradientsPerIter = PropertiesUtils.getInt(props, "clearGradientsPerIter", clearGradientsPerIter); saveIntermediate = PropertiesUtils.getBool(props, "saveIntermediate", saveIntermediate); unlabeled = PropertiesUtils.getBool(props, "unlabeled", unlabeled); cPOS = PropertiesUtils.getBool(props, "cPOS", cPOS); noPunc = PropertiesUtils.getBool(props, "noPunc", noPunc); doWordEmbeddingGradUpdate = PropertiesUtils.getBool(props, "doWordEmbeddingGradUpdate", doWordEmbeddingGradUpdate); sentenceDelimiter = PropertiesUtils.getString(props, "sentenceDelimiter", sentenceDelimiter); tagger = PropertiesUtils.getString(props, "tagger.model", tagger);
public static void printProperties(String message, Properties properties, PrintStream stream) { if (message != null) { stream.println(message); } if (properties.isEmpty()) { stream.println(" [empty]"); } else { List<Map.Entry<String, String>> entries = getSortedEntries(properties); for (Map.Entry<String, String> entry : entries) { if ( ! "".equals(entry.getKey())) { stream.format(" %-30s = %s%n", entry.getKey(), entry.getValue()); } } } stream.println(); }
public POSTaggerAnnotator(String annotatorName, Properties props) { String posLoc = props.getProperty(annotatorName + ".model"); if (posLoc == null) { posLoc = DefaultPaths.DEFAULT_POS_MODEL; } boolean verbose = PropertiesUtils.getBool(props, annotatorName + ".verbose", false); this.pos = loadModel(posLoc, verbose); this.maxSentenceLength = PropertiesUtils.getInt(props, annotatorName + ".maxlen", Integer.MAX_VALUE); this.nThreads = PropertiesUtils.getInt(props, annotatorName + ".nthreads", PropertiesUtils.getInt(props, "nthreads", 1)); this.reuseTags = PropertiesUtils.getBool(props, annotatorName + ".reuseTags", false); }
public DependencyParseAnnotator(Properties properties) { String modelPath = PropertiesUtils.getString(properties, "model", DependencyParser.DEFAULT_MODEL); parser = DependencyParser.loadFromModelFile(modelPath, properties); nThreads = PropertiesUtils.getInt(properties, "nthreads", DEFAULT_NTHREADS); maxTime = PropertiesUtils.getLong(properties, "sentenceTimeout", DEFAULT_MAXTIME); extraDependencies = MetaClass.cast(properties.getProperty("extradependencies", "NONE"), GrammaticalStructure.Extras.class); }
public Options(Properties properties) { includeText = PropertiesUtils.getBool(properties, "output.includeText", false); encoding = properties.getProperty("encoding", "UTF-8"); pretty = PropertiesUtils.getBool(properties, "output.prettyPrint", true); String constituencyTreeStyle = properties.getProperty("output.constituencyTree", "penn"); constituencyTreePrinter = new TreePrint(constituencyTreeStyle); String dependencyTreeStyle = properties.getProperty("output.dependencyTree", "typedDependenciesCollapsed"); dependencyTreePrinter = new TreePrint(dependencyTreeStyle); coreferenceContextSize = PropertiesUtils.getInt(properties,"output.coreferenceContextSize", 0); printSingletons = PropertiesUtils.getBool(properties, "output.printSingletonEntities", false); relationsBeam = PropertiesUtils.getDouble(properties, "output.relation.beam", 0.0); keysToPrint = getKeysToPrint(properties.getProperty("output.columns", DEFAULT_KEYS)); }
Language language = PropertiesUtils.get(options, "l", Language.English, Language.class); final TreebankLangParserParams tlpp = language.params; final int maxGoldYield = PropertiesUtils.getInt(options, "y", Integer.MAX_VALUE); final boolean VERBOSE = PropertiesUtils.getBool(options, "v", false); final boolean sortByF1 = PropertiesUtils.hasProperty(options, "s"); int worstKTreesToEmit = PropertiesUtils.getInt(options, "s", 0); PriorityQueue<Triple<Double,Tree,Tree>> queue = sortByF1 ? new PriorityQueue<>(2000, new F1Comparator()) : null; boolean doCatLevel = PropertiesUtils.getBool(options, "c", false); String labelRegex = options.getProperty("f", null); String encoding = options.getProperty("e", "UTF-8");
PropertiesUtils.getBool(properties, NERClassifierCombiner.APPLY_NUMERIC_CLASSIFIERS_PROPERTY, NERClassifierCombiner.APPLY_NUMERIC_CLASSIFIERS_DEFAULT); PropertiesUtils.getBool(properties, NumberSequenceClassifier.USE_SUTIME_PROPERTY, NumberSequenceClassifier.USE_SUTIME_DEFAULT); NERClassifierCombiner.Language nerLanguage = NERClassifierCombiner.Language.fromString(PropertiesUtils.getString(properties, NERClassifierCombiner.NER_LANGUAGE_PROPERTY, null), NERClassifierCombiner.NER_LANGUAGE_DEFAULT); boolean verbose = PropertiesUtils.getBool(properties, "ner." + "verbose", false); Properties combinerProperties = PropertiesUtils.extractSelectedProperties(properties, NERClassifierCombiner.DEFAULT_PASS_DOWN_PROPERTIES); if (useSUTime) { Properties sutimeProps = PropertiesUtils.extractPrefixedProperties(properties, NumberSequenceClassifier.SUTIME_PROPERTY + '.', true); PropertiesUtils.overWriteProperties(combinerProperties, sutimeProps); this.nThreads = PropertiesUtils.getInt(properties, "ner.nthreads", PropertiesUtils.getInt(properties, "nthreads", 1)); this.maxTime = PropertiesUtils.getLong(properties, "ner.maxtime", 0); this.maxSentenceLength = PropertiesUtils.getInt(properties, "ner.maxlen", Integer.MAX_VALUE); this.language = LanguageInfo.getLanguageFromString(PropertiesUtils.getString(properties, "ner.language", "en"));
throw new IllegalArgumentException("No model specified for Parser annotator " + annotatorName); this.VERBOSE = PropertiesUtils.getBool(props, annotatorName + ".debug", false); this.maxSentenceLength = PropertiesUtils.getInt(props, annotatorName + ".maxlen", -1); this.maxParseTime = PropertiesUtils.getLong(props, annotatorName + ".maxtime", -1); this.kBest = PropertiesUtils.getInt(props, annotatorName + ".kbest", 1); this.keepPunct = PropertiesUtils.getBool(props, annotatorName + ".keepPunct", true); if (PropertiesUtils.getBool(props, buildGraphsProperty)) { log.info("WARNING: " + buildGraphsProperty + " set to true, but " + this.parser.getTLPParams().getClass() + " does not support dependencies"); this.BUILD_GRAPHS = PropertiesUtils.getBool(props, buildGraphsProperty, true); boolean generateOriginalDependencies = PropertiesUtils.getBool(props, annotatorName + ".originalDependencies", false); parser.getTLPParams().setGenerateOriginalDependencies(generateOriginalDependencies); TreebankLanguagePack tlp = parser.getTLPParams().treebankLanguagePack(); this.nThreads = PropertiesUtils.getInt(props, annotatorName + ".nthreads", PropertiesUtils.getInt(props, "nthreads", 1)); boolean usesBinary = StanfordCoreNLP.usesBinaryTrees(props); this.saveBinaryTrees = PropertiesUtils.getBool(props, annotatorName + ".binaryTrees", usesBinary); this.noSquash = PropertiesUtils.getBool(props, annotatorName + ".nosquash", false); this.extraDependencies = MetaClass.cast(props.getProperty(annotatorName + ".extradependencies", "NONE"), GrammaticalStructure.Extras.class);
System.exit(-1); int maxLen = PropertiesUtils.getInt(options, "y", Integer.MAX_VALUE); boolean printTrees = PropertiesUtils.getBool(options, "p", false); boolean flattenTrees = PropertiesUtils.getBool(options, "f", false); boolean printPOS = PropertiesUtils.getBool(options, "a", false); boolean printTnT = PropertiesUtils.getBool(options, "t", false); Language language = PropertiesUtils.get(options, "l", Language.English, Language.class); TreebankLangParserParams tlpp = language.params; String encoding = options.getProperty("e", "UTF-8");
/** * Load a double property. If the key is not present, returns 0.0. */ public static double getDouble(Properties props, String key) { return getDouble(props, key, 0.0); }
public static int maxTrainExamplesPerDocument(Properties props) { return PropertiesUtils.getInt(props, "coref.statistical.maxTrainExamplesPerDocument", Integer.MAX_VALUE); } }
try { boolean applyNumericClassifiers = PropertiesUtils.getBool(properties, prefix + APPLY_NUMERIC_CLASSIFIERS_PROPERTY_BASE, APPLY_NUMERIC_CLASSIFIERS_DEFAULT); boolean useSUTime = PropertiesUtils.getBool(properties, prefix + NumberSequenceClassifier.USE_SUTIME_PROPERTY_BASE, NumberSequenceClassifier.USE_SUTIME_DEFAULT); combinerProperties = PropertiesUtils.extractSelectedProperties(properties, passDownProperties); if (useSUTime) { Properties sutimeProps = PropertiesUtils.extractPrefixedProperties(properties, NumberSequenceClassifier.SUTIME_PROPERTY + ".", true); PropertiesUtils.overWriteProperties(combinerProperties, sutimeProps);
/** * Set up the fine-grained TokensRegexNERAnnotator sub-annotator * * @param properties Properties for the TokensRegexNER sub-annotator */ public void setUpFineGrainedNER(Properties properties) { // set up fine grained ner this.applyFineGrained = PropertiesUtils.getBool(properties, "ner.applyFineGrained", true); if (this.applyFineGrained) { String fineGrainedPrefix = "ner.fine.regexner"; Properties fineGrainedProps = PropertiesUtils.extractPrefixedProperties(properties, fineGrainedPrefix+".", true); // explicity set fine grained ner default here if (!fineGrainedProps.containsKey("ner.fine.regexner.mapping")) fineGrainedProps.setProperty("ner.fine.regexner.mapping", DefaultPaths.DEFAULT_KBP_TOKENSREGEX_NER_SETTINGS); // build the fine grained ner TokensRegexNERAnnotator fineGrainedNERAnnotator = new TokensRegexNERAnnotator(fineGrainedPrefix, fineGrainedProps); } }
public static void printProperties(String message, Properties properties) { printProperties(message, properties, System.out); }
/** * Build a {@code Properties} object containing key-value pairs from * the given data where the keys are prefixed with the given * {@code prefix}. The keys in the returned object will be stripped * of their common prefix. * * @param properties Key-value data from which to extract pairs * @param prefix Key-value pairs where the key has this prefix will * be retained in the returned {@code Properties} object * @return A Properties object containing those key-value pairs from * {@code properties} where the key was prefixed by * {@code prefix}. This prefix is removed from all keys in * the returned structure. */ public static Properties extractPrefixedProperties(Properties properties, String prefix) { return extractPrefixedProperties(properties, prefix, false); }
String nameOfDataset = PropertiesUtils.hasProperty(dsParams, ConfigParser.paramName) ? dsParams.getProperty(ConfigParser.paramName) : "UN-NAMED";
public static List<Map.Entry<String, String>> getSortedEntries(Properties properties) { return Maps.sortedEntries(asMap(properties)); }
System.exit(-1); Language language = PropertiesUtils.get(options, "l", Language.English, Language.class); TreebankLangParserParams tlpp = language.params; String encoding = options.getProperty("e", "UTF-8");