pytorch_uie_ner
pytorch_uie_ner copied to clipboard
map_offset问题
源码utils.py中的map_offset()在处理index为0的实体时,会导致实体解析出现错误,源码如下: def map_offset(ori_offset, offset_mapping): """ map ori offset to token offset """ for index, span in enumerate(offset_mapping): if span[0] <= ori_offset < span[1]: return index return -1
建议进行修改,下面是我的修改方法: def map_offset(ori_offset, offset_mapping): """ map ori offset to token offset """ for index, span in enumerate(offset_mapping): if index < 2: continue if span[0] <= ori_offset < span[1]: return index return -1
源码utils.py中的map_offset()在处理index为0的实体时,会导致实体解析出现错误,源码如下: def map_offset(ori_offset, offset_mapping): """ map ori offset to token offset """ for index, span in enumerate(offset_mapping): if span[0] <= ori_offset < span[1]: return index return -1
建议进行修改,下面是我的修改方法: def map_offset(ori_offset, offset_mapping): """ map ori offset to token offset """ for index, span in enumerate(offset_mapping): if index < 2: continue if span[0] <= ori_offset < span[1]: return index return -1
感谢建议。