(lable,index_bio)
return entity
根据预测得到label标签解析出来实体，得到实体开始和结束位置
    :param lable:
    :param index_bio:
    :return:
根据预测得到label标签解析出来实体，得到实体开始和结束位置
    :param lable:
    :param index_bio:
    :return:
根据预测得到label标签解析出来实体，得到实体开始和结束位置 : param lable : : param index_bio : : return :
def get_entity(lable,index_bio):
    '''
    根据预测得到label标签解析出来实体，得到实体开始和结束位置
    :param lable:
    :param index_bio:
    :return:
    '''
    lable = [index_bio[i] for i in lable]
    entity=[]
    start = -1
    end = -1
    for i in range(len(lable)):

        if lable[i][0] == 'B':
            start = i
            end = i
            if i==len(lable)-1 and not start==-1:
                entity.append((start,end))
                start = -1
            elif i != len(lable)-1 and lable[i+1][0] == 'O' and not start==-1:
                entity.append((start, end))
                start = -1
            elif i != len(lable)-1 and lable[i+1][0] == 'B' and not start==-1:
                entity.append((start, end))
                start = -1
        elif lable[i][0] == 'I':
            end = i
            if i==len(lable)-1 and not start==-1:
                entity.append((start,end))
                start = -1
            elif i != len(lable)-1 and lable[i+1][0] == 'O' and not start==-1:
                entity.append((start, end))
                start = -1
            elif i != len(lable)-1 and lable[i+1][0] == 'B' and not start==-1:
                entity.append((start, end))
                start = -1
    return entity
def get_entity ( lable , index_bio ) : lable = [ index_bio [ i ] for i in lable ] entity = [ ] start = - 1 end = - 1 for i in range ( len ( lable ) ) : if lable [ i ] [ 0 ] == 'B' : start = i end = i if i == len ( lable ) - 1 and not start == - 1 : entity . append ( ( start , end ) ) start = - 1 elif i != len ( lable ) - 1 and lable [ i + 1 ] [ 0 ] == 'O' and not start == - 1 : entity . append ( ( start , end ) ) start = - 1 elif i != len ( lable ) - 1 and lable [ i + 1 ] [ 0 ] == 'B' and not start == - 1 : entity . append ( ( start , end ) ) start = - 1 elif lable [ i ] [ 0 ] == 'I' : end = i if i == len ( lable ) - 1 and not start == - 1 : entity . append ( ( start , end ) ) start = - 1 elif i != len ( lable ) - 1 and lable [ i + 1 ] [ 0 ] == 'O' and not start == - 1 : entity . append ( ( start , end ) ) start = - 1 elif i != len ( lable ) - 1 and lable [ i + 1 ] [ 0 ] == 'B' and not start == - 1 : entity . append ( ( start , end ) ) start = - 1 return entity