def partition_text(sent, max_length):
    """
    partitions a tokenized sent in chunks of max possible
    length that is less than `max_length`. `max_length` can
    be altered by a coroutine using generator.send()
    """
    acc, comax_length = '', None
    sent.reverse()
    while sent:
        next_word = sent.pop()
        if len(acc) + len(next_word) < (comax_length or max_length):
            acc += next_word + ' '
        else:
            comax_length = yield acc.strip()
            acc = next_word + ' '
    else:
        yield acc.strip()
