Exemplo n.º 1
0
 static DefaultSimilarity()
 {
     for (int i = 0; i < 256; i++)
     {
         NORM_TABLE[i] = SmallFloat.Byte315ToFloat((sbyte)i);
     }
 }
Exemplo n.º 2
0
 static BM25Similarity()
 {
     for (int i = 0; i < 256; i++)
     {
         float f = SmallFloat.Byte315ToFloat((sbyte)i);
         NORM_TABLE[i] = 1.0f / (f * f);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 得到文档某字段的Norm
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="field"></param>
 /// <param name="docId"></param>
 /// <returns></returns>
 public static float GetNorm(IndexReader reader, string field, int docId)
 {
     return(SmallFloat.Byte315ToFloat(reader.Norms(field)[docId]));
 }
Exemplo n.º 4
0
 /// <summary>
 /// The default implementation encodes <code>boost / sqrt(length)</code>
 /// with <seealso cref="SmallFloat#floatToByte315(float)"/>.  this is compatible with
 /// Lucene's default implementation.  If you change this, then you should
 /// change <seealso cref="#decodeNormValue(byte)"/> to match.
 /// </summary>
 protected internal virtual sbyte EncodeNormValue(float boost, int fieldLength)
 {
     return(SmallFloat.FloatToByte315(boost / (float)Math.Sqrt(fieldLength)));
 }
Exemplo n.º 5
0
 /// <summary>Encodes a normalization factor for storage in an index.
 ///
 /// <p/>The encoding uses a three-bit mantissa, a five-bit exponent, and
 /// the zero-exponent point at 15, thus
 /// representing values from around 7x10^9 to 2x10^-9 with about one
 /// significant decimal digit of accuracy.  Zero is also represented.
 /// Negative numbers are rounded up to zero.  Values too large to represent
 /// are rounded down to the largest representable value.  Positive values too
 /// small to represent are rounded up to the smallest positive representable
 /// value.
 ///
 /// </summary>
 /// <seealso cref="AbstractField.Boost" />
 /// <seealso cref="Lucene.Net.Util.SmallFloat" />
 public static byte EncodeNorm(float f)
 {
     return((byte)SmallFloat.FloatToByte315(f));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Encodes a normalization factor for storage in an index.
 /// <p>
 /// The encoding uses a three-bit mantissa, a five-bit exponent, and the
 /// zero-exponent point at 15, thus representing values from around 7x10^9 to
 /// 2x10^-9 with about one significant decimal digit of accuracy. Zero is also
 /// represented. Negative numbers are rounded up to zero. Values too large to
 /// represent are rounded down to the largest representable value. Positive
 /// values too small to represent are rounded up to the smallest positive
 /// representable value.
 /// </summary>
 /// <seealso cref= Lucene.Net.Document.Field#setBoost(float) </seealso>
 /// <seealso cref= Lucene.Net.Util.SmallFloat </seealso>
 public override sealed long EncodeNormValue(float f)
 {
     return(SmallFloat.FloatToByte315(f));
 }