1、关系抽取
1.1 专家系统
key_words = ["收购","竞拍","转让","扩张","并购","注资","整合","并入","竞购","竞买","支付","收购价","收购价格","承购","购得","购进",
"购入","买进","买入","赎买","购销","议购","函购","函售","抛售","售卖","销售","转售"]
1.2 句法依存
if 'SBV' in child_dict and 'VOB' in child_dict:
r = words[index]
e1 = complete_e(words, postags, child_dict_list, child_dict['SBV'][0])
e2 = complete_e(words, postags, child_dict_list, child_dict['VOB'][0])
svos.append([e1, r, e2])
1.3 远程监督
2、知识图谱的常见表示(Neo4j)
2.1 数据
字段 | 描述 |
---|
Person_a | 实体a(人名,如:贾宝玉) |
Person_b | 实体b(人名,如:薛宝钗) |
Relation | 实体间关系(丈夫) |
Family_a | 实体a的家族(贾家荣国府) |
Family_b | 实体b的家族(薛家) |
2.2 导入
with open("./raw_data/relation.txt") as f:
for line in f.readlines():
rela_array=line.strip("\n").split(",")
print(rela_array)
graph.run("MERGE(p: Person{cate:'%s',Name: '%s'})"%(rela_array[3],rela_array[0]))
graph.run("MERGE(p: Person{cate:'%s',Name: '%s'})" % (rela_array[4], rela_array[1]))
graph.run(
"MATCH(e: Person), (cc: Person) \
WHERE e.Name='%s' AND cc.Name='%s'\
CREATE(e)-[r:%s{relation: '%s'}]->(cc)\
RETURN r" % (rela_array[0], rela_array[1], rela_array[2], rela_array[2])
)
2.3 查询
match(p )-[r]->(n:Person{Name:'%s'}) return p.Name,r.relation,n.Name,p.cate,n.cate Union all match(p:Person {Name:'%s'}) -[r]->(n) return p.Name, r.relation, n.Name, p.cate, n.cate
2.4 效果
- 贾宝玉 的关系图谱
- 李纨 的关系图谱
- 林黛玉 的关系图谱