示例#1
0
 def decode_characters(self, valuestring):
     read = six.StringIO(valuestring).read
     freq = unpack("!I", read(_INT_SIZE))[0]
     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)
         posns_chars.append((position, startchar, endchar))
     return posns_chars
示例#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
示例#3
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
示例#4
0
 def decode_positions(self, valuestring):
     read = six.StringIO(valuestring).read
     freq = unpack("!I", read(_INT_SIZE))[0]
     position = 0
     positions = []
     for _ in range(freq):
         position = read_varint(read) + position
         positions.append(position)
     return positions
示例#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
示例#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
示例#7
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
示例#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
示例#9
0
    def decode_positions(self, valuestring):
        f = six.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 range(freq):
            position = read_varint(read) + position
            # Skip boost
            seek(1, 1)
            positions.append(position)
        return positions
示例#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
示例#11
0
 def read_varint(self):
     """Reads a variable-length encoded integer from the wrapped file.
     """
     return read_varint(self.file.read)
示例#12
0
 def read_varint(self):
     """Reads a variable-length encoded integer from the wrapped file.
     """
     return read_varint(self.file.read)