Chaned score to float and added QueryScorer.getMaxTermWeight (useful for callibrating GradientFormatter)

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@151025 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Harwood 2005-01-07 21:17:09 +00:00
parent 96c0bf9c90
commit ceb895e772
2 changed files with 15 additions and 3 deletions

View File

@ -23,7 +23,7 @@ package org.apache.lucene.search.highlight;
*/
public class GradientFormatter implements Formatter
{
private int maxScore;
private float maxScore;
int fgRMin, fgGMin, fgBMin;
@ -41,7 +41,8 @@ public class GradientFormatter implements Formatter
* Sets the color range for the IDF scores
*
* @param maxScore
* The score (and above) displayed as maxColor
* The score (and above) displayed as maxColor (See QueryScorer.getMaxWeight
* which can be used to callibrate scoring scale)
* @param minForegroundColor
* The hex color used for representing IDF scores of zero eg
* #FFFFFF (white) or null if no foreground color required
@ -55,7 +56,7 @@ public class GradientFormatter implements Formatter
* The largest hex color used for representing IDF scores eg
* #000000 (black) or null if no background color required
*/
public GradientFormatter(int maxScore, String minForegroundColor,
public GradientFormatter(float maxScore, String minForegroundColor,
String maxForegroundColor, String minBackgroundColor,
String maxBackgroundColor)
{

View File

@ -35,6 +35,7 @@ public class QueryScorer implements Scorer
TextFragment currentTextFragment=null;
HashSet uniqueTermsInFragment;
float totalScore=0;
float maxTermWeight=0;
private HashMap termsToFind;
@ -67,6 +68,7 @@ public class QueryScorer implements Scorer
for (int i = 0; i < weightedTerms.length; i++)
{
termsToFind.put(weightedTerms[i].term,weightedTerms[i]);
maxTermWeight=Math.max(maxTermWeight,weightedTerms[i].getWeight());
}
}
@ -122,4 +124,13 @@ public class QueryScorer implements Scorer
//this class has no special operations to perform at end of processing
}
/**
*
* @return The highest weighted term (useful for passing to GradientFormatter to set
* top end of coloring scale.
*/
public float getMaxTermWeight()
{
return maxTermWeight;
}
}