当前位置:网站首页>知识图谱学习笔记——我的第一次知识图谱实践
知识图谱学习笔记——我的第一次知识图谱实践
2022-08-09 00:55:00 【晓山清】
数据集来自OpenKG.CN
代码
from py2neo import *
import pandas as pd
#connect
#g=Graph(host='127.0.0.1',http_port=7474,user='neo4j',password='lan')
g=Graph('http://localhost:7474/',auth=('neo4j',"lan"))
filename="E:\\1\\数据集\\东周列国知识图谱\\kg.xlsx"
try_data=pd.read_excel(filename)
character1=try_data.iloc[1:,0]
character1[0]="齐桓公"
character2=try_data.iloc[1:,1]
character2[0]="齐襄公"
relation=try_data.iloc[1:,2]
relation[0]="关系"
for i in range(len(relation)):
#build note
cha1=Node('person',name=str(character1[i]))
cha2=Node('person',name=str(character2[i]))
# g.create(cha1)
# g.create(cha2)
#build relation
re=Relationship(cha1,str(relation[i]),cha2)
# g.create(re)
g.merge(cha1,'person','name')
g.merge(cha2,'person','name')
g.merge(re,'person','name')
效果图展示
边栏推荐
猜你喜欢
Discourse 的关闭主题(Close Topic )和重新开放主题
在vscode中编辑、编译、下载Keil工程
C语言-大端存储和小端存储
神经网络基本原理
容器运维平台的故障处理-1
年初离职,学习半年源码,终于拿到了蚂蚁 Offer,分享面试过程
PostMan导入证书 添加证书
A double non-programmer interviewed Ant, Meituan, Ctrip and other big companies with offers to share the interview process
笔记&代码 | 统计学——基于R(第四版) 第十一章 时间序列预测
4-5 Matplotlib库 散点图
随机推荐
插值拟合——数据处理或预测
卷积神经网络EfficentNet v1学习记录--Model Scaling
图像超分辨率重建概述
模型冻结对应层参数freeze
【C语言刷题】链表中快慢指针的应用
Unity3D小白学习日记(01):如何把物体移动到鼠标点击处
requestAnimationFrame实现浏览器动画
XShell用命令行打包jar包(详细步骤)
有相同字符串的查找
微信企业号开发之开启回调模式
Sencha Touch延迟加载模块提高程序启动时性能
【科研-学习-pytorch】6-数值计算
如何仿造一个websocket请求?
LeetCode精选200道--字符串篇
在特征通道提升网络性能 --SENet网络详解
阿里云服务器买完不知道如何使用(新手入门教程)
10月自学考试结束后总结
统一身份管理平台IAM单点登录流程及第三方接口设计方案
在Ubuntu/Linux环境下使用MySQL:修改数据库sql_mode,可解决“this is incompatible with sql_mode=only_full_group_by”问题
docker搭建redis主从复制,容器无法启动?