

前后端分离架构
- 前端: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
完整源码可获取,可远程部署答疑