Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 8
0
 def decode_docboosts(self, valuestring):
     freq = unpack("!I", valuestring[:_INT_SIZE])[0]
     docboost = byte_to_float(valuestring[-1])
     return (freq, docboost)
Ejemplo n.º 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
Ejemplo n.º 10
0
 def decode_docboosts(self, valuestring):
     freq = unpack("!I", valuestring[:_INT_SIZE])[0]
     docboost = byte_to_float(valuestring[-1])
     return (freq, docboost)