exampleDocuments.createExamplesForTarget(target);
examples = exampleDocuments.getAllPositiveExamples();
if (shouldAbort())
return null;
TextRulerRuleList bestRulesPool = new TextRulerRuleList();
TextRulerRuleList contextRulesPool = new TextRulerRuleList();
String slotName = target.getSingleSlotRawTypeName();
bestRulesPoolMap.put(slotName, bestRulesPool);
contextRulesPoolMap.put(slotName, contextRulesPool);
coveredExamples = new HashSet<TextRulerExample>();
int roundNumber = 0;
for (TextRulerExample e : examples)
if (!coveredExamples.contains(e)) {
if (shouldAbort())
break;
roundNumber++;
currentBestRules = new LP2CurrentBestRulesQueue(maxCurrentBestRulesCount);
currentContextualRules = new LP2CurrentBestRulesQueue(maxCurrentContextualRulesCount);
// TextRulerToolkit.log("Example: "+e.getAnnotation().getBegin()+" : "+e.getAnnotation().getEnd());
induceRulesFromExample(e, roundNumber);
// TextRulerToolkit.log("Best Rules from this Seed: "+currentBestRules.size());
// if (TextRulerToolkit.DEBUG && currentBestRules.size()>1)
// {
// for (TextRulerRule r : currentBestRules)
// {
// TextRulerToolkit.log("\tp="+r.getCoveringStatistics().getCoveredPositivesCount()+"; n="+r.getCoveringStatistics().getCoveredNegativesCount()+"; "+r.getRuleString());
// for (TextRulerExample ex :
// r.getCoveringStatistics().getCoveredPositiveExamples())
// {
// TextRulerToolkit.log("\t\te="+ex.getAnnotation().getBegin());
//
// }
// }
// }
for (LP2Rule bestRule : currentBestRules) {
addToFinalBestRulesPool(bestRule);
}
for (LP2Rule ctxRule : currentContextualRules) {
addToFinalContextRulesPool(ctxRule);
}
sendStatusUpdateToDelegate("New Rules added.", TextRulerLearnerState.ML_RUNNING, true);
}
if (TextRulerToolkit.DEBUG) {
bestRulesPool.saveToRulesFile(getIntermediateRulesFileName(), getFileHeaderString(true));
// for (TextRulerRule r : bestRulesPool)
// {
// TextRulerToolkit.log("p="+r.getCoveringStatistics().getCoveredPositivesCount()+"; n="+r.getCoveringStatistics().getCoveredNegativesCount()+"; "+r.getRuleString());
// }
}
TextRulerRuleList result = bestRulesPool;
if (contextualRules != null)
for (TextRulerRule r : contextRulesPool)
contextualRules.add(r);
return result;
}