@staticmethod
def compute_text_offsets(doc, texts):
    """Computes all offsets and inserts text into document"""
    text2offsets = {}
    for textname, text in texts.items():
        offsets = []
        pos = 0
        for subseq in text:
            offsets.append(pos)
            pos += len(subseq)
        offsets.append(pos)
        fulltext = ''.join(text)
        doc.add_text(textname, fulltext)
        text2offsets[textname] = dict(zip(range(len(offsets)), offsets))
    return text2offsets
