org.hd.d.pg2k.ai.scorer
Class ScoreAndConf

java.lang.Object
  extended by org.hd.d.pg2k.ai.scorer.ScoreAndConf
All Implemented Interfaces:
MemoryTools.Internable

public final class ScoreAndConf
extends java.lang.Object
implements MemoryTools.Internable

Immutable (and Internable) return type from scorer method. Allowed values run from -MAX (bad) through 0 (neutral) to +MAX (good) for score, and from 0 (no confidence) to +MAX (full) for confidence.

Note that the score values are symmetrical about zero.

The low-ish precision of the elements is deliberate to reflect the fact that scoring is bound to be fairly imprecise and to save a little space.


Field Summary
static java.util.Comparator<ScoreAndConf> ByConfidence
          A static Comparator that sorts by confidence.
static java.util.Comparator<ScoreAndConf> ByGoodness
          A static Comparator that sorts by goodness.
 short confidence
          Confidence: 0 (no confidence) to +MAX (full) for confidence.
static short MAX
          Maximum positive or negative value of any element; strictly positive.
static int MAX_GOODNESS
          Max (+ve) "goodness" value returned by computeScorerGoodness(); strictly positive.
static ScoreAndConf NO_OPINION
          All-zeros value used to mean "no idea" / "no opinion" when returned by a Scorer.
 short score
          Score: -MAX (bad) through 0 (neutral) to +MAX (good).
 
Constructor Summary
ScoreAndConf(int score, int confidence)
          Construct an instance using int values; requires extra checking.
ScoreAndConf(short score, short confidence)
          Construct an instance.
 
Method Summary
static int computeScorerGoodness(ScoreAndConf sac)
          Compute Scorer "goodness" from its ScoreAndConfidence value.
 boolean equals(java.lang.Object obj)
          Equality depends on all elements.
static ScoreAndConf fromString(java.lang.String s)
          Parse toString() representation to return ScoreAndConf value; never null.
 int hashCode()
          The hash depends on all elements.
 java.lang.Boolean isGood()
          Find out if this is notably good or bad using the same thresholds as for voting (etc) in the rest of the Gallery.
 java.lang.String toString()
          Compute human-readable summary; never null.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX

public static final short MAX
Maximum positive or negative value of any element; strictly positive.

See Also:
Constant Field Values

score

public final short score
Score: -MAX (bad) through 0 (neutral) to +MAX (good).


confidence

public final short confidence
Confidence: 0 (no confidence) to +MAX (full) for confidence.


NO_OPINION

public static final ScoreAndConf NO_OPINION
All-zeros value used to mean "no idea" / "no opinion" when returned by a Scorer.


MAX_GOODNESS

public static final int MAX_GOODNESS
Max (+ve) "goodness" value returned by computeScorerGoodness(); strictly positive.

See Also:
Constant Field Values

ByGoodness

public static final java.util.Comparator<ScoreAndConf> ByGoodness
A static Comparator that sorts by goodness.


ByConfidence

public static final java.util.Comparator<ScoreAndConf> ByConfidence
A static Comparator that sorts by confidence.

Constructor Detail

ScoreAndConf

public ScoreAndConf(short score,
                    short confidence)
Construct an instance.


ScoreAndConf

public ScoreAndConf(int score,
                    int confidence)
Construct an instance using int values; requires extra checking.

Method Detail

hashCode

public int hashCode()
The hash depends on all elements.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Equality depends on all elements.

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Compute human-readable summary; never null. This is also designed to be parsable to (re)construct an instance as an alternative to serialisation.

This includes the scale (maximum) for non-zero values to allow for robust reconstruction in future versions.

Overrides:
toString in class java.lang.Object

fromString

public static ScoreAndConf fromString(java.lang.String s)
Parse toString() representation to return ScoreAndConf value; never null.

Throws:
java.lang.IllegalArgumentException - if the input is unparsable

isGood

public java.lang.Boolean isGood()
Find out if this is notably good or bad using the same thresholds as for voting (etc) in the rest of the Gallery. Returns TRUE if rated good, FALSE if bad, null if not significantly either (ie too close to neutral) or if unknown.

This is based on the product of score and confidence.


computeScorerGoodness

public static int computeScorerGoodness(ScoreAndConf sac)
Compute Scorer "goodness" from its ScoreAndConfidence value. We want Scorers with a good correlation (+ve) and good confidence.

This is a unitless relative value used to sort Scorers in the range [-MAX^2,+MAX^2] ie [-MAX_GOODNESS,+MAX_GOODNESS where -ve is "wrongheaded", 0 is "useless", and +ve is "good".


DHD Multimedia Gallery V1.60.69

Copyright (c) 1996-2012, Damon Hart-Davis. All rights reserved.