< Summary

Information
Class: Intentum.Core.Evaluation.IntentEvaluator
Assembly: Intentum.Core
File(s): /home/runner/work/Intentum/Intentum/src/Intentum.Core/Evaluation/IntentEvaluator.cs
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 40
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
Evaluate(...)100%11100%
Normalize(...)100%11100%

File(s)

/home/runner/work/Intentum/Intentum/src/Intentum.Core/Evaluation/IntentEvaluator.cs

#LineLine coverage
 1using Intentum.Core.Behavior;
 2using Intentum.Core.Intents;
 3
 4namespace Intentum.Core.Evaluation;
 5
 6/// <summary>
 7/// Infers intent and confidence from a behavior space.
 8/// </summary>
 9public static class IntentEvaluator
 10{
 11    /// <summary>Evaluates the given behavior space and returns an intent with confidence and signals.</summary>
 12    public static IntentEvaluationResult Evaluate(
 13        string intentName,
 14        BehaviorSpace behaviorSpace)
 315    {
 316        var vector = behaviorSpace.ToVector();
 17
 318        var signals = vector.Dimensions.Select(d =>
 619            new IntentSignal(
 620                Source: "behavior",
 621                Description: d.Key,
 622                Weight: Normalize(d.Value)
 623            )).ToList();
 24
 625        var score = signals.Sum(s => s.Weight) / Math.Max(1, signals.Count);
 26
 327        var confidence = IntentConfidence.FromScore(score);
 28
 329        var intent = new Intent(
 330            intentName,
 331            signals,
 332            confidence
 333        );
 34
 335        return new IntentEvaluationResult(intent, vector);
 336    }
 37
 38    private static double Normalize(double value)
 339        => Math.Min(1.0, value / 10.0);
 40}