public QueryScorer(WeightedTerm[] weightedTerms) { termsToFind = new Hashtable(); for (int i = 0; i < weightedTerms.Length; i++) { WeightedTerm existingTerm = (WeightedTerm) termsToFind[weightedTerms[i].term]; if ((existingTerm == null) || (existingTerm.weight < weightedTerms[i].weight)) { //if a term is defined more than once, always use the highest scoring weight termsToFind[weightedTerms[i].term] = weightedTerms[i]; maxTermWeight = System.Math.Max(maxTermWeight, weightedTerms[i].Weight); } } }
public QueryTermScorer(WeightedTerm[] weightedTerms) { termsToFind = new HashMap <String, WeightedTerm>(); for (int i = 0; i < weightedTerms.Length; i++) { WeightedTerm existingTerm = termsToFind[weightedTerms[i].Term]; if ((existingTerm == null) || (existingTerm.Weight < weightedTerms[i].Weight)) { // if a term is defined more than once, always use the highest scoring // Weight termsToFind[weightedTerms[i].Term] = weightedTerms[i]; maxTermWeight = Math.Max(maxTermWeight, weightedTerms[i].Weight); } } }
/* (non-Javadoc) * @see org.apache.lucene.search.highlight.Scorer#getTokenScore() */ public float GetTokenScore() { String termText = termAtt.Term; WeightedTerm queryTerm = termsToFind[termText]; if (queryTerm == null) { // not a query term - return return(0); } // found a query term - is it unique in this doc? if (!uniqueTermsInFragment.Contains(termText)) { totalScore += queryTerm.Weight; uniqueTermsInFragment.Add(termText); } return(queryTerm.Weight); }
public QueryTermScorer(WeightedTerm[] weightedTerms) { termsToFind = new HashMap<String, WeightedTerm>(); for (int i = 0; i < weightedTerms.Length; i++) { WeightedTerm existingTerm = termsToFind[weightedTerms[i].Term]; if ((existingTerm == null) || (existingTerm.Weight < weightedTerms[i].Weight)) { // if a term is defined more than once, always use the highest scoring // Weight termsToFind[weightedTerms[i].Term] = weightedTerms[i]; maxTermWeight = Math.Max(maxTermWeight, weightedTerms[i].Weight); } } }