public void Validate() {

    List<String> allURI = new ArrayList<String>();

    for (String mediaURI : File.MediaURIs) {
      if (!allURI.contains(mediaURI)) {
        allURI.add(mediaURI);
      } else {
        super.AddValidationError(
            "Media URI values are not unique: MediaURI:" + mediaURI, "Duplicate MediaURI");
      }
    }
  }
Example #2
0
  @Override
  public void sitePostAction(File root, File category, File site) {
    Statistics statistics;
    RollerLearner roller;
    Validator validator;
    Rule rule;

    try {

      // ///////////////////////////////////////////////////////////////////////////

      System.out.printf("===> ROLLER'S LEARNING FROM %s%n", site.getName());

      Watch.start();
      {
        ConfigurationPersistence.load(site);
        statistics = new Statistics();

        roller = new RollerLearner();
        roller.setStatistics(statistics);
        roller.learn();
        rule = roller.getRule();
      }
      Watch.stop();

      RulePersistence.save(site, rule);

      System.out.printf(
          "<=== END LEARNING %s - %s - %s%n",
          site.getName(),
          Formatter.toTime(Watch.getTiming()),
          Formatter.toSize(Memory.getFreeMemory()));

      // Site, Learning Time (segs.), Score, Nodes, Attempts, contexts, contexts', Attributes, Num.
      // Rules, Num. Selectors
      GlobalConfiguration.getOutput()
          .printf(
              "%s,%f,%f,%d,%d,%d,%d,%d,%d,%d,",
              site.getName(),
              Watch.getTiming() / 1000.0,
              RollerConfiguration.getScoringFunction().compute(rule),
              roller.getStatistics().getNodesExplored(),
              roller.getStatistics().getNumberAttempts(),
              rule.getTrainingDataset().getContexts().size(),
              computecontextsx(rule),
              computeAttributes(rule),
              computeNumRules(rule),
              computeNumSelectors(rule));

      Memory.collectGarbage();

      // ///////////////////////////////////////////////////////////////////////////

      System.out.printf("===> ROLLER'S TESTING %s%n", site.getName());

      Watch.start();
      {
        validator = new Validator();
        validator.setRule(rule);
        validator.setDataSet(RollerConfiguration.getTestSet());
        validator.validate();
      }
      Watch.stop();

      System.out.printf("%s%n", validator.getPerformance().toSummaryString(true));
      System.out.printf("%s%n", validator.getPerformance().toClassDetailsString());
      System.out.printf("%s%n", validator.getPerformance().toMatrixString());

      System.out.printf(
          "<=== END TESTING %s - %s - %s%n",
          site.getName(),
          Formatter.toTime(Watch.getTiming()),
          Formatter.toSize(Memory.getFreeMemory()));

      // Testing Time (segs.), P, R, F1, ROC, Error Rate
      GlobalConfiguration.getOutput()
          .printf(
              "%f,%f,%f,%f,%f,%f%n",
              Watch.getTiming() / 1000.0,
              validator.getPerformance().weightedPrecision(),
              validator.getPerformance().weightedRecall(),
              validator.getPerformance().weightedFMeasure(),
              validator.getPerformance().weightedAreaUnderROC(),
              validator.getPerformance().errorRate());

      GlobalConfiguration.getOutput().flush();

      Memory.collectGarbage();
    } catch (Throwable oops) {
      System.out.printf("%n%n%nOOPS! SOMETHING WENT WRONG!%n%n%n");
      oops.printStackTrace(System.out);
      GlobalConfiguration.getOutput().println();
      System.out.printf("%n%n%n");
    }
  }