Exemplo n.º 1
0
 def decode_characters(self, valuestring):
     read = StringIO(valuestring).read
     freq = unpack("!I", 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
Exemplo n.º 2
0
 def decode_characters(self, valuestring):
     read = StringIO(valuestring).read
     freq = unpack("!I", 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
Exemplo n.º 3
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
Exemplo n.º 4
0
 def decode_positions(self, valuestring):
     read = StringIO(valuestring).read
     freq = unpack("!I", read(_INT_SIZE))[0]
     position = 0
     positions = []
     for _ in xrange(freq):
         position = read_varint(read) + position
         positions.append(position)
     return positions
Exemplo n.º 5
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
Exemplo n.º 6
0
 def decode_positions(self, valuestring):
     read = StringIO(valuestring).read
     freq = unpack("!I", read(_INT_SIZE))[0]
     position = 0
     positions = []
     for _ in xrange(freq):
         position = read_varint(read) + position
         positions.append(position)
     return positions
Exemplo n.º 7
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
Exemplo n.º 8
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
Exemplo n.º 9
0
    def decode_positions(self, valuestring):
        f = StringIO(valuestring)
        read, seek = f.read, f.seek

        freq = unpack("!I", 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
Exemplo n.º 10
0
 def decode_positions(self, valuestring):
     f = StringIO(valuestring)
     read, seek = f.read, f.seek
     
     freq = unpack("!I", 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
Exemplo n.º 11
0
 def read_svarint(self):
     """Reads a variable-length encoded signed integer from the wrapped file.
     """
     return decode_signed_varint(read_varint(self.file.read))
Exemplo n.º 12
0
 def read_varint(self):
     """Reads a variable-length encoded integer from the wrapped
     file.
     """
     return read_varint(self.file.read)
Exemplo n.º 13
0
 def read_svarint(self):
     """Reads a variable-length encoded signed integer from the wrapped
     file.
     """
     return decode_signed_varint(read_varint(self.file.read))
Exemplo n.º 14
0
 def read_varint(self):
     """Reads a variable-length encoded integer from the wrapped file.
     """
     return read_varint(self.file.read)