public SpatialDataDownloader(Configuration config) { this.config = config; this.dir = new SpatialDataFolder(new File(config.get().getString("spatial.dir"))); }
public SpatialDataDownloader(Configuration config) { this.config = config; this.dir = new SpatialDataFolder(new File(config.get().getString("spatial.dir"))); }
public static void downloadDictionaryIfNecessary(Configuration conf) throws IOException, InterruptedException { String path = conf.get().getString("phrases.analyzer.stanford.path"); String url = conf.get().getString("phrases.analyzer.stanford.url"); File file = new File(path); File completed = new File(path + ".completed"); if (!completed.isFile()) { LOG.info("downloading stanford dictionary..."); FileDownloader downloader = new FileDownloader(); downloader.download(new URL(url), file); FileUtils.touch(completed); } }
public SpatialDataDownloader(Env env) { this.config = env.getConfiguration(); this.dir = new SpatialDataFolder(new File(config.get().getString("spatial.dir"))); }
public SpatialDataDownloader(Env env) { this.config = env.getConfiguration(); this.dir = new SpatialDataFolder(new File(config.get().getString("spatial.dir"))); }
public SRBuilder(Env env, String metricName, Language language) throws ConfigurationException { this.env = env; this.language = language; this.config = env.getConfiguration(); this.srDir = new File(config.get().getString("sr.metric.path")); datasetNames = config.get().getStringList("sr.dataset.defaultsets"); // Properly resolve the default metric name. this.metricName = env.getConfigurator().resolveComponentName(SRMetric.class, metricName); if (!srDir.isDirectory()) { srDir.mkdirs(); } }
public ShapeFileMatcher(Env env) { this.env = env; this.dir = new SpatialDataFolder(new File(env.getConfiguration().get().getString("spatial.dir"))); this.downloader = new SpatialDataDownloader(env); }
private void initConfig(Configuration config) throws ClassNotFoundException { for (Config stageConfig : config.get().getConfigList("loader.stages")) { PipelineStage stage = new PipelineStage(stageConfig, stages.values(), state); stages.put(stage.getName(), stage); } // Set up the groups Config groupConfig = config.get().getConfig("loader.groups"); for (String g : config.get().getObject("loader.groups").keySet()) { groups.put(g, new ArrayList<String>()); for (String s : groupConfig.getStringList(g)) { PipelineStage stage = getStage(s); // throws IllegalArgumentException if unknown stage groups.get(g).add(s); } } }
public ShapeFileMatcher(Env env) { this.env = env; this.dir = new SpatialDataFolder(new File(env.getConfiguration().get().getString("spatial.dir"))); this.downloader = new SpatialDataDownloader(env); }
private void initConfig(Configuration config) throws ClassNotFoundException { for (Config stageConfig : config.get().getConfigList("loader.stages")) { PipelineStage stage = new PipelineStage(stageConfig, stages.values(), state); stages.put(stage.getName(), stage); } // Set up the groups Config groupConfig = config.get().getConfig("loader.groups"); for (String g : config.get().getObject("loader.groups").keySet()) { groups.put(g, new ArrayList<String>()); for (String s : groupConfig.getStringList(g)) { PipelineStage stage = getStage(s); // throws IllegalArgumentException if unknown stage groups.get(g).add(s); } } }
/** * Returns the config object associated with the given class and name. * @param klass The generic interface or superclass, not the specific implementation. * @param name The name of the class as it appears in the config file. If name is null, * the configurator tries to guess by looking for a "default" entry in * the config that provides the name for a default implementation or, if * there is exactly one implementation returning it. Otherwise, if name is * null it throws an error. * @return The requested config object. * @throws ConfigurationException */ public Config getConfig(Class klass, String name) throws ConfigurationException { if (!providers.containsKey(klass)) { throw new ConfigurationException("No registered providers for components with class " + klass); } ProviderSet pset = providers.get(klass); name = resolveComponentName(klass, name); String path = pset.path + "." + name; if (!conf.get().hasPath(path)) { throw new ConfigurationException("Configuration path " + path + " does not exist"); } return conf.get().getConfig(path); }
@Override public String describeDisambiguator() { if (!config.hasPath("disambiguator")){ return "none"; } String disambigName = config.getString("disambiguator"); try { Map dc = configurator.getConfig(Disambiguator.class, disambigName).root().unwrapped(); String phraseName = null; if (dc.containsKey("phraseAnalyzer")) { phraseName = (String) dc.get("phraseAnalyzer"); } if (phraseName == null || phraseName.equals("default")) { phraseName = configurator.getConf().get().getString("phrases.analyzer.default"); } dc.put("phraseAnalyzer", phraseName); return disambigName + "=" + dc.toString(); } catch (ConfigurationException e) { throw new IllegalStateException(e); } }
@Override public PhraseAnalyzerDao get(String name, Config config, Map<String, String> runtimeParams) throws ConfigurationException { if (!config.getString("type").equals("objectdb")) { return null; } boolean isNew = config.getBoolean("isNew"); File path = new File(getConfig().get().getString("phrases.path"), name); StringNormalizer normalizer = getConfigurator().get(StringNormalizer.class, config.getString("normalizer")); try { return new PhraseAnalyzerObjectDbDao(normalizer, path, isNew); } catch (DaoException e) { throw new ConfigurationException(e); } } }
@Override public UniversalPageDao get(String name, Config config, Map<String, String> runtimeParams) throws ConfigurationException { if (!config.getString("type").equals("sql")) { return null; } try { int algorithmId = getConfig().get().getInt("mapper." + config.getString("mapper") + ".algorithmId"); return new UniversalPageSqlDao( getConfigurator().get( WpDataSource.class, config.getString("dataSource")), algorithmId ); } catch (DaoException e) { throw new ConfigurationException(e); } } }
@Override public UniversalLinkDao get(String name, Config config, Map<String, String> runtimeParams) throws ConfigurationException { if (!config.getString("type").equals("skeletal-sql")) { return null; } try { int algorithmId = getConfig().get().getInt("mapper." + config.getString("mapper") + ".algorithmId"); return new UniversalLinkSkeletalSqlDao( getConfigurator().get( WpDataSource.class, config.getString("dataSource")), algorithmId ); } catch (DaoException e) { throw new ConfigurationException(e); } } }
@Override public LocalPageDao get(String name, Config config, Map<String, String> runtimeParams) throws ConfigurationException { if (!config.getString("type").equals("sql")) { return null; } try { LocalPageSqlDao dao = new LocalPageSqlDao( getConfigurator().get( WpDataSource.class, config.getString("dataSource")) ); String cachePath = getConfig().get().getString("dao.sqlCachePath"); File cacheDir = new File(cachePath); if (!cacheDir.isDirectory()) { cacheDir.mkdirs(); } dao.useCache(cacheDir); return dao; } catch (DaoException e) { throw new ConfigurationException(e); } } }
@Override public UniversalLinkDao get(String name, Config config, Map<String, String> runtimeParams) throws ConfigurationException { if (!config.getString("type").equals("sql")) { return null; } try { int algorithmId = getConfig().get().getInt("mapper." + config.getString("mapper") + ".algorithmId"); return new UniversalLinkSqlDao( getConfigurator().get( WpDataSource.class, config.getString("dataSource")), getConfigurator().get( LocalLinkDao.class, config.getString("localLinkDao")), algorithmId ); } catch (DaoException e) { throw new ConfigurationException(e); } } }
protected static void configureBase(Configurator configurator, BaseSRMetric sr, Config config) throws ConfigurationException { Config rootConfig = configurator.getConf().get(); File path = new File(rootConfig.getString("sr.metric.path")); sr.setDataDir(FileUtils.getFile(path, sr.getName(), sr.getLanguage().getLangCode())); // initialize normalizers sr.setSimilarityNormalizer(configurator.get(Normalizer.class, config.getString("similaritynormalizer"))); sr.setMostSimilarNormalizer(configurator.get(Normalizer.class, config.getString("mostsimilarnormalizer"))); boolean isTraining = rootConfig.getBoolean("sr.metric.training"); if (isTraining) { sr.setReadNormalizers(false); } if (config.hasPath("buildMostSimilarCache")) { sr.setBuildMostSimilarCache(config.getBoolean("buildMostSimilarCache")); } try { sr.read(); } catch (IOException e){ throw new ConfigurationException(e); } LOG.info("finished base configuration of metric " + sr.getName()); } }
public MappedShapefileLoader(Env env) throws ConfigurationException, WikiBrainException { this.env = env; this.lang = env.getLanguages().getBestAvailableEnglishLang(false); this.pageDao = env.getConfigurator().get(LocalPageDao.class); this.conceptDao = env.getConfigurator().get(UniversalPageDao.class); this.metaDao = env.getConfigurator().get(MetaInfoDao.class); this.spatialDao = env.getConfigurator().get(SpatialDataDao.class); this.folder = new SpatialDataFolder( new File(env.getConfiguration().get().getString("spatial.dir"))); }
public MappedShapefileLoader(Env env) throws ConfigurationException, WikiBrainException { this.env = env; this.lang = env.getLanguages().getBestAvailableEnglishLang(false); this.pageDao = env.getConfigurator().get(LocalPageDao.class); this.conceptDao = env.getConfigurator().get(UniversalPageDao.class); this.metaDao = env.getConfigurator().get(MetaInfoDao.class); this.spatialDao = env.getConfigurator().get(SpatialDataDao.class); this.folder = new SpatialDataFolder( new File(env.getConfiguration().get().getString("spatial.dir"))); }