def get_docidx_from_offset(doc_start_char, doc_end_char, offset2docidx):
    """
        This function gets the starting and ending document-level word indices for an entity given the entity's document-level offset. 
    """
    begin_idx = None
    end_idx = None # exclusive
    for offset in offset2docidx:
        if offset[0] <= doc_start_char < offset[1]:
            begin_idx = offset2docidx[offset]
        if  offset[0] < doc_end_char <= offset[1]:
            end_idx = offset2docidx[offset]
    return (begin_idx, end_idx)