Search in sources :

Example 26 with RuntimeEnvironment

use of com.joliciel.talismane.machineLearning.features.RuntimeEnvironment 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;
}
Also used : RuntimeEnvironment(com.joliciel.talismane.machineLearning.features.RuntimeEnvironment) ArrayList(java.util.ArrayList) FeatureResult(com.joliciel.talismane.machineLearning.features.FeatureResult) Decision(com.joliciel.talismane.machineLearning.Decision)

Aggregations

RuntimeEnvironment (com.joliciel.talismane.machineLearning.features.RuntimeEnvironment)26 ArrayList (java.util.ArrayList)19 FeatureResult (com.joliciel.talismane.machineLearning.features.FeatureResult)18 Decision (com.joliciel.talismane.machineLearning.Decision)14 List (java.util.List)13 TokenSequence (com.joliciel.talismane.tokeniser.TokenSequence)10 Config (com.typesafe.config.Config)10 TalismaneException (com.joliciel.talismane.TalismaneException)8 ClassificationEvent (com.joliciel.talismane.machineLearning.ClassificationEvent)8 PosTaggedToken (com.joliciel.talismane.posTagger.PosTaggedToken)8 Sentence (com.joliciel.talismane.rawText.Sentence)8 Token (com.joliciel.talismane.tokeniser.Token)8 IOException (java.io.IOException)8 Map (java.util.Map)8 Set (java.util.Set)8 SortedSet (java.util.SortedSet)8 TreeSet (java.util.TreeSet)8 Collectors (java.util.stream.Collectors)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8