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); } }
/** * Initializes the LAP based on the lap parameter (if given) and the language information in the configuration file * * @param option -- (parsed) command arguments */ public void initializeLAP(String lapClassName, File configFile) { logger.info("LAP initialized from class " + lapClassName); try { // CommonConfig config = new ImplCommonConfig(configFile); Class<?> lapClass = Class.forName(lapClassName); Constructor<?> lapClassConstructor = lapClass.getConstructor(CommonConfig.class); lap = (LAPAccess) lapClassConstructor.newInstance(new ImplCommonConfig(configFile)); // lap = (LAPAccess) lapClassConstructor.newInstance(config); } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | ConfigurationException e) { logger.error("Error initializing LAP : " + e.getClass()); e.printStackTrace(); } }
@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); } }
@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); } }
/** * Create the CommonConfig object based on the configuration file name provided as argument */ public void initializeConfigFile() { configFileName = option.config; configFile = new File(configFileName); logger.info("Configuration file: " + configFileName); try { config = new ImplCommonConfig(configFile); initializeEDA(); } catch (ConfigurationException e) { logger.error("Problem generating the CommonConfig object for the configuration file"); e.printStackTrace(); } }
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 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()); } }
@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
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()); } }
/** * WARN: Broken code; wordNetPath doesn't work. --- update either commonconfig * or LexicalAligner. Thus, it will rely on fixed XML file path --- which won't work * within a Jar (used as a library) * * @param wordNetPath * @throws AlignmentComponentException */ public WordNetENLinker_old (String wordNetPath) throws AlignmentComponentException { this.wordNetPath = wordNetPath; File configFile = new File("../core/src/main/resources/configuration-file/lexlinkers/WordNetENLinker.xml"); try { config = new ImplCommonConfig(configFile); } catch (ConfigurationException ce) { throw new AlignmentComponentException("Reading base configuration file failed!", ce); } //updateConfig(); worker = new LexicalAligner(config); } public void annotate(JCas aJCas) throws AlignmentComponentException
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()); }
ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(args[0])));
CommonConfig config = new ImplCommonConfig(configFile);
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]))); ConfigurationParams confParams = confFile.getModuleConfiguration(eu.excitementproject.eop.distsim.util.Configuration.MAPRED_COOCCURRENCE_COUNTING); job.setJarByClass(ExtractAndCountBasicNodeBasedElementsFeatures.class);
public static void main(String[] args) throws Exception { ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(args[0])));
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])));
Constructor<?> componentClassConstructor = componentClass.getConstructor(CommonConfig.class); File configFile = new File(configurationFile); ImplCommonConfig commonConfig = new ImplCommonConfig(configFile); this.aligner = (LexicalAligner) componentClassConstructor.newInstance(commonConfig);