Exemplo n.º 1
0
		/// <summary>Implemented as
		/// <code>state.getBoost()*lengthNorm(numTerms)</code>, where
		/// <code>numTerms</code> is {@link FieldInvertState#GetLength()} if {@link
		/// #setDiscountOverlaps} is false, else it's {@link
		/// FieldInvertState#GetLength()} - {@link
		/// FieldInvertState#GetNumOverlap()}.
		/// 
		/// <p/><b>WARNING</b>: This API is new and experimental, and may suddenly
		/// change.<p/> 
		/// </summary>
		public override float ComputeNorm(System.String field, FieldInvertState state)
		{
			int numTerms;
			if (discountOverlaps)
				numTerms = state.GetLength() - state.GetNumOverlap();
			else
				numTerms = state.GetLength();
			return (float) (state.GetBoost() * LengthNorm(field, numTerms));
		}
Exemplo n.º 2
0
 /// <summary>Implemented as
 /// <c>state.getBoost()*lengthNorm(numTerms)</c>, where
 /// <c>numTerms</c> is <see cref="FieldInvertState.Length" /> if <see cref="DiscountOverlaps" />
 /// is false, else it's <see cref="FieldInvertState.Length" />
 /// - <see cref="FieldInvertState.NumOverlap" />
 ///.
 /// 
 /// <p/><b>WARNING</b>: This API is new and experimental, and may suddenly
 /// change.<p/> 
 /// </summary>
 public override float ComputeNorm(System.String field, FieldInvertState state)
 {
     int numTerms;
     if (internalDiscountOverlaps)
         numTerms = state.Length - state.NumOverlap;
     else
         numTerms = state.Length;
     return (state.Boost * LengthNorm(field, numTerms));
 }
Exemplo n.º 3
0
        /// <summary>Implemented as
        /// <code>state.getBoost()*lengthNorm(numTerms)</code>, where
        /// <code>numTerms</code> is {@link FieldInvertState#GetLength()} if {@link
        /// #setDiscountOverlaps} is false, else it's {@link
        /// FieldInvertState#GetLength()} - {@link
        /// FieldInvertState#GetNumOverlap()}.
        ///
        /// <p/><b>WARNING</b>: This API is new and experimental, and may suddenly
        /// change.<p/>
        /// </summary>
        public override float ComputeNorm(System.String field, FieldInvertState state)
        {
            int numTerms;

            if (discountOverlaps)
            {
                numTerms = state.GetLength() - state.GetNumOverlap();
            }
            else
            {
                numTerms = state.GetLength();
            }
            return((float)(state.GetBoost() * LengthNorm(field, numTerms)));
        }
        /// <summary>Implemented as
        /// <c>state.getBoost()*lengthNorm(numTerms)</c>, where
        /// <c>numTerms</c> is <see cref="FieldInvertState.Length" /> if <see cref="DiscountOverlaps" />
        /// is false, else it's <see cref="FieldInvertState.Length" />
        /// - <see cref="FieldInvertState.NumOverlap" />
        ///.
        ///
        /// <p/><b>WARNING</b>: This API is new and experimental, and may suddenly
        /// change.<p/>
        /// </summary>
        public override float ComputeNorm(System.String field, FieldInvertState state)
        {
            int numTerms;

            if (internalDiscountOverlaps)
            {
                numTerms = state.Length - state.NumOverlap;
            }
            else
            {
                numTerms = state.Length;
            }
            return(state.Boost * LengthNorm(field, numTerms));
        }
Exemplo n.º 5
0
        public override float ComputeNorm(System.String field, Lucene.Net.Index.FieldInvertState state)
        {
            int numTerms;

            if (discountOverlaps)
            {
                numTerms = state.Length - state.NumOverlap;
            }
            else
            {
                numTerms = state.Length;
            }
            return((float)(state.Boost * LengthNorm(field, numTerms)));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Encodes the document length in the same way as <seealso cref="TFIDFSimilarity"/>. </summary>
        public override long ComputeNorm(FieldInvertState state)
        {
            float numTerms;

            if (DiscountOverlaps_Renamed)
            {
                numTerms = state.Length - state.NumOverlap;
            }
            else
            {
                numTerms = state.Length;
            }
            return(EncodeNormValue(state.Boost, numTerms));
        }
Exemplo n.º 7
0
 /// <summary> Compute the normalization value for a field, given the accumulated
 /// state of term processing for this field (see <seealso cref="FieldInvertState"/>).
 ///
 /// <p/>Implementations should calculate a float value based on the field
 /// state and then return that value.
 ///
 /// <p/>For backward compatibility this method by default calls
 /// {@link #LengthNorm(String, int)} passing
 /// {@link FieldInvertState#GetLength()} as the second argument, and
 /// then multiplies this value by <seealso cref="FieldInvertState.GetBoost()"/>.<p/>
 ///
 /// <p/><b>WARNING</b>: This API is new and experimental and may
 /// suddenly change.<p/>
 ///
 /// </summary>
 /// <param name="field">field name
 /// </param>
 /// <param name="state">current processing state for this field
 /// </param>
 /// <returns> the calculated float norm
 /// </returns>
 public virtual float ComputeNorm(System.String field, FieldInvertState state)
 {
     return((float)(state.GetBoost() * LengthNorm(field, state.GetLength())));
 }
 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 //Make everything else 1 so we see the effect of the payload
 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 public override float LengthNorm(FieldInvertState state)
 {
     return state.Boost;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Computes the normalization value for a field, given the accumulated
 /// state of term processing for this field (see <seealso cref="FieldInvertState"/>).
 ///
 /// <p>Matches in longer fields are less precise, so implementations of this
 /// method usually set smaller values when <code>state.getLength()</code> is large,
 /// and larger values when <code>state.getLength()</code> is small.
 ///
 /// @lucene.experimental
 /// </summary>
 /// <param name="state"> current processing state for this field </param>
 /// <returns> computed norm value </returns>
 public abstract long ComputeNorm(FieldInvertState state);
Exemplo n.º 10
0
 public override long ComputeNorm(FieldInvertState state)
 {
     return Sims[0].ComputeNorm(state);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Encodes the document length in the same way as <seealso cref="TFIDFSimilarity"/>. </summary>
 public override long ComputeNorm(FieldInvertState state)
 {
     float numTerms;
     if (DiscountOverlaps_Renamed)
     {
         numTerms = state.Length - state.NumOverlap;
     }
     else
     {
         numTerms = state.Length;
     }
     return EncodeNormValue(state.Boost, numTerms);
 }
Exemplo n.º 12
0
 public override float ComputeNorm(System.String fieldName, FieldInvertState state)
 {
     return(delegee.ComputeNorm(fieldName, state));
 }
Exemplo n.º 13
0
 public override long ComputeNorm(FieldInvertState state)
 {
     return 1; // we dont care
 }
Exemplo n.º 14
0
 /// <summary>
 /// Compute an index-time normalization value for this field instance.
 /// <p>
 /// this value will be stored in a single byte lossy representation by
 /// <seealso cref="#encodeNormValue(float)"/>.
 /// </summary>
 /// <param name="state"> statistics of the current field (such as length, boost, etc) </param>
 /// <returns> an index-time normalization value </returns>
 public abstract float LengthNorm(FieldInvertState state);
Exemplo n.º 15
0
 public override sealed long ComputeNorm(FieldInvertState state)
 {
     float normValue = LengthNorm(state);
     return EncodeNormValue(normValue);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Computes the normalization value for a field, given the accumulated
 /// state of term processing for this field (see <seealso cref="FieldInvertState"/>).
 ///
 /// <p>Matches in longer fields are less precise, so implementations of this
 /// method usually set smaller values when <code>state.getLength()</code> is large,
 /// and larger values when <code>state.getLength()</code> is small.
 ///
 /// @lucene.experimental
 /// </summary>
 /// <param name="state"> current processing state for this field </param>
 /// <returns> computed norm value </returns>
 public abstract long ComputeNorm(FieldInvertState state);
Exemplo n.º 17
0
 public override float LengthNorm(FieldInvertState state)
 {
     return 10f;
 }
Exemplo n.º 18
0
 /// <summary> Compute the normalization value for a field, given the accumulated
 /// state of term processing for this field (see <see cref="FieldInvertState" />).
 ///
 /// <p/>Implementations should calculate a float value based on the field
 /// state and then return that value.
 ///
 /// <p/>For backward compatibility this method by default calls
 /// <see cref="LengthNorm(string, int)" /> passing
 /// <see cref="FieldInvertState.GetLength()" /> as the second argument, and
 /// then multiplies this value by <see cref="FieldInvertState.GetBoost()" />.<p/>
 ///
 /// <p/><b>WARNING</b>: This API is new and experimental and may
 /// suddenly change.<p/>
 ///
 /// </summary>
 /// <param name="field">field name
 /// </param>
 /// <param name="state">current processing state for this field
 /// </param>
 /// <returns> the calculated float norm
 /// </returns>
 public virtual float ComputeNorm(string field, FieldInvertState state)
 {
     return((float)(state.Boost * LengthNorm(field, state.Length)));
 }
Exemplo n.º 19
0
 public override sealed long ComputeNorm(FieldInvertState state)
 {
     return(Get(state.Name).ComputeNorm(state));
 }
Exemplo n.º 20
0
 public virtual void TestDiscountOverlapsBoost()
 {
     DefaultSimilarity expected = new DefaultSimilarity();
     SimilarityBase actual = new DFRSimilarity(new BasicModelIne(), new AfterEffectB(), new NormalizationH2());
     expected.DiscountOverlaps = false;
     actual.DiscountOverlaps = false;
     FieldInvertState state = new FieldInvertState("foo");
     state.Length = 5;
     state.NumOverlap = 2;
     state.Boost = 3;
     Assert.AreEqual(expected.ComputeNorm(state), actual.ComputeNorm(state));
     expected.DiscountOverlaps = true;
     actual.DiscountOverlaps = true;
     Assert.AreEqual(expected.ComputeNorm(state), actual.ComputeNorm(state));
 }
		public override float ComputeNorm(System.String fieldName, FieldInvertState state)
		{
			return delegee.ComputeNorm(fieldName, state);
		}
 public override sealed long ComputeNorm(FieldInvertState state)
 {
     return Get(state.Name).ComputeNorm(state);
 }
Exemplo n.º 23
0
		/// <summary> Compute the normalization value for a field, given the accumulated
		/// state of term processing for this field (see {@link FieldInvertState}).
		/// 
		/// <p/>Implementations should calculate a float value based on the field
		/// state and then return that value.
		/// 
		/// <p/>For backward compatibility this method by default calls
		/// {@link #LengthNorm(String, int)} passing
		/// {@link FieldInvertState#GetLength()} as the second argument, and
		/// then multiplies this value by {@link FieldInvertState#GetBoost()}.<p/>
		/// 
		/// <p/><b>WARNING</b>: This API is new and experimental and may
		/// suddenly change.<p/>
		/// 
		/// </summary>
		/// <param name="field">field name
		/// </param>
		/// <param name="state">current processing state for this field
		/// </param>
		/// <returns> the calculated float norm
		/// </returns>
		public virtual float ComputeNorm(System.String field, FieldInvertState state)
		{
			return (float) (state.GetBoost() * LengthNorm(field, state.GetLength()));
		}
Exemplo n.º 24
0
 public override long ComputeNorm(FieldInvertState state)
 {
     return(Sims[0].ComputeNorm(state));
 }