Ejemplo n.º 1
0
 def valuedecoder(self, v):
     if len(v) == _INT_SIZE:
         return (1.0, unpack_uint(v)[0], 1)
     elif len(v) == _terminfo_struct0.size:
         return _terminfo_struct0.unpack(v)
     elif len(v) == _terminfo_struct1.size:
         return _terminfo_struct1.unpack(v)
     else:
         return _terminfo_struct2.unpack(v)
Ejemplo n.º 2
0
 def decode_positions(self, valuestring):
     read = StringIO(valuestring).read
     freq = unpack_uint(read(_INT_SIZE))[0]
     position = 0
     positions = []
     for _ in xrange(freq):
         position = read_varint(read) + position
         positions.append(position)
     return positions
Ejemplo n.º 3
0
 def decode_positions(self, valuestring):
     read = StringIO(valuestring).read
     freq = unpack_uint(read(_INT_SIZE))[0]
     position = 0
     positions = []
     for _ in xrange(freq):
         position = read_varint(read) + position
         positions.append(position)
     return positions
Ejemplo n.º 4
0
 def decode_characters(self, valuestring):
     read = StringIO(valuestring).read
     freq = unpack_uint(read(_INT_SIZE))[0]
     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)
         posns_chars.append((position, startchar, endchar))
     return posns_chars
Ejemplo n.º 5
0
 def decode_characters(self, valuestring):
     read = StringIO(valuestring).read
     freq = unpack_uint(read(_INT_SIZE))[0]
     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)
         posns_chars.append((position, startchar, endchar))
     return posns_chars
Ejemplo n.º 6
0
    def decode_position_boosts(self, valuestring):
        f = StringIO(valuestring)
        read = f.read
        freq = unpack_uint(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.º 7
0
 def decode_position_boosts(self, valuestring):
     f = StringIO(valuestring)
     read = f.read
     freq = unpack_uint(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.º 8
0
 def decode_positions(self, valuestring):
     f = StringIO(valuestring)
     read, seek = f.read, f.seek
     
     freq = unpack_uint(read(_INT_SIZE))[0]
     # Skip summed boost
     seek(_FLOAT_SIZE, 1)
     
     position = 0
     positions = []
     for _ in xrange(freq):
         position = read_varint(read) + position
         # Skip boost
         seek(1, 1)
         positions.append(position)
     return positions
Ejemplo n.º 9
0
    def decode_positions(self, valuestring):
        f = StringIO(valuestring)
        read, seek = f.read, f.seek

        freq = unpack_uint(read(_INT_SIZE))[0]
        # Skip summed boost
        seek(_FLOAT_SIZE, 1)

        position = 0
        positions = []
        for _ in xrange(freq):
            position = read_varint(read) + position
            # Skip boost
            seek(1, 1)
            positions.append(position)
        return positions
Ejemplo n.º 10
0
    def decode_character_boosts(self, valuestring):
        f = StringIO(valuestring)
        read = f.read

        freq = unpack_uint(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.º 11
0
 def decode_character_boosts(self, valuestring):
     f = StringIO(valuestring)
     read = f.read
     
     freq = unpack_uint(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.º 12
0
 def decode_docboosts(self, valuestring):
     freq = unpack_uint(valuestring[:_INT_SIZE])[0]
     docboost = byte_to_float(valuestring[-1])
     return (freq, docboost)
Ejemplo n.º 13
0
 def get_uint(self, position):
     return unpack_uint(self.map[position:position + _INT_SIZE])[0]
Ejemplo n.º 14
0
 def read_uint(self):
     return unpack_uint(self.file.read(_INT_SIZE))[0]
Ejemplo n.º 15
0
 def read_uint(self):
     return unpack_uint(self.file.read(_INT_SIZE))[0]
Ejemplo n.º 16
0
 def decode_frequency(self, valuestring):
     return unpack_uint(valuestring)[0]
Ejemplo n.º 17
0
 def decode_weight(self, valuestring):
     freq = unpack_uint(valuestring[:_INT_SIZE])[0]
     docboost = byte_to_float(valuestring[-1])
     return freq * docboost * self.field_boost
Ejemplo n.º 18
0
 def get_uint(self, position):
     return unpack_uint(self.get(position, _INT_SIZE))[0]
Ejemplo n.º 19
0
 def decode_frequency(self, valuestring):
     return unpack_uint(valuestring[:_INT_SIZE])[0]
Ejemplo n.º 20
0
 def decode_weight(self, valuestring):
     freq = unpack_uint(valuestring)[0]
     return freq * self.field_boost
Ejemplo n.º 21
0
 def decode_weight(self, valuestring):
     freq = unpack_uint(valuestring)[0]
     return freq * self.field_boost
Ejemplo n.º 22
0
 def decode_frequency(self, valuestring):
     return unpack_uint(valuestring)[0]
Ejemplo n.º 23
0
 def decode_docboosts(self, valuestring):
     freq = unpack_uint(valuestring[:_INT_SIZE])[0]
     docboost = byte_to_float(valuestring[-1])
     return (freq, docboost)
Ejemplo n.º 24
0
 def decode_frequency(self, valuestring):
     return unpack_uint(valuestring[:_INT_SIZE])[0]
Ejemplo n.º 25
0
 def decode_weight(self, valuestring):
     freq = unpack_uint(valuestring[:_INT_SIZE])[0]
     docboost = byte_to_float(valuestring[-1])
     return freq * docboost * self.field_boost
Ejemplo n.º 26
0
 def get_uint(self, position):
     return unpack_uint(self.map[position:position + _INT_SIZE])[0]
Ejemplo n.º 27
0
 def get_uint(self, position):
     return unpack_uint(self.get(position, _INT_SIZE))[0]