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
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
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
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
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
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
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
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
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
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
def read_varint(self): """Reads a variable-length encoded integer from the wrapped file. """ return read_varint(self.file.read)