public Language getDefaultLanguage() { return getLanguages().getDefaultLanguage(); }
public QualitativeAnalyzer(Env env) { this.env = env; this.language = env.getLanguages().getDefaultLanguage(); }
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)); }
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(); }
Language language = env.getLanguages().getDefaultLanguage();
public String formatExplanation(Explanation explanation) throws DaoException { String[] plaintextBuilder = explanation.getFormat().split("\\?", -1); if (explanation.getInformation().size()!=plaintextBuilder.length-1){ throw new IllegalStateException("Incorrect number of information objects in explanation. Expected "+(plaintextBuilder.length-1)+" but found "+explanation.getInformation().size()); } String plaintext = plaintextBuilder[0]; for (int i = 1; i<plaintextBuilder.length; i++){ Object object = explanation.getInformation().get(i-1); //Handle the different possible types of information. //Add additional handlers as appropriate if (object instanceof LocalPage){ plaintext+=((LocalPage) object).getTitle().getCanonicalTitle(); }else if(object instanceof UniversalPage){ Language defaultlang = ((UniversalPage) object).getLanguageSet().getDefaultLanguage(); LocalId nameId = (LocalId)((UniversalPage) object).getLocalEntities(defaultlang).toArray()[0]; LocalPage namePage = localPageDao.getById(nameId.getLanguage(), nameId.getId()); plaintext+=namePage.getTitle().getCanonicalTitle(); }else { plaintext+=object.toString(); } plaintext+=plaintextBuilder[i]; } return plaintext; }
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(); }
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);
RawPageDao rpd = env.getConfigurator().get(RawPageDao.class); LocalPageDao lpd = env.getConfigurator().get(LocalPageDao.class); Language lang = env.getLanguages().getDefaultLanguage(); Wikifier wikifier = env.getComponent(Wikifier.class, lang); LinkProbabilityDao linkProbabilityDao = env.getComponent(LinkProbabilityDao.class, lang);
Word2VecTrainer trainer = new Word2VecTrainer( c.get(LocalPageDao.class), env.getLanguages().getDefaultLanguage() ); if (cmd.hasOption("f")) {
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); } } }
PhraseAnalyzerDao dao = phraseAnalyzer.getDao(); Word2Phrase w2p = new Word2Phrase(env.getLanguages().getDefaultLanguage(), dao); w2p.concatenateBigrams( new File(cmd.getOptionValue("i")),
throw new UnsupportedOperationException(); // TODO: implement universal metrics Language lang = env.getLanguages().getDefaultLanguage(); List<Dataset> datasets = new ArrayList<Dataset>(); String mode = cmd.hasOption("x") ? cmd.getOptionValue("x") : "within-dataset";
/** * Returns English if English is in the set, else returns Simple. If Simple is not in the * set, will return the default language or throws an exception, depending on the value of returnDefaultLangIfEnglishNotAvailable * @return * @throws WikiBrainException */ public Language getBestAvailableEnglishLang(boolean returnDefaultLangIfEnglishNotAvailable) throws WikiBrainException { if (this.containsLanguage(Language.getByLangCode("en"))){ return Language.getByLangCode("en"); }else if (this.containsLanguage(Language.getByLangCode("simple"))){ return Language.getByLangCode("simple"); }else{ if (returnDefaultLangIfEnglishNotAvailable){ return this.getDefaultLanguage(); } throw new WikiBrainException("No English language available"); } }
String name = wdDao.getItem(wdItem).getLabels().get(langs.getDefaultLanguage()); if(name == null) continue;
String name = wdDao.getItem(wdItem).getLabels().get(langs.getDefaultLanguage()); if(name == null) continue;