Qizx fe-4.4p2 API

com.qizx.api.util.fulltext
Class DefaultScorer

java.lang.Object
  extended by com.qizx.api.util.fulltext.DefaultScorer
All Implemented Interfaces:
Scorer

public class DefaultScorer
extends Object
implements Scorer

Default scorer implementation


Field Summary
static String FT_WEIGHT
          Name of the metadata property which can contain a weight for a Document.
 
Fields inherited from interface com.qizx.api.fulltext.Scorer
CORE_SCORE
 
Constructor Summary
DefaultScorer()
           
 
Method Summary
 float getDocumentWeight(Document scoredDocument)
          Support of document ranking: returns a positive number (default 1) which is used as a weight for the document.
 float normalizeScore(float rawScore)
          Normalizes a score so that its value is between 0 and 1
 float normAll(float[] subWeights)
          Computes the weight norm associated with a conjunction ('ftand' or 'all') of full-text selections.
 float normOr(float[] subWeights)
          Computes the weight norm associated with a disjunction ('ftor' or 'any') of full-text selections.
 float normWord(float inverseDocFrequency)
          Computes the weight associated with a simple word.
 float scoreAll(float[] scores)
          Computes the score of a conjunction ('ftand' or 'all') of full-text selections.
 float scoreOr(float[] scores, int scoreCount)
          Computes the score of a disjunction ('ftor' or 'any') of full-text selections.
 float scoreWord(float norm, float termFrequency)
          Computes the score of a single word.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FT_WEIGHT

public static final String FT_WEIGHT
Name of the metadata property which can contain a weight for a Document. Support of document ranking.

See Also:
Constant Field Values
Constructor Detail

DefaultScorer

public DefaultScorer()
Method Detail

normalizeScore

public float normalizeScore(float rawScore)
Description copied from interface: Scorer
Normalizes a score so that its value is between 0 and 1

Specified by:
normalizeScore in interface Scorer
Parameters:
rawScore - a positive value possibly greater than 1

normWord

public float normWord(float inverseDocFrequency)
Description copied from interface: Scorer
Computes the weight associated with a simple word.

Specified by:
normWord in interface Scorer
Parameters:
inverseDocFrequency - inverse of the fraction of documents that contain this term
Returns:
the computed weighting of simple term. The default implementation is: 1 + log(inverseDocFrequency)

scoreWord

public float scoreWord(float norm,
                       float termFrequency)
Description copied from interface: Scorer
Computes the score of a single word.

Specified by:
scoreWord in interface Scorer
Parameters:
norm - normalized weight of word (as computed by Scorer.normWord(float)).
termFrequency - relative term frequency in the current document (number of occurrences divided by average number of occurrences in all documents).
Returns:
the computed score. The default implementation is termFrequency multiplied by 'norm'.

normAll

public float normAll(float[] subWeights)
Description copied from interface: Scorer
Computes the weight norm associated with a conjunction ('ftand' or 'all') of full-text selections. The default weight norm is the sum of squared sub-weights power -1/2.

Specified by:
normAll in interface Scorer
Parameters:
subWeights - weight values computed for sub-selections.
Returns:
the computed weighting.

scoreAll

public float scoreAll(float[] scores)
Description copied from interface: Scorer
Computes the score of a conjunction ('ftand' or 'all') of full-text selections.

Specified by:
scoreAll in interface Scorer
Parameters:
scores - weight values computed for sub-selections.
Returns:
the computed weighting. The default implementation is the sum of scores.

normOr

public float normOr(float[] subWeights)
Description copied from interface: Scorer
Computes the weight norm associated with a disjunction ('ftor' or 'any') of full-text selections.

Specified by:
normOr in interface Scorer
Parameters:
subWeights - weight values computed for sub-selections.
Returns:
the normed weighting. The default implementation is a weighted average of the sum of sub-weights and their maximum value.

scoreOr

public float scoreOr(float[] scores,
                     int scoreCount)
Description copied from interface: Scorer
Computes the score of a disjunction ('ftor' or 'any') of full-text selections.

Specified by:
scoreOr in interface Scorer
Parameters:
scores - weight values computed for sub-selections.
scoreCount - number of values in scores
Returns:
the computed score. The default implementation is a weighted average of the sum of sub-scores and their maximum value.

getDocumentWeight

public float getDocumentWeight(Document scoredDocument)
Description copied from interface: Scorer
Support of document ranking: returns a positive number (default 1) which is used as a weight for the document.

Specified by:
getDocumentWeight in interface Scorer
Parameters:
scoredDocument - document to weight. Typically, the weight is a metadata property of the document.
Returns:
a positive number

© 2010 Axyana Software