public EnvBuilder setBaseDir(String dir) { return setBaseDir(new File(dir)); }
private void initializeFromCommandLine(CommandLine cmd) { setUseLoadedLanguages(); if (cmd.hasOption("n")) { setConceptMapper(cmd.getOptionValue("n")); } if (cmd.hasOption("base-dir")) { setBaseDir(new File(cmd.getOptionValue("base-dir"))); } if (cmd.hasOption("h")) { setMaxThreads(Integer.valueOf(cmd.getOptionValue("h"))); } if (cmd.hasOption("c")) { setConfigFile(new File(cmd.getOptionValue("c").trim())); } if (cmd.hasOption("l")) { String val = cmd.getOptionValue("l"); if (val.equals("loaded")) { setUseLoadedLanguages(); } else if (val.equals("downloaded")) { setUseDownloadedLanguages(); } else if (val.equals("all")) { setLanguages(LanguageSet.ALL); } else { // TODO: handle world economies, etc. setLanguages(new LanguageSet(cmd.getOptionValue("l"))); } } if (cmd.hasOption("tmp-dir")) { setTmpDir(new File(cmd.getOptionValue("tmp-dir"))); } }
public static void main() throws DaoException, ConfigurationException { // Prepare the environment; set the root to the current directory ("."). Env env = new EnvBuilder() .setBaseDir(".") .build(); // Get the configurator that creates components and a phraze analyzer from it Configurator configurator = env.getConfigurator(); PhraseAnalyzer pa = configurator.get(PhraseAnalyzer.class); UniversalPageDao dao = configurator.get(UniversalPageDao.class); // get the most common phrases in simple Language simple = Language.getByLangCode("simple"); // simple english LinkedHashMap<LocalId, Float> resolution = pa.resolve(simple, "apple", 5); // show the closest pages System.out.println("meanings of apple:"); for (LocalId p : resolution.keySet()) { System.out.println("\t" + p + ": " + resolution.get(p)); // translate them... UniversalPage concept = dao.getByLocalPage(p.asLocalPage()); //UniversalPage concept = dao.getByLocalPage(new Local, 1); for (LocalId id : concept.getLocalEntities()) { System.out.println("\t\tin language " + id.getLanguage() + " is " + id); } } } }
public static void main() throws DaoException, ConfigurationException { // Prepare the environment; set the root to the current directory ("."). Env env = new EnvBuilder() .setBaseDir(".") .build(); // Get the configurator that creates components and a phraze analyzer from it Configurator configurator = env.getConfigurator(); PhraseAnalyzer pa = configurator.get(PhraseAnalyzer.class); UniversalPageDao dao = configurator.get(UniversalPageDao.class); // get the most common phrases in simple Language simple = Language.getByLangCode("simple"); // simple english LinkedHashMap<LocalId, Float> resolution = pa.resolve(simple, "apple", 5); // show the closest pages System.out.println("meanings of apple:"); for (LocalId p : resolution.keySet()) { System.out.println("\t" + p + ": " + resolution.get(p)); // translate them... UniversalPage concept = dao.getByLocalPage(p.asLocalPage()); //UniversalPage concept = dao.getByLocalPage(new Local, 1); for (LocalId id : concept.getLocalEntities()) { System.out.println("\t\tin language " + id.getLanguage() + " is " + id); } } } }