知识图谱可视化系统源码分享


前后端分离架构

  • 前端:vue3 + antd-design-vue
  • 后端:python

系统功能

  • 登录
  • 注册
  • 知识图谱可视化
  • 智能问答
  • 图谱数据维护
  • 用户管理

可定制开发其它功能

代码设计规范,好修改,数据可轻松替换,便于复用

python 复制代码
if __name__ == '__main__':
    # 清空数据库中的所有数据
    graph.delete_all()
    files = loop_files('result', 'json')
    if files:
        data_list = []
        for file in files:
            file_name = os.path.basename(file)
            with open(file, 'r', encoding='utf-8') as file:
                content = file.read()
            content_list = []
            try:
                content_list = json.loads(content)
            except Exception as e:
                print(f"文件解析失败:{file}", e)
            if content_list:
                data_list.extend(content_list)
        # 保存数据到neo4j
        save_to_neo(data_list)
python 复制代码
    def get_kg_new(self, entity):
        conditions = []
        if entity:
            conditions.append(f"n.name =~ '.*{entity}.*'")
        where_clause = " AND ".join(conditions)
        where_clause = f"WHERE {where_clause}" if where_clause else ""
        sql = f"""
                   MATCH p=(n)-[r]-(m)
                   {where_clause}
                   RETURN nodes(p) AS nodes, relationships(p) AS rels limit 100
                   """
        print("查询节点:" + sql)
        result = self.graph.run(sql).data()
        nodes = []
        lines = []
        id_list = []

        if result:
            for record in result:
                for node in record['nodes']:
                    node_id = node.identity
                    if node_id not in id_list:
                        node_data = {
                            'id': node_id,
                            'name': node['name'],
                            'type': list(node.labels)[0] if node.labels else ''
                        }
                        for prop in node:
                            node_data[prop] = node[prop]
                        id_list.append(node_id)
                        nodes.append(node_data)

                for rel in record['rels']:
                    lines.append({
                        'from': rel.start_node.identity,
                        'to': rel.end_node.identity,
                        'text': type(rel).__name__
                    })

        json_data = {'nodes': nodes, 'lines': lines}
        return json_data

完整源码可获取,可远程部署答疑

相关推荐
志栋智能2 小时前
告别高昂投入:超自动化IT运维的轻量化实践
大数据·运维·网络·人工智能·自动化
腾视科技TENSORTEC2 小时前
腾视科技TS-SG-SM7系列AI算力模组:32TOPS算力引擎,开启边缘智能新纪元
大数据·人工智能·科技·ai·ai算力模组·ai模组·ainas
红色石头本尊2 小时前
3-输出解析器outputParsers
人工智能
Theodore_10222 小时前
深度学习(12)正则化线性回归中的偏差与方差调试
人工智能·深度学习·算法·机器学习·线性回归
半自定义大剑仙2 小时前
RUL寿命预测从零讲起
人工智能
梦想的旅途22 小时前
企微智能知识库:AI赋能私域流量
人工智能·自动化·企业微信
JavaPub-rodert2 小时前
Codex是什么?和ChatGPT有什么区别
人工智能·chatgpt·codex
链巨人2 小时前
理解L-平滑 (L-smoothness)和\mu-强凸 (\mu-strong convexity)并以此假设来证明梯度下降方法的收敛性
人工智能·机器学习
薛定猫AI2 小时前
【技术干货】Open Claw 最新重大更新:插件生态、上下文控制与自托管 AI 助手的工程实践
人工智能