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


前后端分离架构

  • 前端: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

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

相关推荐
key_3_feng3 分钟前
鸿蒙NEXT原生AI智能家庭助手开发方案
人工智能·华为·harmonyos
MRDONG13 分钟前
深入理解 RAG(Retrieval-Augmented Generation):原理、工程体系与实践指南
人工智能·算法·语言模型·自然语言处理
bryant_meng4 分钟前
【Reading Notes】(8.9)Favorite Articles from 2025 September
人工智能·深度学习·llm·资讯
互联网科技看点6 分钟前
诸葛智能入选IDC最新报告:以营销智能体驱动金融增长
大数据·人工智能·金融
东离与糖宝8 分钟前
静态语言与动态语言基础:核心区别对比
人工智能
551只玄猫9 分钟前
【模块1 建立认知1】为什么金融数据不能用“普通机器学习”?
人工智能·机器学习·数学建模·金融·数据科学·金融建模
数智工坊9 分钟前
深度拆解 AnomalyCLIP:用 CLIP 做零样本异常检测,不看目标数据也能精准定位缺陷
人工智能
xcbrand10 分钟前
工业制造品牌全案公司找哪家
大数据·人工智能·python·制造
k笔墨丹青11 分钟前
三维重建(点云)
人工智能·机器学习·3d
别或许11 分钟前
线代中为什么左乘一个列满秩矩阵,不改变矩阵的秩?
人工智能·算法·矩阵