/** * This method takes care to not load the metric itself, and just deal in names. * Once the metric is loaded, it has already accessed its data files. * @throws ConfigurationException */ public void deleteDataDirectories() throws ConfigurationException { for (String name : getSubmetrics(metricName)) { File dir = FileUtils.getFile(srDir, name, language.getLangCode()); if (dir.exists()) { LOG.info("deleting metric directory " + dir); FileUtils.deleteQuietly(dir); } } }
if (type.equals("ensemble") || type.equals("simple-ensemble")) { for (String child : config.getStringList("metrics")) { toAdd.addAll(getSubmetrics(child)); toAdd.add(child); toAdd.addAll(getSubmetrics(config.getString("generator.basemetric"))); } else if (type.equals("milnewitten")) { toAdd.add(config.getString("inlink"));
/** * First deletes models if deleteExistingData is true, then builds the appropriate metrics. * @throws ConfigurationException * @throws DaoException * @throws IOException * @throws WikiBrainException */ public void build() throws ConfigurationException, DaoException, IOException, WikiBrainException, InterruptedException { if (deleteExistingData) { deleteDataDirectories(); } buildConceptsIfNecessary(); LOG.info("building metric " + metricName); for (String name : getSubmetrics(metricName)) { buildMetric(name); } }
private void buildConceptsIfNecessary() throws IOException, ConfigurationException, DaoException { boolean needsConcepts = false; for (String name : getSubmetrics(metricName)) { String type = getMetricType(name); if (type.equals("sparsevector.esa") || type.equals("sparsevector.mostsimilarconcepts")) { needsConcepts = true; } } if (!needsConcepts) { return; } File path = FileUtils.getFile( env.getConfiguration().get().getString("sr.concepts.path"), language.getLangCode() + ".txt" ); path.getParentFile().mkdirs(); // Check to see if concepts are already built if (path.isFile() && FileUtils.readLines(path).size() > 1) { return; } LOG.info("building concept file " + path.getAbsolutePath() + " for " + metricName); SRConceptSpaceGenerator gen = new SRConceptSpaceGenerator(language, env.getConfigurator().get(LocalLinkDao.class), env.getConfigurator().get(LocalPageDao.class)); gen.writeConcepts(path); LOG.info("finished creating concept file " + path.getAbsolutePath() + " with " + FileUtils.readLines(path).size() + " lines"); }