赞
踩
上一次的知识图谱只是做了数学概念方面的,这次做的包括了整个认知领域。由于覆盖的节点数比较多,就对代码和数据形式进行了修改,以进行分类。
完整代码如下:
from py2neo import Graph, Node, Relationship, NodeMatcher import pandas as pd from pdb import set_trace def load_data(): # 加载数据 data= pd.read_excel('./entity.xlsx') cognitive = data['cognitive'].tolist() focus = data['focus'].tolist() project = data['project'].tolist() activity = data['activity'].tolist() age = data['age'].tolist() cognitive_list = [str(i) for i in cognitive] focus_list = [str(i) for i in focus] project_list = [str(i) for i in project] activity_list = [str(i) for i in activity] age_list = [str(i)for i in age] link_dict = dict() link_dict['cognitive'] = cognitive_list link_dict['focus'] = focus_list link_dict['project'] = project_list link_dict['activity'] = activity_list link_dict['age'] = age_list df_data = pd.DataFrame(link_dict) return df_data class DataToNeo4j:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。