use of com.joliciel.talismane.machineLearning.ClassificationEvent in project jochre by urieli.
the class JochreSplitEventStream method next.
@Override
public ClassificationEvent next() {
ClassificationEvent event = null;
if (this.hasNext()) {
LOG.debug("next event, " + splitCandidate.getShape() + ", split: " + splitCandidate.getPosition());
List<FeatureResult<?>> featureResults = new ArrayList<FeatureResult<?>>();
// analyse features
for (SplitFeature<?> feature : splitFeatures) {
RuntimeEnvironment env = new RuntimeEnvironment();
FeatureResult<?> featureResult = feature.check(splitCandidate, env);
if (featureResult != null) {
featureResults.add(featureResult);
if (LOG.isTraceEnabled()) {
LOG.trace(featureResult.toString());
}
}
}
SplitOutcome outcome = SplitOutcome.DO_NOT_SPLIT;
for (Split split : splitCandidate.getShape().getSplits()) {
int distance = splitCandidate.getPosition() - split.getPosition();
if (distance < 0)
distance = 0 - distance;
// recall
if (distance < splitCandidateFinder.getMinDistanceBetweenSplits()) {
outcome = SplitOutcome.DO_SPLIT;
break;
}
}
if (outcome.equals(SplitOutcome.DO_SPLIT))
yesCount++;
else
noCount++;
LOG.debug("Outcome: " + outcome);
event = new ClassificationEvent(featureResults, outcome.name());
// set splitCandidate to null so that hasNext can retrieve the next one.
this.splitCandidate = null;
}
return event;
}
Aggregations