private boolean isHybridMode() throws ConfigurationException { boolean hybridMode = false; if (configurationParams.containsKey(RTE_ENGINE_GAP_HYBRID_MODE)) { hybridMode = configurationParams.getBoolean(RTE_ENGINE_GAP_HYBRID_MODE); } return hybridMode; }
protected boolean userRequiresAnnotations(ConfigurationParams params) throws ConfigurationException { boolean ret = true; if (params.containsKey(TransformationsConfigurationParametersNames.USER_REQUIRES_ANNOTATIONS)) { ret = params.getBoolean(TransformationsConfigurationParametersNames.USER_REQUIRES_ANNOTATIONS); } return ret; }
private WhichClassifier inferWhichClassifier(String rGuess_orDummy_parameter, String modelParameter) throws ConfigurationException, TeEngineMlException { WhichClassifier which = null; if (configurationParams.containsKey(rGuess_orDummy_parameter)) { which=configurationParams.getBoolean(rGuess_orDummy_parameter)?WhichClassifier.REASONABLE_GUESS_OR_DUMMY:null; } if (null==which) { if (configurationParams.containsKey(modelParameter)) { which=WhichClassifier.XML_MODEL; } } if (null==which) { if (null==useF1Classifier_FalseForAccuracy_NullForXMLModelFile) throw new TeEngineMlException("Cannot infer which classifier to use. Please fix the configuration file."); if (useF1Classifier_FalseForAccuracy_NullForXMLModelFile) { which = WhichClassifier.FROM_SAMPLES_F1; } else { which = WhichClassifier.FROM_SAMPLES_ACCURACY; } } return which; }
public static EnglishSingleTreeParser getParser(ConfigurationParams params) throws TeEngineMlException, ParserRunException, ConfigurationException if ( (params.containsKey(PREPROCESS_EASYFIRST)) && (params.containsKey(PREPROCESS_MINIPAR)) ) throw new TeEngineMlException("The configuration file specify both easy first and minipar parsers, but only one of them should be specified, not both!"); if (params.containsKey(PREPROCESS_EASYFIRST)) String host=null; Integer port=null; if (params.containsKey(ConfigurationParametersNames.PREPROCESS_EASYFIRST_HOST)) host = params.get(ConfigurationParametersNames.PREPROCESS_EASYFIRST_HOST); if (params.containsKey(ConfigurationParametersNames.PREPROCESS_EASYFIRST_PORT)) port = params.getInt(ConfigurationParametersNames.PREPROCESS_EASYFIRST_PORT); else if (params.containsKey(PREPROCESS_MINIPAR))
public PredicateArgumentStructureBuilderFactoryFactory(ConfigurationParams params) throws ConfigurationException, NomlexException { this.nomlexMap = createNomlexMapFromConfigurationParams(params); PastaMode modeInConfiguration = null; if (params.containsKey(MODE_PARAMETER_NAME)) { modeInConfiguration = params.getEnum(PastaMode.class, MODE_PARAMETER_NAME); } else { modeInConfiguration = PastaMode.BASIC; } this.mode = modeInConfiguration; }
private Boolean readClassifierOptimizationParameter() throws ConfigurationException, TeEngineMlException { Boolean ret = null; if (configurationParams.containsKey(ConfigurationParametersNames.RTE_ENGINE_CLASSIFIER_OPTIMIZATION_PARAMETER_NAME)) { String value = configurationParams.getString(ConfigurationParametersNames.RTE_ENGINE_CLASSIFIER_OPTIMIZATION_PARAMETER_NAME); if (value.equalsIgnoreCase(BiuteeConstants.CLASSIFIER_OPTIMIZATION_ACCURACY_PARAMETER_VALUE)) { ret = false; } else if (value.equalsIgnoreCase(BiuteeConstants.CLASSIFIER_OPTIMIZATION_F1_PARAMETER_VALUE)) { ret = true; } else { throw new TeEngineMlException("The parameter value \""+value+"\" is illegal for the parameter \""+ConfigurationParametersNames.RTE_ENGINE_CLASSIFIER_OPTIMIZATION_PARAMETER_NAME+"." + "\nPlease remove this parameter from the configuration file, or use one of the following parameters: \"" + BiuteeConstants.CLASSIFIER_OPTIMIZATION_ACCURACY_PARAMETER_VALUE+"\" or \""+BiuteeConstants.CLASSIFIER_OPTIMIZATION_F1_PARAMETER_VALUE+"\"."); } } return ret; }
if (configurationParams.containsKey(RTE_SUM_IS_NOVELTY_TASK_FLAG)) isNoveltyTask = configurationParams.getBoolean(RTE_SUM_IS_NOVELTY_TASK_FLAG); logger.info("Loading " + (isNoveltyTask ? "Novelty" : "Main") + " task files");
if (configurationParams.containsKey(RTE_SUM_IS_NOVELTY_TASK_FLAG)) isNoveltyTask = configurationParams.getBoolean(RTE_SUM_IS_NOVELTY_TASK_FLAG); logger.info("Loading " + (isNoveltyTask ? "Novelty" : "Main") + " task files");
public static PARSER setParserMode(ConfigurationParams params) throws ConfigurationException, TeEngineMlException { if (params.containsKey(ConfigurationParametersNames.RTE_ENGINE_PARSER_PARAMETER_NAME)) { PARSER parser = params.getEnum(PARSER.class, ConfigurationParametersNames.RTE_ENGINE_PARSER_PARAMETER_NAME); logger.info("Setting parser to "+parser.name()); ParserSpecificConfigurations.changeParser(parser); return parser; } else { throw new TeEngineMlException("Parser mode parameters missing."); //logger.warn("Parser mode not set. Using default: "+ParserSpecificConfigurations.getParserMode().name()); } }
protected void registerPlugins(PluginRegistry pluginRegistry) throws TeEngineMlException, ConfigurationException { try { ConfigurationParams params = configurationFile.getModuleConfiguration(ConfigurationParametersNames.TRANSFORMATIONS_MODULE_NAME); if (params.containsKey(ConfigurationParametersNames.PLUGIN_REGISTERER_PARAMETER_NAME)) { String pluginRegistererClassName = params.get(ConfigurationParametersNames.PLUGIN_REGISTERER_PARAMETER_NAME); @SuppressWarnings("unchecked") Class<? extends PluginRegisterer> classPluginRegisterer = (Class<? extends PluginRegisterer>) Class.forName(pluginRegistererClassName); Constructor<? extends PluginRegisterer> constructor = classPluginRegisterer.getConstructor(ConfigurationFile.class,PluginRegistry.class); PluginRegisterer pluginRegisterer = constructor.newInstance(this.configurationFile,pluginRegistry); pluginRegisterer.register(); } pluginRegistry.sealRegistry(); } catch(RuntimeException | NoSuchMethodException | IllegalAccessException | InvocationTargetException | PluginException | ClassNotFoundException | PluginAdministrationException | InstantiationException e) { throw new TeEngineMlException("Failed to register plugins",e); } }
if (params.containsKey("table_file")) { return mapFromTwoColumnsText( FileUtils.loadFileOrUrlToList(params.getString("table_file")), params.getString("table_separator")); } else if (params.containsKey("table_contents")) { return mapFromTwoColumnsText( params.getString("table_contents").split("[\n\r]+"), params.getString("table_separator")); } else if (params.containsKey("wiki_file")) { return mapFromWikiText( FileUtils.loadFileOrUrlToList(params.getString("wiki_file")), params.containsKey("add_heading_to_heading_match")? params.getBoolean("add_heading_to_heading_match"): false, params.containsKey("headings_are_keys")? params.getBoolean("headings_are_keys"): false ); } else if (params.containsKey("wiki_contents")) { return mapFromWikiText( params.getString("wiki_contents").split("[\n\r]+"), params.containsKey("add_heading_to_heading_match")? params.getBoolean("add_heading_to_heading_match"): false, params.containsKey("headings_are_keys")? params.getBoolean("headings_are_keys"): false ); } else {
private void readExcludeList() throws OperationException { try { ConfigurationParams transformationsParameters = configurationFile.getModuleConfiguration(ConfigurationParametersNames.TRANSFORMATIONS_MODULE_NAME); if (transformationsParameters.containsKey(ConfigurationParametersNames.EXCLUDE_TRANSFORMATIONS_PARAMETER_NAME)) { excludeTransformations = Collections.unmodifiableSet(transformationsParameters.getEnumSet(SingleOperationType.class, ConfigurationParametersNames.EXCLUDE_TRANSFORMATIONS_PARAMETER_NAME)); } else { excludeTransformations = Collections.<SingleOperationType>unmodifiableSet(Collections.<SingleOperationType>emptySet()); } } catch(ConfigurationException e) { throw new OperationException("Failed to initialize.",e); } for (SingleOperationType operation : excludeTransformations) { if (operation.isRuleApplication()) {throw new OperationException("Illegal value for parameter "+ConfigurationParametersNames.EXCLUDE_TRANSFORMATIONS_PARAMETER_NAME+". Rule application operation type should not be specified in this parameter.");} } }
/** * Create an initialized NamedEntityRecognizer using the given configuration params. */ public static NamedEntityRecognizer createNamedEntityRecognizer(ConfigurationParams params) throws InstrumentCombinationException{ boolean doNer; try { doNer = (params.containsKey("do_named_entity_recognition")? params.getBoolean("do_named_entity_recognition"): false); if (doNer) { NamedEntityRecognizer ner = new StanfordNamedEntityRecognizer(new File(params.getFile("ner-classifier-path").getAbsolutePath())); ner.init(); return ner; } else return null; } catch (ConfigurationException e) { throw new InstrumentCombinationException("Nested exception with configuration file while initializing the NER", e); } catch (NamedEntityRecognizerException e) { throw new InstrumentCombinationException("Nested exception while initializing the NER", e); } } }
private void readConfigurationFile() throws ConfigurationFileDuplicateKeyException, ConfigurationException, NumberFormatException, TeEngineMlException, ParserRunException, NamedEntityRecognizerException, TextPreprocessorException { configurationFile = SystemInitialization.loadConfigurationFile(this.configurationFileName); configurationFile.setExpandingEnvironmentVariables(true); ConfigurationParams params = configurationFile.getModuleConfiguration(RTE_PAIRS_PREPROCESS_MODULE_NAME); instruments = new InstrumentsFactory().getDefaultInstruments(params); if (params.containsKey(PREPROCESS_DO_NER)) { doNer = params.getBoolean(PREPROCESS_DO_NER); } else { doNer = true; } if (params.containsKey(PREPROCESS_DO_TEXT_NORMALIZATION)) { doTextNormalization = params.getBoolean(PREPROCESS_DO_TEXT_NORMALIZATION); } else { doTextNormalization=true; } }
/** * Build a string-to-string bidirectional multi-map according to the specification in the given configuration params. * * @param params * <p>should include EITHER the following params: * <li>table_file - path or URL of a text-file that contains the map, in two-column format; see {@link #mapFromTwoColumnsText}. * <li><li>(can be replaced with table_contents - the contents of the file) * <li>table_separator - the pattern that separates between the columns in the file, e.g. "->". * <p>OR the following params: * <li>wiki_file - path or URL of a text-file that contains the map, in wiki-text format; see {@link #mapFromWikiText}. * <li><li>(can be replaced with wiki_contents - the contents of the file) * * @return a map built from that text file. * @throws ConfigurationException * @throws IOException */ public static Map<String,ValueSetMap<String,String>> mapOfMapsFromConfigurationParams(ConfigurationParams params) throws IOException, ConfigurationException { if (params.containsKey("file")) { return mapOfMapsFromText( FileUtils.loadFileOrUrlToList(params.getString("file")), params.getString("table_separator")); } else if (params.containsKey("contents")) { return mapOfMapsFromText( params.getString("contents").split("[\n\r]+"), params.getString("table_separator")); } else { throw new ConfigurationException("configuration params should contain either 'file' or 'contents' ("+params+")"); } }
public WordnetLexicalResource(ConfigurationParams params) throws LexicalResourceException, ConfigurationException { this( params.getDirectory(PARAM_WN_DIR), params.getBoolean(PARAM_ONLY_FIRST_LEFT), params.getBoolean(PARAM_ONLY_FIRST_RIGHT), params.getEnumSet(WordNetRelation.class, PARAM_DEFAULT_RELATIONS), params.getInt(PARAM_CHAINING_LENGTH), params.containsKey(PARAM_WORDNET_DICTIONARY_IMPLEMENTATION_TYPE) ? params.getEnum(WordnetDictionaryImplementationType.class, PARAM_WORDNET_DICTIONARY_IMPLEMENTATION_TYPE) : null); }
if (params.containsKey("easyfirst_stanford_pos_tagger")){ stanfordPosTaggerModel = params.get("easyfirst_stanford_pos_tagger"); posTagger = new MaxentPosTagger(stanfordPosTaggerModel);
if (knowledgeResourcesParams.containsKey(ConfigurationParametersNames.PLUGINS_TO_APPLY))
loadFromSerFile = params.containsKey(TransformationsConfigurationParametersNames.DIRT_LIKE_SER_FILE_PARAMETER_NAME);
if (params.containsKey(PREPROCESS_DO_NER)) doNer = params.getBoolean(PREPROCESS_DO_NER); else doNer = true; if (params.containsKey(PREPROCESS_DO_TEXT_NORMALIZATION)) doTextNormalization = params.getBoolean(PREPROCESS_DO_TEXT_NORMALIZATION); else