def calculate_offset(sentences, i):
    """
    Get the offset for each word in
    the ith sentence.
    """
    offsets = []
    sentence = sentences[i]
    words = sentence.split(' ')
    if i == 0:
        start_pos = 0
    else:
        start_pos = len('\n'.join(sentences[0:i])) + 1

    for j, word in enumerate(words):
        if j == 0:
            start = start_pos
        else:
            start = start_pos + len(' '.join(words[0:j])) + 1

        offsets.append([start, start + len(word)])

    return offsets, words