public QualitativeAnalyzer(Env env) { this.env = env; this.language = env.getLanguages().getDefaultLanguage(); }
public Language getDefaultLanguage() { return getLanguages().getDefaultLanguage(); }
public List<File> getFiles(FileMatcher ... matchers) { return getFiles(getLanguages(), matchers); }
private void printHeader() { System.out.println(StringUtils.repeat("*", WIDTH)); System.out.println("*" + StringUtils.repeat(" ", WIDTH - 2) + "*"); System.out.println("*" + StringUtils.center("LOADED WIKIBRAIN DATA:", WIDTH - 2) + "*"); System.out.println("*" + StringUtils.repeat(" ", WIDTH - 2) + "*"); System.out.println("*" + StringUtils.center(" Default language: " + env.getLanguages().getDefaultLanguage(), WIDTH - 2) + "*"); System.out.println("*" + StringUtils.center(" Loaded languages: " + env.getLanguages(), WIDTH - 2) + "*"); System.out.println("*" + StringUtils.repeat(" ", WIDTH - 2) + "*"); System.out.println(StringUtils.repeat("-", WIDTH)); printRow("component", "language", "count", "errors", "modified"); System.out.println(StringUtils.repeat("-", WIDTH)); }
private void printHeader() { System.out.println(StringUtils.repeat("*", WIDTH)); System.out.println("*" + StringUtils.repeat(" ", WIDTH - 2) + "*"); System.out.println("*" + StringUtils.center("LOADED WIKIBRAIN DATA:", WIDTH - 2) + "*"); System.out.println("*" + StringUtils.repeat(" ", WIDTH - 2) + "*"); System.out.println("*" + StringUtils.center(" Default language: " + env.getLanguages().getDefaultLanguage(), WIDTH - 2) + "*"); System.out.println("*" + StringUtils.center(" Loaded languages: " + env.getLanguages(), WIDTH - 2) + "*"); System.out.println("*" + StringUtils.repeat(" ", WIDTH - 2) + "*"); System.out.println(StringUtils.repeat("-", WIDTH)); printRow("component", "language", "count", "errors", "modified"); System.out.println(StringUtils.repeat("-", WIDTH)); }
private void doLanguages(WikiBrainWebRequest req) { List<String> langs = new ArrayList<String>(); for (Language l : env.getLanguages()) { langs.add(l.getLangCode()); } Collections.sort(langs); req.writeJsonResponse("languages", langs); }
public void retrieveLocations() throws DaoException { // Get all known concept geometries Map<Integer, Geometry> geometries = sdDao.getAllGeometriesInLayer("wikidata", "earth"); LOG.info(String.format("Get %d geometries, now building id-name mapping", geometries.size())); // Build up list of concepts in all languages for (Integer conceptId : geometries.keySet()){ UniversalPage concept = upDao.getById(conceptId); if (concept != null && concept.hasAllLanguages(env.getLanguages())) { concepts.add(concept); locations.put(concept, geometries.get(conceptId).getCentroid()); if (concepts.size() % 1000 == 0) { LOG.info(String.format("Loaded %d geometries with articles in %s...", concepts.size(), env.getLanguages())); } } } LOG.info(String.format("Found %d geometries with articles in %s", concepts.size(), env.getLanguages())); }
public WikidataValueScorer(Env env, Config conf) throws ConfigurationException { super(env, conf); try { wikidataDao = env.getConfigurator().get(WikidataDao.class); columnName = conf.getString("column"); Language lang = env.getLanguages().getBestAvailableEnglishLang(false); WikidataEntity prop = wikidataDao.getProperty(lang, conf.getString("property")); if (prop == null) { throw new IllegalArgumentException("Couldn't find property with name " + conf.getString("property")); } propertyId = prop.getId(); } catch (WikiBrainException e) { throw new ConfigurationException(e); } catch (DaoException e) { throw new ConfigurationException(e); } }
public void init() throws ConfigurationException, DaoException { // Warm up necessary components for (Language l : env.getLanguages()) { LOG.info("warming up components for language: " + l); getSr(l); env.getConfigurator().get(Wikifier.class, "websail", "language", l.getLangCode()); } LOG.info("warming up pagerank"); LocalPage p = pageDao.get(new DaoFilter().setLimit(1)).iterator().next(); linkDao.getPageRank(p.toLocalId()); }
public SimpleToblersLawEvaluator(Env env) throws ConfigurationException { this.env = env; this.langs = new ArrayList<Language>(env.getLanguages().getLanguages()); // Get data access objects Configurator c = env.getConfigurator(); this.sdDao = c.get(SpatialDataDao.class); this.lpDao = c.get(LocalPageDao.class); this.upDao = c.get(UniversalPageDao.class); // build SR metrics this.metrics = new HashMap<Language, SRMetric>(); for(Language lang : langs){ SRMetric m = c.get(SRMetric.class, "ensemble", "language", lang.getLangCode()); metrics.put(lang, m); } }
public SimpleToblersLawEvaluator(Env env) throws ConfigurationException { this.env = env; this.langs = new ArrayList<Language>(env.getLanguages().getLanguages()); // Get data access objects Configurator c = env.getConfigurator(); this.sdDao = c.get(SpatialDataDao.class); this.lpDao = c.get(LocalPageDao.class); this.upDao = c.get(UniversalPageDao.class); // build SR metrics this.metrics = new HashMap<Language, SRMetric>(); for(Language lang : langs){ SRMetric m = c.get(SRMetric.class, "ensemble", "language", lang.getLangCode()); metrics.put(lang, m); } }
public GeoResolver(Env env, Config config) throws ConfigurationException { this.env = env; this.config = config; this.titleFields = config.getStringList("titles"); this.contextFields = config.getStringList("context"); this.language = env.getLanguages().getDefaultLanguage(); this.pageDao = env.getConfigurator().get(LocalPageDao.class); this.disambig = env.getConfigurator().get(Disambiguator.class, config.getString("dab"), "language", language.getLangCode()); if (this.language != Language.EN && this.language != Language.SIMPLE) { throw new IllegalArgumentException(); } initScorers(); }
public GeoResolver(Env env, Config config) throws ConfigurationException { this.env = env; this.config = config; this.titleFields = config.getStringList("titles"); this.contextFields = config.getStringList("context"); this.language = env.getLanguages().getDefaultLanguage(); this.pageDao = env.getConfigurator().get(LocalPageDao.class); this.disambig = env.getConfigurator().get(Disambiguator.class, config.getString("dab"), "language", language.getLangCode()); if (this.language != Language.EN && this.language != Language.SIMPLE) { throw new IllegalArgumentException(); } initScorers(); }
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"))); }
public PipelineLoader(Env env, List<StageArgs> args) throws ConfigurationException, DaoException, ClassNotFoundException, InterruptedException { MetaInfoDao metaDao = env.getConfigurator().get(MetaInfoDao.class); this.langs = env.getLanguages(); this.state = metaDao.getAllCummulativeInfo(); // this.diagnosticDao = env.getConfigurator().get(DiagnosticDao.class); initConfig(env.getConfiguration()); if (args == null) { if (langs.size() == 0) { throw new IllegalArgumentException("No languages specified to pipeline loader"); } else if (langs.size() == 1) { args = Arrays.asList(new StageArgs(DEFAULT_GROUP, true, null)); } else { args = Arrays.asList(new StageArgs(MULTILINGUAL_GROUP, true, null)); } } setStageArguments(args); }
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 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 { // The following ten-line dance to get an env is awkward and repeated over and over. // Figure out a good way to consolidate it. Env env = EnvBuilder.envFromArgs(args); Configurator configurator = env.getConfigurator(); LocalPageDao lpDao = configurator.get(LocalPageDao.class); LocalLinkDao sqlDao = configurator.get(LocalLinkDao.class, "sql"); Language simple = env.getLanguages().getDefaultLanguage(); LocalPage page = lpDao.getByTitle(new Title("List of Soundgarden band members", simple), NameSpace.ARTICLE); System.out.println("page is " + page); DaoFilter filter = new DaoFilter().setSourceIds(page.getLocalId()).setLanguages(simple); for (LocalLink link : sqlDao.get(filter)) { System.out.println("link is: " + link); } } }
public static void main(String args[]) throws ConfigurationException, DaoException { // The following ten-line dance to get an env is awkward and repeated over and over. // Figure out a good way to consolidate it. Env env = EnvBuilder.envFromArgs(args); Configurator configurator = env.getConfigurator(); LocalPageDao lpDao = configurator.get(LocalPageDao.class); LocalLinkDao sqlDao = configurator.get(LocalLinkDao.class, "sql"); Language simple = env.getLanguages().getDefaultLanguage(); LocalPage page = lpDao.getByTitle(new Title("List of Soundgarden band members", simple), NameSpace.ARTICLE); System.out.println("page is " + page); DaoFilter filter = new DaoFilter().setSourceIds(page.getLocalId()).setLanguages(simple); for (LocalLink link : sqlDao.get(filter)) { System.out.println("link is: " + link); } } }