PYTHON::知识图谱
Posted ahua的头发
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PYTHON::知识图谱相关的知识,希望对你有一定的参考价值。
仅当作记录
import py2neo from py2neo import Graph,Node,Relationship import pandas as pd graph = Graph("http://localhost:7474") graph = Graph("http://localhost:7474",uername="neo4j",password="lh990816") graph.delete_all()#清空所有内容 data = pd.read_excel("D:/data.xlsx") print(data.shape) datalable = list(data) data_row = len(data) print(data_row) # print(data.columns[1]) # b = Node(‘Person‘,name=‘yingying‘) # graph.create(b) datalable2 = len(datalable) print(datalable2) for i in range(0,data_row): print(data.loc[i][datalable[1]]) Nodee = Node(‘impentity‘,name = str(data.loc[i][datalable[1]])) graph.create(Nodee) for j in range(2,datalable2): print(data.loc[i][j]) print(data.columns[j]) # if(data.loc[i][j]==data.loc[i-1][j]): # selector = py2neo.matching.NodeMatcher(graph) # ndoe = selector.match(‘entity‘).where(‘_.name = "data.loc[i][j]"‘).first() # else: node = Node(‘entity‘,name = str(data.loc[i][j])) graph.create(node) graph.create(Relationship(Nodee,data.columns[j],node)) #print(data.head())
以上是关于PYTHON::知识图谱的主要内容,如果未能解决你的问题,请参考以下文章
电网知识图谱项目总结python代码实现RDF三元组自动化标注