代码拉取完成,页面将自动刷新
import json
def get_option(ents,triples):
nodes = set()
for ent in ents:
nodes.add(ent)
triple_dict = {}
for triple in triples:
ht = triple[0],triple[2]
if ht not in triple_dict:
triple_dict[ht] = []
triple_dict[ht].append(triple[1])
nodes.add(triple[0])
nodes.add(triple[2])
with open('option.json','r',encoding='utf-8') as f:
option = json.load(f)
for node in nodes:
option['series'][0]['data'].append({'name':node})
for (head,tail) in triple_dict:
if head > tail:
curveness = 0.2
else:
curveness = -0.2
if '反向' in triple_dict[(head,tail)] or \
'实体-病历共现' in triple_dict[(head,tail)] or \
'疾病->逻辑症状' in triple_dict[(head,tail)] or \
'其他节点->病历' in triple_dict[(head,tail)]:
continue
option['series'][0]['links'].append(
{
"source": head,
"target": tail,
"symbolSize": [
5,
20
],
"label": {
# "show": True,
"formatter": '/'.join(triple_dict[(head,tail)])
},
"lineStyle": {
"width": 5,
"curveness": curveness
}
}
)
return option
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。