Ejemplo n.º 1
0
 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);
         }
     }
 }
Ejemplo n.º 2
0
 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);
         }
     }
 }
Ejemplo n.º 3
0
        /* (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);
        }
Ejemplo n.º 4
0
 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);
         }
     }
 }