public ConfigurationBasedDataStructureFactory(CommonConfig conf) throws ConfigurationException { this(new ConfigurationFile(conf)); }
@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 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); } }
@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
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); } }
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); } }
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()); } }
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); } }
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 ImplCommonConfig(new File(args[0])));
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()); }
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!"); }
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()); }
ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(args[0])));
ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(args[0]))); ConfigurationParams confParams = confFile.getModuleConfiguration(Configuration.KNOWLEDGE_RESOURCE);
ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(args[0])));
ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(args[0])));