You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
keyword = [i[0] for i in keyword]:['谢', '凯', '同', '家', '北', '南', '记', '高', '警', '告']
可以看到返回的结果是关键词的第一个字。这样得到的events是空列表。如果想要得到正常的结果的话,应该删除keyword = [i[0] for i in keyword]这一行。
请问我的理解对吗?想知道这里是不是bug,还是说有我没有想到的地方。
'''基于文章关键词,建立起实体与关键词之间的关系'''
def rel_entity_keyword( ners, keyword, subsent):
events = []
rels = []
sents = []
ners = [i.split('/')[0] for i in set(ners)]
keyword = [i[0] for i in keyword]
for sent in subsent:
tmp = []
for wd in sent:
if wd in ners + keyword:
tmp.append(wd)
if len(tmp) > 1:
sents.append(tmp)
for ner in ners:
for sent in sents:
if ner in sent:
tmp = ['->'.join([ner, wd]) for wd in sent if wd in keyword and wd != ner and len(wd) > 1]
if tmp:
rels += tmp
for e in set(rels):
events.append([e.split('->')[0], e.split('->')[1]])
return events
#将关键词与实体进行关系抽取
events_entity_keyword = rel_entity_keyword(ners, keywords, subsents_seg)
events += events_entity_keyword
The text was updated successfully, but these errors were encountered:
text_grapher.py
文件中,构建实体与关键词关系的函数返回的events_entity_keyword
是空列表[]
通过查看函数的代码,发现问题可能出在这一行:
keyword = [i[0] for i in keyword]
。['谢雕', '凯旋', '同学', '家人', '北京', '南都', '记者', '高中', '警方', '告诉']
,keyword = [i[0] for i in keyword]
:['谢', '凯', '同', '家', '北', '南', '记', '高', '警', '告']
可以看到返回的结果是关键词的第一个字。这样得到的events是空列表。如果想要得到正常的结果的话,应该删除
keyword = [i[0] for i in keyword]
这一行。请问我的理解对吗?想知道这里是不是bug,还是说有我没有想到的地方。
The text was updated successfully, but these errors were encountered: