use of com.joliciel.talismane.machineLearning.features.FeatureResult 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;
}
use of com.joliciel.talismane.machineLearning.features.FeatureResult in project jochre by urieli.
the class RecursiveShapeSplitter method shouldSplit.
public double shouldSplit(Split splitCandidate) {
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());
}
}
}
List<Decision> decisions = decisionMaker.decide(featureResults);
double yesProb = 0.0;
for (Decision decision : decisions) {
if (decision.getOutcome().equals(SplitOutcome.DO_SPLIT.name())) {
yesProb = decision.getProbability();
break;
}
}
if (LOG.isTraceEnabled()) {
LOG.trace("splitCandidate: left=" + splitCandidate.getShape().getLeft() + ", pos=" + splitCandidate.getPosition());
LOG.trace("yesProb: " + yesProb);
}
return yesProb;
}
Aggregations