annotations2csv.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:iaetdroit 作者: pommedeterresautee 项目源码 文件源码
def get_interval_offsets_txt(lines: List[str]) -> Iterator[Tuple[int, int]]:
    """Return all the intervals corresponding to the ``lines``
    passed as parameter:
    [(0, n), (n, m), …]
    where the values are the character position of the beginning and end of
    each line, counting from the first character of the file (start at 0)"""

    idx_first_char = 0
    cumulative_lines_length = list(itertools.accumulate(list(map(len, lines))))

    return zip([idx_first_char] + cumulative_lines_length,
               cumulative_lines_length)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号