@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 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 static void annotateByCommandLineArguments(String[] args) throws AnnotatorException, ConfigurationFileDuplicateKeyException, ConfigurationException, ParserRunException, ConllConverterException, SentenceSplitterException, FileNotFoundException, IOException { if (args.length < (1)) throw new AnnotatorException(String.format("usage: %s configurationFile.xml sentence(s)", AnnotateSentenceToConll.class.getSimpleName())); List<String> argsList = Utils.arrayToCollection(args, new Vector<String>()); Iterator<String> argsIterator = argsList.iterator(); ConfigurationFile confFile = new ConfigurationFile(new File(argsIterator.next())); confFile.setExpandingEnvironmentVariables(true); AnnotateSentenceToConll app = new AnnotateSentenceToConll(confFile); Iterable<String> sentencesToAnnotate = getSentencesIterable(argsIterator,app); List<ExtendedNode> list = new ArrayList<ExtendedNode>(); for (String sentence : sentencesToAnnotate) { ExtendedNode annotatedSentece = app.annotateSentece(sentence); list.add(annotatedSentece); } AnnotatedTreeToConllCoverter.treesToConllFiles(list, app.conllOutputFolder, CONLL_CONVERTER); } }
protected ConfigurationParams getTruthTellerParams() throws ConfigurationException { ConfigurationParams params = configurationFile.getModuleConfiguration(TransformationsConfigurationParametersNames.TRUTH_TELLER_MODULE_NAME); return params; }
/** * 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(); }
ConfigurationParams resourceParams = configurationFile.getModuleConfiguration(moduleName); DirtDBRuleBase ruleBase = DirtDBRuleBase.fromConfigurationParams(resource.getDisplayName(), configurationFile.getModuleConfiguration(resource.getModuleName()),parser); listDirtDbRuleBases.add(ruleBase); ruleBasesEnvelopes.put(resource.getDisplayName(),new RuleBaseEnvelope<Info, BasicNode>(ruleBase)); logger.info("Building LexicalChainRuleBase..."); if (logger.isDebugEnabled())logger.debug("The display name for the LexicalChainRuleBase is: "+resource.getDisplayName()); ConfigurationFile configurationFile = new ConfigurationFile(this.configurationFile.getConfFile()); ConfigurationParams configurationParams = configurationFile.getModuleConfiguration(resource.getModuleName()); graphBasedLexicalChainRuleBase = new PlisRuleBase(configurationParams); RuleBaseEnvelope<Info, BasicNode> lexicalChainEnvelope = createEnvelopeForLexicalChain(graphBasedLexicalChainRuleBase, graphBasedLexicalChainRuleBase.getRuleBasesNames());
public ConfigurationBasedDataStructureFactory(CommonConfig conf) throws ConfigurationException { this(new ConfigurationFile(conf)); }
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); }
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; } }
public static ConfigurationFile loadConfigurationFile(String configurationFileName) throws ConfigurationException { try { return new ConfigurationFile(new ImplCommonConfig(new File(configurationFileName))); } catch (eu.excitementproject.eop.common.exception.ConfigurationException e) { throw new ConfigurationException("Failed to load configuration file. Please see nested exception.",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)); }
ConfigurationFile confFile = new ConfigurationFile(new File(configurationFileName)); confFile.setExpandingEnvironmentVariables(true); WordnetLexicalResource wnLexR = new WordnetLexicalResource(confFile.getModuleConfiguration(moduleName));
public PredicateArgumentStructureBuilderFactoryFactory(ConfigurationFile configurationFile) throws ConfigurationException, NomlexException { this(configurationFile.getModuleConfiguration(BUILDER_MODULE_NAME)); }
configurationFile.setExpandingEnvironmentVariables(true); configurationParams = configurationFile.getModuleConfiguration(configurationModuleName); ConfigurationParams transformationsParams = this.configurationFile.getModuleConfiguration(ConfigurationParametersNames.TRANSFORMATIONS_MODULE_NAME); File stopWordsFile = transformationsParams.getFile(RTE_TRAIN_AND_TEST_STOP_WORDS); StopWordsFileLoader stopWordsLoader = new StopWordsFileLoader(stopWordsFile.getPath());
public static void main(String[] args) throws WikiInitializationException, WikiTitleParsingException, IOException { if (args.length==0) { System.out.println("Missing configuration file path on first argument"); return; } System.out.println("Configurationm file: " + args[0]); ConfigurationFile conf; try { conf = new ConfigurationFile(args[0]); } catch (ConfigurationFileDuplicateKeyException e) { System.out.println("Exception when initializing the ConfigurationFile Class. error was:\n"+ e.getMessage()); return; } catch (ConfigurationException e) { System.out.println("Exception when initializing the ConfigurationFile Class. error was:\n"+ e.getMessage()); return; } WikipediaLexicalInferencesMiner miner = new WikipediaLexicalInferencesMinerForEnglish(); miner.MineWikipedia(conf); } }
@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); } }
ConfigurationFile confFile = new ConfigurationFile(new File(args[0])); confFile.setExpandingEnvironmentVariables(true); ConfigurationParams compilationParams = confFile.getModuleConfiguration(RuleCompilerParameterNames.RULE_COMPILER_PARAMS_MODULE); ConfigurationParams applictionParams = confFile.getModuleConfiguration(RuleCompilerParameterNames.SYNTACTIC_PARAMS_MODULE);
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; }
public void preprocess() throws ConfigurationFileDuplicateKeyException, ConfigurationException, NumberFormatException, TeEngineMlException, ParserRunException, NamedEntityRecognizerException, TextPreprocessorException, CoreferenceResolutionException, Rte6mainIOException, TreeCoreferenceInformationException, FileNotFoundException, IOException this.configurationFile.setExpandingEnvironmentVariables(true); preprocessParameters = configurationFile.getModuleConfiguration(RTE_SUM_PREPROCESS_MODULE_NAME); this.instruments = new InstrumentsFactory().getDefaultInstruments(preprocessParameters); if (preprocessParameters.containsKey(PREPROCESS_DO_NER))
public static void main(String[] args) throws WikiInitializationException, WikiTitleParsingException, IOException { if (args.length==0) { System.out.println("Missing configuration file path on first argument"); return; } ConfigurationFile conf; try { conf = new ConfigurationFile(args[0]); } catch (ConfigurationFileDuplicateKeyException e) { System.out.println("Exception when initializing the ConfigurationFile Class. error was:\n"+ e.getMessage()); return; } catch (ConfigurationException e) { System.out.println("Exception when initializing the ConfigurationFile Class. error was:\n"+ e.getMessage()); return; } System.out.println("Configuration read. Initializing the miner ..."); WikipediaLexicalInferencesMiner miner = new WikipediaLexicalInferencesMinerForItalian(); miner.MineWikipedia(conf); } }