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


前后端分离架构

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

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

相关推荐
xywww1683 小时前
大模型 API 选型实战:GPT、Gemini、Claude 接入时该看哪些指标?
运维·服务器·人工智能·python·gpt·langchain
私人珍藏库8 小时前
[Android] PeakFinder AR v4.8.89 (山峰全景识别+增强现实山峰查看器)
android·人工智能·智能手机·ar·工具·软件
CS创新实验室9 小时前
算法、齿轮与硅基大脑:数值计算发展简史
人工智能·算法·数值计算
能有时光9 小时前
PyTorch KernelAgent 源码解读 ---(4)--- ExtractorAgent
人工智能·pytorch·python
fthux9 小时前
GitZip Pro 源码解析:一个 GitHub 文件/文件夹下载扩展是如何工作的(一)整体架构与扩展入口
人工智能·ai·开源·github·open source
aqi0010 小时前
15天学会AI应用开发(十七)使用LangGraph实现会话记忆功能
人工智能·python·大模型·ai编程·ai应用
xixixi7777710 小时前
三大 AI 安全里程碑:Akamai 高危风险预警、智能体水印强制落地、PQC 量子安全全产业链统一
大数据·人工智能·安全·ai·大模型·智能体·政策
AI小码11 小时前
LLM 应用的缓存工程:当每次 API 调用都在燃烧成本
java·人工智能·spring·计算机·llm·编程·api
code 小楊11 小时前
AI函数调用:Function Calling从理论到实战全解析
人工智能
delishcomcn11 小时前
智切未来:AI算法如何重塑不干胶标签分切机的精度与效率边界
人工智能·神经网络·计算机视觉