23 using System.Collections.Generic;
26 using Lucene.Net.Analysis;
27 using Lucene.Net.Analysis.Tokenattributes;
28 using Lucene.Net.Index;
29 using Lucene.Net.Support;
31 namespace Lucene.Net.Search.Highlight
43 private HashSet<String> uniqueTermsInFragment;
45 private float totalScore = 0;
46 private float maxTermWeight = 0;
47 private HashMap<String, WeightedTerm> termsToFind;
58 : this(QueryTermExtractor.GetTerms(query))
70 : this(QueryTermExtractor.GetTerms(query, false, fieldName))
86 : this(QueryTermExtractor.GetIdfWeightedTerms(query, reader, fieldName))
92 termsToFind =
new HashMap<String, WeightedTerm>();
93 for (
int i = 0; i < weightedTerms.Length; i++)
96 if ((existingTerm == null)
97 || (existingTerm.
Weight < weightedTerms[i].Weight))
101 termsToFind[weightedTerms[i].Term] = weightedTerms[i];
102 maxTermWeight = Math.Max(maxTermWeight, weightedTerms[i].
Weight);
127 uniqueTermsInFragment =
new HashSet<String>();
128 currentTextFragment = newFragment;
138 public float GetTokenScore()
140 String termText = termAtt.Term;
143 if (queryTerm == null)
149 if (!uniqueTermsInFragment.Contains(termText))
151 totalScore += queryTerm.
Weight;
152 uniqueTermsInFragment.Add(termText);
162 public float FragmentScore
164 get {
return totalScore; }
174 public void AllFragmentsProcessed()
185 public float MaxTermWeight
187 get {
return maxTermWeight; }