if (rules.isEmpty())
return rules;
List<TextRulerStatisticsCollector> sums = new ArrayList<TextRulerStatisticsCollector>();
for (TrabalRule each : rules) {
sums.add(new TextRulerStatisticsCollector());
}
List<TextRulerExampleDocument> goldDocs;
List<TextRulerExampleDocument> additionalDocs;
goldDocs = documents.getDocuments();
additionalDocs = additionalDocuments.getDocuments();
CAS theTestCAS = getTestCAS();
int counter = 0;
for (TrabalRule rule : rules) {
counter++;
String ruleString = rule.getRuleString();
String ruleInfo = getRuleInfo(rule);
System.out.println("testing: " + ruleString);
if (inducedRules.containsKey(ruleString)) {
rule.setCoveringStatistics(inducedRules.get(ruleString));
System.out.println("skipped with " + inducedRules.get(ruleString));
} else {
for (int i = 0; i < goldDocs.size(); i++) {
TextRulerExampleDocument goldDoc = goldDocs.get(i);
TextRulerExampleDocument additionalDoc = additionalDocs.get(i);
sendStatusUpdateToDelegate("Testing " + ruleSet + ruleInfo + " on document " + (i + 1)
+ " of " + goldDocs.size() + " : rule " + counter + " of " + rules.size(),
TextRulerLearnerState.ML_RUNNING, false);
TextRulerStatisticsCollector sumC = new TextRulerStatisticsCollector();
prepareTestCas(theTestCAS, goldDoc, additionalDoc);
testRuleOnDocument(rule, goldDoc, additionalDoc, sumC, theTestCAS);
sums.get(counter - 1).add(sumC);
int n = sumC.getCoveredNegativesCount();
int p = sumC.getCoveredPositivesCount();
int pnorm = p;
if (pnorm == 0) {
pnorm = 1;
}
if (n / pnorm > maxErrorRate) {
System.out.println("stopped:" + sumC);
break;
}
if (shouldAbort())
return rules;
}
TextRulerStatisticsCollector c = sums.get(counter - 1);
rule.setCoveringStatistics(sums.get(counter - 1));
inducedRules.put(ruleString, c);
}
}
for (int ruleIndex = 0; ruleIndex < rules.size(); ruleIndex++) {