Package com.tnsai.quality.tracing
Record Class Score
java.lang.Object
java.lang.Record
com.tnsai.quality.tracing.Score
- Record Components:
name- score name (e.g. "quality", "relevance", "toxicity")value- numeric value (0.0 for false, 1.0 for true in boolean mode)type- the type of score valuesource- who/what produced the scoreobservationId- optional id linking this score to a specific observation (null for trace-level)label- optional categorical label (only meaningful forScoreType.CATEGORICAL)
public record Score(String name, double value, ScoreType type, ScoreSource source, String observationId, String label)
extends Record
A score attached to a trace or observation.
Scores can be numeric (0.0-1.0 continuous), boolean (pass/fail), or categorical (label). Each score records its source (human, model, or heuristic) for provenance tracking.
Instances are immutable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Scorebool(String name, boolean passed, ScoreSource source) Creates a boolean score (pass=1.0, fail=0.0).static Scorecategorical(String name, String label, ScoreSource source) Creates a categorical score with a label.final booleanIndicates whether some other object is "equal to" this one.forObservation(String observationId) Returns a copy of this score bound to the given observation.final inthashCode()Returns a hash code value for this object.label()Returns the value of thelabelrecord component.name()Returns the value of thenamerecord component.static Scorenumeric(String name, double value, ScoreSource source) Creates a numeric score (0.0 to 1.0 range).Returns the value of theobservationIdrecord component.source()Returns the value of thesourcerecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.doublevalue()Returns the value of thevaluerecord component.
-
Constructor Details
-
Score
public Score(String name, double value, ScoreType type, ScoreSource source, String observationId, String label) Creates an instance of aScorerecord class.- Parameters:
name- the value for thenamerecord componentvalue- the value for thevaluerecord componenttype- the value for thetyperecord componentsource- the value for thesourcerecord componentobservationId- the value for theobservationIdrecord componentlabel- the value for thelabelrecord component
-
-
Method Details
-
numeric
Creates a numeric score (0.0 to 1.0 range). -
bool
Creates a boolean score (pass=1.0, fail=0.0). -
categorical
Creates a categorical score with a label. -
forObservation
Returns a copy of this score bound to the given observation. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
value
public double value()Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
source
Returns the value of thesourcerecord component.- Returns:
- the value of the
sourcerecord component
-
observationId
Returns the value of theobservationIdrecord component.- Returns:
- the value of the
observationIdrecord component
-
label
Returns the value of thelabelrecord component.- Returns:
- the value of the
labelrecord component
-