Example #1
0
 def read_8bitfloat(self, mantissabits=5, zeroexp=2):
     """Reads a byte-sized representation of a floating point value.
     
     :param mantissabits: the number of bits to use for the mantissa
         (with the rest used for the exponent).
     :param zeroexp: the zero point for the exponent.
     """
     return byte_to_float(self.read_byte(), mantissabits, zeroexp)
Example #2
0
 def read_8bitfloat(self, mantissabits=5, zeroexp=2):
     """Reads a byte-sized representation of a floating point value.
     
     :param mantissabits: the number of bits to use for the mantissa
         (with the rest used for the exponent).
     :param zeroexp: the zero point for the exponent.
     """
     return byte_to_float(self.read_byte(), mantissabits, zeroexp)
Example #3
0
    def decode_position_boosts(self, valuestring):
        f = six.StringIO(valuestring)
        read = f.read
        freq = unpack("!I", read(_INT_SIZE))[0]

        # Skip summed boost
        f.seek(_FLOAT_SIZE, 1)

        position = 0
        posns_boosts = []
        for _ in range(freq):
            position = read_varint(read) + position
            boost = byte_to_float(read(1))
            posns_boosts.append((position, boost))
        return posns_boosts
Example #4
0
 def decode_position_boosts(self, valuestring):
     f = StringIO(valuestring)
     read = f.read
     freq = unpack("!I", read(_INT_SIZE))[0]
     
     # Skip summed boost
     f.seek(_FLOAT_SIZE, 1)
     
     position = 0
     posns_boosts = []
     for _ in xrange(freq):
         position = read_varint(read) + position
         boost = byte_to_float(read(1))
         posns_boosts.append((position, boost))
     return posns_boosts
Example #5
0
    def decode_character_boosts(self, valuestring):
        f = six.StringIO(valuestring)
        read = f.read

        freq = unpack("!I", read(_INT_SIZE))[0]
        # Skip summed boost
        f.seek(_FLOAT_SIZE, 1)

        position = 0
        endchar = 0
        posns_chars = []
        for _ in range(freq):
            position = read_varint(read) + position
            startchar = endchar + read_varint(read)
            endchar = startchar + read_varint(read)
            boost = byte_to_float(read(1))
            posns_chars.append((position, startchar, endchar, boost))
        return posns_chars
Example #6
0
 def decode_character_boosts(self, valuestring):
     f = StringIO(valuestring)
     read = f.read
     
     freq = unpack("!I", read(_INT_SIZE))[0]
     # Skip summed boost
     f.seek(_FLOAT_SIZE, 1)
     
     position = 0
     endchar = 0
     posns_chars = []
     for _ in xrange(freq):
         position = read_varint(read) + position
         startchar = endchar + read_varint(read)
         endchar = startchar + read_varint(read)
         boost = byte_to_float(read(1))
         posns_chars.append((position, startchar, endchar, boost))
     return posns_chars
Example #7
0
 def decode_weight(self, valuestring):
     freq = unpack("!I", valuestring[:_INT_SIZE])[0]
     docboost = byte_to_float(valuestring[-1])
     return freq * docboost * self.field_boost
Example #8
0
 def decode_docboosts(self, valuestring):
     freq = unpack("!I", valuestring[:_INT_SIZE])[0]
     docboost = byte_to_float(valuestring[-1])
     return (freq, docboost)
Example #9
0
 def decode_weight(self, valuestring):
     freq = unpack("!I", valuestring[:_INT_SIZE])[0]
     docboost = byte_to_float(valuestring[-1])
     return freq * docboost * self.field_boost
Example #10
0
 def decode_docboosts(self, valuestring):
     freq = unpack("!I", valuestring[:_INT_SIZE])[0]
     docboost = byte_to_float(valuestring[-1])
     return (freq, docboost)