protected ConfigurationParams getTruthTellerParams() throws ConfigurationException { ConfigurationParams params = configurationFile.getModuleConfiguration(TransformationsConfigurationParametersNames.TRUTH_TELLER_MODULE_NAME); return params; }
public ConfigurationBasedDataStructureFactory(ConfigurationFile confFile) throws ConfigurationException { textUnitParams = confFile.getModuleConfiguration(Configuration.TEXT_UNITS_DATA_STRUCTURE); coOccurrenceParams = confFile.getModuleConfiguration(Configuration.CO_OCCURRENCES_DATA_STRUCTURE); elementParams = confFile.getModuleConfiguration(Configuration.ELEMENTS_DATA_STRUCTURE); featureParams = confFile.getModuleConfiguration(Configuration.FEATURES_DATA_STRUCTURE); elementFeatureCountsParams = confFile.getModuleConfiguration(Configuration.ELEMENT_FEATURE_COUNTS_DATA_STRUCTURE); featureElementsParams = confFile.getModuleConfiguration(Configuration.FEATURE_ELEMENTS_DATA_STRUCTURE); elementFeatureScoresParams = confFile.getModuleConfiguration(Configuration.ELEMENT_FEATURE_SCORES_DATA_STRUCTURE); elementElementScoresParams = confFile.getModuleConfiguration(Configuration.ELEMENT_SCORES_DATA_STRUCTURE); }
public PredicateArgumentStructureBuilderFactoryFactory(ConfigurationFile configurationFile) throws ConfigurationException, NomlexException { this(configurationFile.getModuleConfiguration(BUILDER_MODULE_NAME)); }
@Override public RecordReader<BasicNode, LongWritable> createRecordReader(InputSplit split, TaskAttemptContext context) { try { //ConfigurationFile conf = new ConfigurationFile(context.getConfiguration().get(eu.excitementproject.eop.distsim.util.Configuration.CONFIGURATION_FILE)); ConfigurationFile conf = new ConfigurationFile(new ImplCommonConfig(new File(context.getConfiguration().get(eu.excitementproject.eop.distsim.util.Configuration.CONFIGURATION_FILE)))); return new SentenceCountingRecordReader<BasicNode>(conf.getModuleConfiguration(context.getConfiguration().get(eu.excitementproject.eop.distsim.util.Configuration.CONFIGURATION_MODULE))); } catch (Exception e) { throw new RuntimeException(e); } }
public static void main(String[] args) throws Exception { //ConfigurationFile confFile = new ConfigurationFile(args[0]); ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(args[0]))); separateFilterAndIndexElementsFeatures1(confFile.getModuleConfiguration(Configuration.MAPRED_SEPARATE_FILTER_INDEX_ELEMENT_FEATURE_1)); separateFilterAndIndexElementsFeatures2(confFile.getModuleConfiguration(Configuration.MAPRED_SEPARATE_FILTER_INDEX_ELEMENT_FEATURE_2)); }
public static Set<String> getLexicalRuleBasesForMultiWords(ConfigurationFile configurationFile) throws ConfigurationException { Set<String> ret = new LinkedHashSet<String>(); ConfigurationParams knowledgeResourcesParams = configurationFile.getModuleConfiguration(TRANSFORMATIONS_MODULE_NAME); String valueAsString = knowledgeResourcesParams.get(LEXICAL_RESOURCES_RETRIEVE_MULTIWORDS_PARAMETER_NAME); if (valueAsString.trim().length()>0) { Set<KnowledgeResource> resources = knowledgeResourcesParams.getEnumSet(KnowledgeResource.class, LEXICAL_RESOURCES_RETRIEVE_MULTIWORDS_PARAMETER_NAME); for (KnowledgeResource resource : resources) { ret.add(resource.getDisplayName()); } } return ret; }
@Override public void setup(Context context) { try { //ConfigurationFile confFile = new ConfigurationFile(context.getConfiguration().get(eu.excitementproject.eop.distsim.util.Configuration.CONFIGURATION_FILE)); ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(context.getConfiguration().get(eu.excitementproject.eop.distsim.util.Configuration.CONFIGURATION_FILE)))); ConfigurationParams confParams = confFile.getModuleConfiguration(context.getConfiguration().get(eu.excitementproject.eop.distsim.util.Configuration.CONFIGURATION_MODULE)); this.cooccurrenceExtraction = (CooccurrenceExtraction)Factory.create(confParams.get(eu.excitementproject.eop.distsim.util.Configuration.COOCCURENCE_EXTRACTION_CLASS), confParams); this.elementFeatureExtraction = (ElementFeatureExtraction)Factory.create(confParams.get(eu.excitementproject.eop.distsim.util.Configuration.ELEMENT_FEATURE_EXTRACTION_CLASS),confParams); } catch (Exception e) { throw new RuntimeException(e); } }
/** * @param args * @throws ConfigurationException * @throws ConfigurationFileDuplicateKeyException * @throws LexicalResourceException * @throws UnsupportedPosTagStringException */ public static void main(String[] args) throws ConfigurationFileDuplicateKeyException, ConfigurationException, LexicalResourceException, UnsupportedPosTagStringException { ConfigurationFile confFile = new ConfigurationFile(new File("B:/Apps/BIUTEE/workdir/biutee_train.xml")); // ConfigurationParams params = confFile.getModuleConfiguration("LinDependencySimilarity"); // AbstractSimilarityLexicalResource lexResource = new LinDistsimLexicalResource(params); // ConfigurationParams params = confFile.getModuleConfiguration("bap"); // AbstractSimilarityLexicalResource lexResource = new Direct1000LexicalResource(params); ConfigurationParams params = confFile.getModuleConfiguration("LinDependencySimilarity"); AbstractSimilarityLexicalResource lexResource = new LinProximityOriginalLexicalResource(params); String lemma = "left"; PartOfSpeech pos = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); List<LexicalRule<? extends RuleInfo>> rules = lexResource.getRulesForRight(lemma, pos); System.out.println("Found " +rules.size()+" right rules for <"+ lemma+", "+ pos+">"); for (LexicalRule<? extends RuleInfo> rule : rules) System.out.println(rule); }
@Override public void setup(Context context) { try { //ConfigurationFile confFile = new ConfigurationFile(context.getConfiguration().get(eu.excitementproject.eop.distsim.util.Configuration.CONFIGURATION_FILE)); ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig (new File(context.getConfiguration().get(eu.excitementproject.eop.distsim.util.Configuration.CONFIGURATION_FILE)))); ConfigurationParams confParams = confFile.getModuleConfiguration(context.getConfiguration().get(eu.excitementproject.eop.distsim.util.Configuration.CONFIGURATION_MODULE)); try { minCount = confParams.getLong(eu.excitementproject.eop.distsim.util.Configuration.MIN_COUNT); } catch (ConfigurationException ce) { minCount = 0; } } catch (Exception e) { throw new RuntimeException(e); } } @Override
@Override public void init() throws OperationException { if (logger.isDebugEnabled()){logger.debug("Initializing operations script: "+this.getClass().getName());} try { knowledgeResourcesParams = configurationFile.getModuleConfiguration(TRANSFORMATIONS_MODULE_NAME); List<KnowledgeResource> knowledgeResources = knowledgeResourcesParams.getEnumList(KnowledgeResource.class, KNOWLEDGE_RESOURCES_PARAMETER_NAME); createItemsForKnowledgeResources(knowledgeResources); } catch (ConfigurationException e) { throw new OperationException("Initialization failed. See nested exception.",e); } catch(RuleBaseException|ClassNotFoundException|TeEngineMlException |LexicalResourceException|IOException|SQLException e) { throw new OperationException("Could not create a rule base.",e); } }
public static void main(String args[]) throws Exception { if (args.length != 3) { System.out.println("Usage: eu.excitementproject.eop.core.component.lexicalknowledge.wordnet.WordnetLexicalResource <configuration file> <wordnet section name> <tested noun>"); System.exit(0); } ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(args[0]))); ConfigurationParams confParams = confFile.getModuleConfiguration(args[1]); WordnetLexicalResource resource = new WordnetLexicalResource(confParams); List<LexicalRule<? extends WordnetRuleInfo>> rules = resource.getRulesForRight(args[2], new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN)); for (LexicalRule<? extends WordnetRuleInfo> rule : rules) { System.out.println(rule.getLLemma() + " " + rule.getLPos()); } }
protected ConfigurationParams getParamsOfKnowledgeResource(KnowledgeResource knowledgeResource) throws TeEngineMlException, ConfigurationException { String name = knowledgeResource.getInfrastructureModuleName(); if (null==name) { name = knowledgeResource.getModuleName(); } if (null==name) throw new TeEngineMlException("null name"); return configurationFile.getModuleConfiguration(name); }
public static void main(String[] args) throws SimilarityNotFoundException, LexicalResourceException, UnsupportedPosTagStringException, ElementTypeException, FileNotFoundException, RedisRunException, eu.excitementproject.eop.common.exception.ConfigurationException { //Assumption: the running directory contains a subdirectory 'redis' with two files: redis-rever and redis.conf if (args.length != 1) { System.err.printf("Usage: %s <configuration file>\n", TestDIRTSimilarity.class.getName()); System.exit(0); } ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(args[0]))); ConfigurationParams confParams = confFile.getModuleConfiguration(Configuration.KNOWLEDGE_RESOURCE); SimilarityStorage similarityStorage = new DefaultSimilarityStorage(confParams); StringBasedElement leftElement = new StringBasedElement("n<xsubj<v:buy:v>dobj>n"); for (ElementsSimilarityMeasure similarity : similarityStorage.getSimilarityMeasure(leftElement, RuleDirection.LEFT_TO_RIGHT)) System.out.println(similarity.getLeftElement() + " --> " + similarity.getRightElement() + " : " + similarity.getSimilarityMeasure()); } }
public static void main(String[] args) throws Exception{ String term = ""; for (int i = 1; i < args.length; i++) term += (" " + args[i]); term = term.trim(); ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(args[0]))); WikipediaLexicalResource wlr = new WikipediaLexicalResource(confFile.getModuleConfiguration("WikiV3")); List<LexicalRule<? extends BaseRuleInfo>> l1 = wlr.getRulesForLeft(term, null); List<LexicalRule<? extends BaseRuleInfo>> l2 = wlr.getRulesForRight(term, null); System.out.println("\n" + term + " --> :"); for (LexicalRule<? extends BaseRuleInfo> rule : l1) System.out.println("\t" + rule.getRLemma() + ", " + rule.getConfidence()); System.out.println("\n--> " + term + ":"); for (LexicalRule<? extends BaseRuleInfo> rule : l2) System.out.println("\t" + rule.getLLemma() + ", " + rule.getConfidence()); }
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); } }
public static void main(String[] args) throws EntailmentCompilationException, ConfigurationException, ConllConverterException { if (args.length == 0) throw new EntailmentCompilationException("usage: EntailmentRuleCompiler configurationFile.xml"); ConfigurationFile confFile = new ConfigurationFile(new File(args[0])); confFile.setExpandingEnvironmentVariables(true); ConfigurationParams compilationParams = confFile.getModuleConfiguration(RuleCompilerParameterNames.RULE_COMPILER_PARAMS_MODULE); File dir = compilationParams.getDirectory(RuleCompilerParameterNames.ENTAILMENT_RULES_DIRECTORY); final String ruleFileSuffix = compilationParams.get(RuleCompilerParameterNames.RULE_FILE_SUFFIX); // create an english node rule compliler EntailmentRuleCompiler compiler = new EntailmentRuleCompiler(); Set<RuleWithConfidenceAndDescription<Info, BasicNode>> rulesWithCD = new LinkedHashSet<RuleWithConfidenceAndDescription<Info,BasicNode>>( compiler.compileFolder(dir, ruleFileSuffix)); File conllDir = new File(compilationParams.get(RuleCompilerParameterNames.CONLL_RULES_DIRECTORY)); conllDir.mkdirs(); System.out.println("Now printing " + rulesWithCD.size() + " rules into CoNLL format..."); rulesToConllFiles(rulesWithCD, conllDir, new BasicConllStringConvertor()); System.out.println("Done!"); }
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.");} } }
public static void main(String[] args) throws Exception{ ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(args[0]))); RedisBasedWikipediaLexicalResource wlr = new RedisBasedWikipediaLexicalResource(confFile.getModuleConfiguration("WikiV3")); String term = ""; for (int i = 1; i < args.length; i++) term += (" " + args[i]); term = term.trim(); List<LexicalRule<? extends WikiRuleInfo>> l1 = wlr.getRulesForLeft(term, null); List<LexicalRule<? extends WikiRuleInfo>> l2 = wlr.getRulesForRight(term, null); System.out.println("\n" + term + "--> :"); for (LexicalRule<? extends WikiRuleInfo> rule : l1) System.out.println("\t" + rule.getRLemma() + ", " + rule.getRelation() + ", " + rule.getConfidence()); System.out.println("\n--> " + term + ": "); for (LexicalRule<? extends WikiRuleInfo> rule : l2) System.out.println("\t" + rule.getLLemma() + ", " + rule.getRelation() + ", " + rule.getConfidence()); }
/** * Ctor * @throws ConfigurationException * @throws ConllConverterException */ public AnnotateSentenceToConll(ConfigurationFile confFile) throws ConfigurationException, ConllConverterException { confFile.setExpandingEnvironmentVariables(true); annotationParams = confFile.getModuleConfiguration(TransformationsConfigurationParametersNames.TRUTH_TELLER_MODULE_NAME); try { annotator = new DefaultSentenceAnnotator(annotationParams); String posTaggerString = annotationParams.get(TransformationsConfigurationParametersNames.PREPROCESS_EASYFIRST); String easyFirstHost = annotationParams.get(TransformationsConfigurationParametersNames.PREPROCESS_EASYFIRST_HOST); int easyFirstPort = annotationParams.getInt(TransformationsConfigurationParametersNames.PREPROCESS_EASYFIRST_PORT); parser = new EasyFirstParser(easyFirstHost, easyFirstPort, posTaggerString); parser.init(); } catch (Exception e) { throw new ConllConverterException("see nested", e); } String conllOutputFolderPath = annotationParams.get(TransformationsConfigurationParametersNames.CONLL_FORMAT_OUTPUT_DIRECTORY); conllOutputFolder = new File(conllOutputFolderPath); conllOutputFolder.mkdirs(); }
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; } }