Example #1
0
        /// <summary>Expert: Constructs and initializes a Weight for a top-level query. </summary>
        public virtual Weight Weight(Searcher searcher)
        {
            Query  query  = searcher.Rewrite(this);
            Weight weight = query.CreateWeight(searcher);
            float  sum    = weight.SumOfSquaredWeights();
            float  norm   = GetSimilarity(searcher).QueryNorm(sum);

            weight.Normalize(norm);
            return(weight);
        }
Example #2
0
            public virtual float SumOfSquaredWeights()
            {
                float sum = 0.0f;

                for (int i = 0; i < weights.Count; i++)
                {
                    BooleanClause c = (BooleanClause)Enclosing_Instance.clauses[i];
                    Weight        w = (Weight)weights[i];
                    if (!c.IsProhibited())
                    {
                        sum += w.SumOfSquaredWeights();                         // sum sub weights
                    }
                }

                sum *= Enclosing_Instance.GetBoost() * Enclosing_Instance.GetBoost();                 // boost each sub-weight

                return(sum);
            }
Example #3
0
            public override float SumOfSquaredWeights()
            {
                float sum = 0.0f;

                for (int i = 0; i < weights.Count; i++)
                {
                    BooleanClause c = (BooleanClause)Enclosing_Instance.clauses[i];
                    Weight        w = (Weight)weights[i];
                    // call sumOfSquaredWeights for all clauses in case of side effects
                    float s = w.SumOfSquaredWeights();                     // sum sub weights
                    if (!c.IsProhibited())
                    {
                        // only add to sum for non-prohibited clauses
                        sum += s;
                    }
                }

                sum *= Enclosing_Instance.GetBoost() * Enclosing_Instance.GetBoost();                 // boost each sub-weight

                return(sum);
            }