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 SRBuilder(Env env, String metricName) throws ConfigurationException { this(env, metricName, env.getDefaultLanguage()); }
public List<File> getFiles(FileMatcher ... matchers) { return getFiles(getLanguages(), matchers); }
public SpatialDataLoader(Env env) throws ConfigurationException, WikiBrainException { this.env = env; this.langs = env.getLanguages(); this.spatialDao = env.getConfigurator().get(SpatialDataDao.class); this.metaDao = env.getConfigurator().get(MetaInfoDao.class); this.wdDao = env.getConfigurator().get(WikidataDao.class); }
public static void main(String args[]) throws ConfigurationException, DaoException { // Get the pageview dao Env env = EnvBuilder.envFromArgs(args); PageViewDao viewDao = env.getConfigurator().get(PageViewDao.class); LocalPageDao pageDao = env.getConfigurator().get(LocalPageDao.class); Language lang = env.getDefaultLanguage(); // Download and import pageview stats if necessary. DateTime start = new DateTime(2014, 8, 14, 11, 0, 0); DateTime end = new DateTime(2014, 8, 14, 23, 0, 0); viewDao.ensureLoaded(start, end, env.getLanguages()); // Retrieve counts for all pageviews TIntIntMap allViews = viewDao.getAllViews(lang, start, end); int pageIds[] = WpCollectionUtils.sortMapKeys(allViews, true); System.out.println("Top pageviews in " + lang); for (int i = 0; i < 10; i++) { LocalPage page = pageDao.getById(lang, pageIds[i]); int n = allViews.get(pageIds[i]); System.out.format("%d. %s (nviews=%d)\n", (i+1), page.getTitle(), n); } } }
public static void main(String args[]) throws ConfigurationException, DaoException { Env env = EnvBuilder.envFromArgs(args); Configurator conf = env.getConfigurator(); LocalPageDao lpDao = conf.get(LocalPageDao.class); WikidataDao wdDao = conf.get(WikidataDao.class); // Get page Title title = new Title("Berlin", env.getDefaultLanguage()); LocalPage page = lpDao.getByTitle(title, NameSpace.ARTICLE); System.out.println("Properties for " + title); // Show statements Map<String, List<LocalWikidataStatement>> statements = wdDao.getLocalStatements(page); for (String property : statements.keySet()) { System.out.println("values for property " + property + " are:"); for (LocalWikidataStatement lws : statements.get(property)) { System.out.println("\t" + lws.getFullStatement()); } } } }
public WebEntityParser(Env env) throws ConfigurationException { // this.conceptDao = env.getConfigurator().get(UniversalPageDao.class); this.pageDao = env.getConfigurator().get(LocalPageDao.class); }
Configurator conf = env.getConfigurator(); metaDao.beginLoad(); for (Language lang : env.getLanguages().getLanguages()) { LOG.info("loading links for " + lang); List<File> paths = env.getFiles(lang, FileMatcher.LINK_SQL); if (paths.size() > 1) { throw new IllegalStateException();
public QualitativeAnalyzer(Env env) { this.env = env; this.language = env.getLanguages().getDefaultLanguage(); }
RawPageDao rpd = env.getConfigurator().get(RawPageDao.class); LocalPageDao lpd = env.getConfigurator().get(LocalPageDao.class); Language lang = env.getLanguages().getDefaultLanguage(); LinkProbabilityDao linkProbabilityDao =env.getComponent(LinkProbabilityDao.class, lang); Wikifier wikifier = env.getComponent(Wikifier.class, lang);
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(); } }
Configurator conf = env.getConfigurator(); List<File> paths; if (cmd.getArgList().isEmpty()) { paths = env.getFiles(FileMatcher.ARTICLES); } else { paths = new ArrayList<File>();
public void evaluate(final List<List<String>> bundles) throws ConfigurationException, IOException { String lc = env.getDefaultLanguage().getLangCode(); File dir = FileUtils.getFile(env.getBaseDir(), "dat/sr/known-phrase/en"); FileUtils.deleteQuietly(dir); final KnownPhraseSim sim = (KnownPhraseSim) env.getConfigurator().get(SRMetric.class, "known-phrase", "language", lc); if (!sim.getDataDir().equals(dir)) { throw new IllegalStateException("expected dir " + dir + ", found " + sim.getDataDir());
public UniversalWord2VecMain(Env env, Language lang) throws ConfigurationException, DaoException { this.env = env; this.lang = lang; UniversalPageDao univDao = env.getConfigurator().get(UniversalPageDao.class); this.pageDao = env.getComponent(LocalPageDao.class); Map<Language, TIntIntMap> allConcepts = univDao.getAllLocalToUnivIdsMap(new LanguageSet(lang)); this.concepts = allConcepts.containsKey(lang) ? allConcepts.get(lang) : new TIntIntHashMap(); }
private Config getConfig(String refSys, String layerGroup, String dataset) { return env.getConfiguration().getConfig("spatial.datasets", refSys, layerGroup, dataset); }
public List<File> getFiles(Language lang, FileMatcher fm) { return getFiles(lang, fm, configuration); }
public static void main(String args[]) throws ConfigurationException, DaoException { // Get the pageview dao Env env = EnvBuilder.envFromArgs(args); PageViewDao viewDao = env.getConfigurator().get(PageViewDao.class); LocalPageDao pageDao = env.getConfigurator().get(LocalPageDao.class); Language lang = env.getDefaultLanguage(); // Download and import pageview stats if necessary. DateTime start = new DateTime(2014, 8, 14, 11, 0, 0); DateTime end = new DateTime(2014, 8, 14, 23, 0, 0); viewDao.ensureLoaded(start, end, env.getLanguages()); // Retrieve counts for all pageviews TIntIntMap allViews = viewDao.getAllViews(lang, start, end); int pageIds[] = WpCollectionUtils.sortMapKeys(allViews, true); System.out.println("Top pageviews in " + lang); for (int i = 0; i < 10; i++) { LocalPage page = pageDao.getById(lang, pageIds[i]); int n = allViews.get(pageIds[i]); System.out.format("%d. %s (nviews=%d)\n", (i+1), page.getTitle(), n); } } }
public SpatialDataLoader(Env env) throws ConfigurationException, WikiBrainException { this.env = env; this.langs = env.getLanguages(); this.spatialDao = env.getConfigurator().get(SpatialDataDao.class); this.metaDao = env.getConfigurator().get(MetaInfoDao.class); this.wdDao = env.getConfigurator().get(WikidataDao.class); }
public static void main(String args[]) throws ConfigurationException, DaoException, IOException { Env env = new EnvBuilder().build(); Configurator c = env.getConfigurator(); Language lang = env.getDefaultLanguage(); // simple english PhraseAnalyzer pa = c.get(PhraseAnalyzer.class, "anchortext"); LocalPageDao pageDao = c.get(LocalPageDao.class); LocalPage page = pageDao.getByTitle(new Title("Obama", lang), NameSpace.ARTICLE); System.out.println("description of " + page + ":"); // should resolve redirect to Barack Obama LinkedHashMap<String, Float> description = pa.describe(lang, page, 100); if (description == null) { System.out.println("\tno description!"); } else { for (String phrase : description.keySet()) { System.out.println("\t" + phrase + ": " + description.get(phrase)); } } } }
public ContainsPointScorer(Env env, Config conf) throws ConfigurationException { super(env, conf); wikidataDao = env.getConfigurator().get(WikidataDao.class); }