/** * Populate with the given properties all static options in all classes in the current classpath. * Note that this may take a while if the classpath is large. * * @param props The properties to use to fill fields in the various classes. */ public static void fillOptions(Properties props) { fillOptions(props, StringUtils.EMPTY_STRING_ARRAY); }
/** * Fill all non-static {@link Option}-tagged fields in the given object with the given * properties. * * @param instance The object instance containing {@link Option}-tagged fields which we should fill. * @param options The properties to use to fill these fields. */ public static void fillOptions(Object instance, Properties options) { fillOptions(new Object[]{ instance }, options); }
/** * Fill all non-static {@link Option}-tagged fields in the given object with the given * command-line arguments. * * @param instance The object instance containing {@link Option}-tagged fields which we should fill. * @param args The command-line arguments to use to fill these fields. */ public static void fillOptions(Object instance, String... args) { fillOptions(new Object[]{ instance }, args); }
public InvertedIndexByTokens(Properties props, Set<String> stopWords, Function<CoreLabel, Map<String, String>> transformSentenceToString, Map<String, Set<String>> index) { super(stopWords, transformSentenceToString); ArgumentParser.fillOptions(this, props); this.index = index; }
/** * Create a new annotator. * @param annotatorName The prefix for the properties for this annotator. * @param props The properties to configure this annotator with. */ public NaturalLogicAnnotator(String annotatorName, Properties props) { ArgumentParser.fillOptions(this, annotatorName, props); }
/** * Populate all static options in the given class, as defined by the given * command-line arguments. * * @param clazz The class to populate static {@link Option}-tagged fields in. * @param args The command-line arguments to use to fill these fields. */ public static void fillOptions(Class<?> clazz, String... args) { Class<?>[] classes = new Class<?>[1]; classes[0] = clazz; fillOptions(classes, args); }
/** * Populate all static {@link Option}-tagged fields in the given classes with the given Properties. * Then, fill in additional (or overwrite existing) properties with the given (String) command-line arguments. * * @param optionClasses The classes to populate static {@link Option}-tagged fields in. * @param props The properties to use to fill these fields. * @param args The command-line arguments to use to fill in additional properties. */ @SuppressWarnings("UnusedDeclaration") public static void fillOptions(Class<?>[] optionClasses, Properties props, String... args) { ArgumentParser.optionClasses = optionClasses; fillOptions(props, args); }
public void setUp(Properties props) { ArgumentParser.fillOptions(this, props); }
public InvertedIndexByTokens(Properties props, Set<String> stopWords, Function<CoreLabel, Map<String, String>> transformSentenceToString) { super(stopWords, transformSentenceToString); ArgumentParser.fillOptions(this, props); index = new HashMap<>(); }
public LuceneSentenceIndex(Properties props, Set<String> stopWords, String indexDirStr, Function<CoreLabel, Map<String, String>> transformer) { super(stopWords, transformer); ArgumentParser.fillOptions(this, props); indexDir = new File(indexDirStr); }
public ScorePhrases(Properties props, ConstantsAndVariables cv){ ArgumentParser.fillOptions(this, props); this.constVars = cv; try { phraseScorer = phraseScorerClass .getConstructor(ConstantsAndVariables.class).newInstance(constVars); } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new RuntimeException(e); } ArgumentParser.fillOptions(phraseScorer, props); }
public static SentenceIndex createIndex(Class<? extends SentenceIndex> indexClass, Map<String, List<CoreLabel>> sents, Properties props, Set<String> stopWords, String indexDirectory, Function<CoreLabel, Map<String, String>> transformCoreLabeltoString) { try { ArgumentParser.fillOptions(SentenceIndex.class, props); Method m = indexClass.getMethod("createIndex", Map.class, Properties.class, Set.class, String.class, Function.class); SentenceIndex index = (SentenceIndex) m.invoke(null, new Object[]{sents, props, stopWords, indexDirectory, transformCoreLabeltoString}); return index; } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException(e); } }
public static SentenceIndex loadIndex(Class<? extends SentenceIndex> indexClass, Properties props, Set<String> stopWords, String indexDirectory, Function<CoreLabel, Map<String, String>> transformCoreLabeltoString){ try { ArgumentParser.fillOptions(SentenceIndex.class, props); Method m = indexClass.getMethod("loadIndex", Properties.class, Set.class, String.class, Function.class); SentenceIndex index = (SentenceIndex) m.invoke(null, new Object[]{props, stopWords, indexDirectory, transformCoreLabeltoString}); return index; } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException(e); } } }
static public void setUp(Properties props){ ArgumentParser.fillOptions(DepPatternFactory.class, props); ArgumentParser.fillOptions(PatternFactory.class, props); for(String s: ignoreRels.split("[,;]")){ ignoreRelsSet.add(GrammaticalRelation.valueOf(s)); } for(String s: allowedTagsForTrigger.split("[,;]")){ allowedTagPatternForTrigger.add(Pattern.compile(s)); } }
public PatternsForEachTokenInMemory(Properties props, Map<String, Map<Integer, Set<E>>> pats) { ArgumentParser.fillOptions(this, props); //TODO: make this atomic if(patternsForEachToken == null) patternsForEachToken = new ConcurrentHashMap<>(); if (pats != null) addPatterns(pats); }
/** * Populate with the given command-line arguments all static options in all * classes in the current classpath. * Note that this may take a while if the classpath is large. * * @param args The command-line arguments to use to fill options. */ public static void fillOptions(String... args) { fillOptions(StringUtils.argsToProperties(args), StringUtils.EMPTY_STRING_ARRAY); }
/** * Populate all static options in the given class, as defined by the given properties. * Then, fill in additional (or overwrite existing) properties with the given (String) command-line arguments. * * @param instance The object instance containing {@link Option}-tagged fields which we should fill. * @param props The properties to use to fill these fields. * @param args Additional command-line options to fill these fields. */ public static void fillOptions(Object instance, Properties props, String... args) { Properties allProperties = updatePropertiesWithOptions(props, args); fillOptions(new Object[]{ instance }, allProperties); }
public CreatePatterns(Properties props, ConstantsAndVariables constVars) throws IOException { this.constVars = constVars; ArgumentParser.fillOptions(ConstantsAndVariables.class, props); constVars.setUp(props); setUp(props); }
public static void main(String[] args) throws IOException { RedwoodConfiguration.standard().apply(); // Disable SLF4J crap. ArgumentParser.fillOptions(KBPTokensregexExtractor.class, args); KBPTokensregexExtractor extractor = new KBPTokensregexExtractor(DIR); List<Pair<KBPInput, String>> testExamples = KBPRelationExtractor.readDataset(TEST_FILE); extractor.computeAccuracy(testExamples.stream(), PREDICTIONS.map(x -> { try { return "stdout".equalsIgnoreCase(x) ? System.out : new PrintStream(new FileOutputStream(x)); } catch (IOException e) { throw new RuntimeIOException(e); } })); }
public static void main(String[] args) throws IOException { RedwoodConfiguration.standard().apply(); // Disable SLF4J crap. ArgumentParser.fillOptions(KBPSemgrexExtractor.class, args); KBPSemgrexExtractor extractor = new KBPSemgrexExtractor(DIR); List<Pair<KBPInput, String>> testExamples = KBPRelationExtractor.readDataset(TEST_FILE); extractor.computeAccuracy(testExamples.stream(), PREDICTIONS.map(x -> { try { return "stdout".equalsIgnoreCase(x) ? System.out : new PrintStream(new FileOutputStream(x)); } catch (IOException e) { throw new RuntimeIOException(e); } })); }