Author image Marvin Humphrey
and 1 contributors

Provide a normalization factor for a field based on the square-root of the number of terms in it.

Return a score factor based on the frequency of a term in a given document. The default implementation is sqrt(freq). Other implementations typically produce ascending scores with ascending freqs, since the more times a doc matches, the more relevant it is likely to be.

_float_to_byte and _byte_to_float encode and decode between 32-bit IEEE floating point numbers and a 5-bit exponent, 3-bit mantissa float. The range covered by the single-byte encoding is 7x10^9 to 2x10^-9. The accuracy is about one significant decimal digit.

The norm_decoder caches the 256 possible byte => float pairs, obviating the need to call decode_norm over and over for a scoring implementation that knows how to use it.