赞
踩
目录
'id':文章id
'discourse_id':描述id(一篇文章会有多个描述)'discourse_start':该描述在文章的开始位置
'discourse_end',:该描述在文章的结束位置
'discourse_text':具体内容
'discourse_type':描述类型(有Name_desc,Age_desc)
Name_desc:姓名描述信息
Age_desc:年龄描述信息
'discourse_type_num':该文章包含该类描述的个数
'predictionstring':“描述”在文章的位置
文章:"i am zzz,i am 18 years old."
'id':1
'discourse_id':11(第一篇文章的第一个描述)
'discourse_start':0
'discourse_end':8
'discourse_text':'i am zmz'
'discourse_type':Name_desc
'discourse_type_num':该文章包含姓名描述信息:1个
'predictionstring':'0 2 3 5 6 7'-->'i a m z m z'
"id":文章id
"text":文章内容
- # BIO标注
- test_text = "i am zzz,i am 18 years old."
- origin_text = [i for i in test_text]
- entity = ['0']*len(test_text)
-
- test_df = pd.DataFrame(columns=['id', 'discourse_id', 'discourse_start', 'discourse_end', 'discourse_text', 'discourse_type', 'discourse_type_num', 'predictionstring'])
- test_df.loc[0] = [1,11,0,8,'i am zmz','Name_desc',1,'0 2 3 5 6 7']
- test_df.loc[1] =[1,12,9,26,'i am 24 years old','Age_desc',1,'9 11 12 14 15 17 18 19 20 21 23 24 25']
-
- # test_text[test_df.loc[0]['discourse_start']:test_df.loc[0]['discourse_end']]
-
- test_text_df = pd.DataFrame([{'id':1,'text':test_text}])
-
- for index,row in test_df[test_df['id'] == 1].iterrows():
- list_discourse = [int(x) for x in row['predictionstring'].split()]
- # print(list_discourse)
- discourse_type = row['discourse_type']
- entity[list_discourse[0]] = 'B-' + discourse_type
- for i in range(1,len(list_discourse)):
- entity[list_discourse[i]] = 'I-' + discourse_type
-
-
- for i in range(len(entity)):
- print(entity[i] + ': ' +origin_text[i])
其中:
伪代码:
test_text[test_df['discourse_start'] : test_df['discourse_end']] == test_df['discourse_text']
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。