Skip to content

Commit 64176a6

Browse files
committed
update data and readme
1 parent 027edf0 commit 64176a6

20 files changed

+529
-19
lines changed

README.md

+48-19
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,56 @@
1-
# Spring-Boot-Neo4j-Movies
2-
Spring-Boot集成Neo4j并利用Spark的朴素贝叶斯分类器实现基于电影知识图谱的智能问答系统
3-
博客地址:https://blog.csdn.net/appleyk
1+
# Spring-Boot-KBQA
42

3+
以Spring Boot框架为载体,通过集成hanLP、neo4j、spark-mllib实现基于电影知识图谱的简易问答系统。
54

6-
升级Spark依赖,由原来的2.3升级到2.4,GitHub官方提醒> = 1.0.0,<= 2.3.2之间的版本容易受到攻击
7-
spark2.4 == >scala2.11 and scala2.12
5+
首先启动springboot后在浏览器中访问8080端口,接着在网页上输入关于电影的一些问题,前端页面通过AJAX请求将问题发送到后端接口,后端接收到请求后,先加载问题模板、字典、分类模型及自定义字典;再对问题分词后利用分类模型将原问题匹配到对应的问题模板上;最后针对不同种类的问题从图数据库neo4j中查询对应的答案并返回。
86

7+
# 数据
8+
- mysql (/data/movie_data_import.sql)
9+
- neo4j (先将mysql的数据导出csv文件,再导入到neo4j中,有利于比较两种数据库的关系,图数据库更适合对关系的处理。也可直接将/data/import.rar压缩包内的文件直接导入到neo4j中)
10+
```
911
10-
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core -->
11-
<dependency>
12-
<groupId>org.apache.spark</groupId>
13-
<artifactId>spark-core_2.12</artifactId>
14-
<version>2.4.0</version>
15-
</dependency>
16-
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-mllib -->
17-
<dependency>
18-
<groupId>org.apache.spark</groupId>
19-
<artifactId>spark-mllib_2.12</artifactId>
20-
<version>2.4.0</version>
21-
<scope>runtime</scope>
22-
</dependency>
12+
找到neo4j的安装路径,并在D:\neo4j-community-3.4.0\目录下创建import目录
13+
完整路径如下D:\neo4j-community-3.4.0\import
14+
因为neo4j支持导入csv文件,其默认目录入口是 ...\import
2315
2416
17+
//导入节点 电影类型 == 注意类型转换
18+
LOAD CSV WITH HEADERS FROM "file:///genre.csv" AS line
19+
MERGE (p:Genre{gid:toInteger(line.gid),name:line.gname})
2520
2621
27-
如果down下来的demo在本地无法运行,请自行降低版本,保证本地spark环境的版本号和pom中的spark依赖的jar包版本一致!
22+
//导入节点 演员信息
23+
LOAD CSV WITH HEADERS FROM 'file:///person.csv' AS line
24+
MERGE (p:Person { pid:toInteger(line.pid),birth:line.birth,
25+
death:line.death,name:line.name,
26+
biography:line.biography,
27+
birthplace:line.birthplace})
28+
29+
30+
// 导入节点 电影信息
31+
LOAD CSV WITH HEADERS FROM "file:///movie.csv" AS line
32+
MERGE (p:Movie{mid:toInteger(line.mid),title:line.title,introduction:line.introduction,
33+
rating:toFloat(line.rating),releasedate:line.releasedate})
34+
35+
36+
// 导入关系 actedin 电影是谁参演的 1对多
37+
LOAD CSV WITH HEADERS FROM "file:///person_to_movie.csv" AS line
38+
match (from:Person{pid:toInteger(line.pid)}),(to:Movie{mid:toInteger(line.mid)})
39+
merge (from)-[r:actedin{pid:toInteger(line.pid),mid:toInteger(line.mid)}]->(to)
40+
41+
//导入关系 电影是什么类型 == 1对多
42+
LOAD CSV WITH HEADERS FROM "file:///movie_to_genre.csv" AS line
43+
match (from:Movie{mid:toInteger(line.mid)}),(to:Genre{gid:toInteger(line.gid)})
44+
merge (from)-[r:is{mid:toInteger(line.mid),gid:toInteger(line.gid)}]->(to)
45+
```
46+
- 问题模板 (/data/question)
47+
- hanLP的数据 (https://github.com/hankcs/HanLP/releases 中的新数据包data-for-1.7.4.zip)
48+
- 自定义词典 (/data/自定义词典.zip解压后放到hanLP的相关目录下,具体路径参考/src/main/resources/application.properties)
49+
50+
51+
# windows下spark环境
52+
53+
- [https://pan.baidu.com/s/1ZIsh5yRChR0zAJXnUui4jw](https://pan.baidu.com/s/1ZIsh5yRChR0zAJXnUui4jw)
54+
55+
# 参考
56+
- [基于电影知识图谱的智能问答系统(八) -- 终极完结篇](https://blog.csdn.net/appleyk/article/details/80422055)

data/import.rar

663 KB
Binary file not shown.

data/movie_data_import.sql

+170
Large diffs are not rendered by default.
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
0:nm 评分
2+
1:nm 上映时间
3+
2:nm 类型
4+
3:nm 简介
5+
4:nm 演员列表
6+
5:nnt 介绍
7+
6:nnt ng 电影作品
8+
7:nnt 电影作品
9+
8:nnt 参演评分 大于 x
10+
9:nnt 参演评分 小于 x
11+
10:nnt 电影类型
12+
11:nnt nnr 合作 电影列表
13+
12:nnt 电影数量
14+
13:nnt 出生日期

data/question/vocabulary.txt

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
0:一
2+
1:地区
3+
2:谁
4+
3:口碑
5+
4:分
6+
5:哪家
7+
6:公司
8+
7:将
9+
8:上
10+
9:关键人物
11+
10:下
12+
11:准备
13+
12:推动
14+
13:喜欢
15+
14:出品
16+
15:故事梗概
17+
16:与
18+
17:怎么样
19+
18:演
20+
19:片长
21+
20:吗
22+
21:相同
23+
22:多
24+
23:拍摄
25+
24:影院
26+
25:拿到
27+
26:编剧
28+
27:分数
29+
28:扮演者
30+
29:还有
31+
30:好看
32+
31:在
33+
32:哪里
34+
33:来自
35+
34:正在
36+
35:个
37+
36:背景
38+
37:成就
39+
38:中
40+
39:类似
41+
40:是
42+
41:由
43+
42:当中
44+
43:剧情
45+
44:列表
46+
45:多少
47+
46:风格
48+
47:这部
49+
48:放
50+
49:分析
51+
50:简介
52+
51:时长
53+
52:重要
54+
53:片
55+
54:格调
56+
55:相似
57+
56:之中
58+
57:豆瓣
59+
58:线索
60+
59:收获
61+
60:类似于
62+
61:情节
63+
62:网
64+
63:打
65+
64:国家
66+
65:全篇
67+
66:奖
68+
67:国人
69+
68:首映
70+
69:做
71+
70:公司出品
72+
71:上映
73+
72:多久
74+
73:这个
75+
74:出镜率
76+
75:赢得
77+
76:步
78+
77:介绍
79+
78:扮演
80+
79:核心人物
81+
80:受欢迎程度
82+
81:代表作品
83+
82:获奖
84+
83:差不多
85+
84:相关
86+
85:影响
87+
86:未来
88+
87:执导
89+
88:类型
90+
89:影评
91+
90:计划
92+
91:要
93+
92:出版
94+
93:观众
95+
94:了
96+
95:哪个
97+
96:看到
98+
97:出生于
99+
98:制片公司
100+
99:和
101+
100:中演
102+
101:演员表
103+
102:发行
104+
103:导演
105+
104:接受度
106+
105:热门
107+
106:得
108+
107:写
109+
108:情况
110+
109:多长时间
111+
110:什么样
112+
111:评价
113+
112:身份
114+
113:较高
115+
114:度
116+
115:生日
117+
116:题材
118+
117:主要
119+
118:多长
120+
119:放映
121+
120:发展
122+
121:走向
123+
122:时间
124+
123:讲
125+
124:筹划
126+
125:饰演
127+
126:人
128+
127:评
129+
128:首播
130+
129:过去
131+
130:梗概
132+
131:过
133+
132:演员
134+
133:拍
135+
134:经典作品
136+
135:获得
137+
136:电影
138+
137:评分
139+
138:成绩
140+
139:网上
141+
140:票房
142+
141:高
143+
142:角色介绍
144+
143:还
145+
144:给
146+
145:个人
147+
146:哪一天
148+
147:制片
149+
148:可以
150+
149:内容
151+
150:出品公司
152+
151:名字
153+
152:剧情简介
154+
153:人物
155+
154:片子
156+
155:部
157+
156:奖项
158+
157:故事
159+
158:哪
160+
159:叫
161+
160:作品
162+
161:制作
163+
162:时候
164+
163:怎么
165+
164:角色
166+
165:程度
167+
166:版权
168+
167:出生日期
169+
168:那天
170+
169:对
171+
170:即将
172+
171:出
173+
172:属于
174+
173:上线
175+
174:中的
176+
175:拿
177+
176:大于
178+
177:出生
179+
178:喜剧
180+
179:ng
181+
180:出演
182+
181:以上
183+
182:以下
184+
183:小于
185+
184:种类
186+
185:合作
187+
186:一起
188+
187:合拍
189+
188:nnr
190+
189:信息

data/question/【0】评分.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
nm的评分是多少
2+
nm得了多少分
3+
nm的评分有多少
4+
nm的评分
5+
nm的分数是
6+
nm电影分数是多少
7+
nm评分
8+
nm的分数是多少
9+
nm这部电影的评分是多少
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
nnt演过哪些风格的电影
2+
nnt演过的电影都有哪些风格
3+
nnt演过的电影有哪些类型
4+
nnt演过风格的电影
5+
nnt演过类型的电影
6+
nnt演过题材的电影
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
nnt和nnr合作的电影有哪些
2+
nnt和nnr一起拍了哪些电影
3+
nnt和nnr一起演过哪些电影
4+
nnt与nnr合拍了哪些电影
5+
nnt和nnr合作了哪些电影
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
nnt一共参演过多少电影
2+
nnt演过多少部电影
3+
nnt演过多少电影
4+
nnt参演的电影有多少
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
nnt的出生日期
2+
nnt的生日
3+
nnt生日多少
4+
nnt的出生是什么时候
5+
nnt的出生是多少
6+
nnt生日是什么时候
7+
nnt生日什么时候
8+
nnt出生日期是什么时候
9+
nnt什么时候出生的
10+
nnt出生于哪一天
11+
nnt的出生日期是哪一天
12+
nnt哪一天出生的

data/question/【1】上映.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
nm的上映时间是什么时候
2+
nm的首映时间是什么时候
3+
nm什么时候上映
4+
nm什么时候首映
5+
nm什么时候在影院上线
6+
什么时候可以在影院看到nm
7+
nm什么时候在影院放映
8+
nm什么时候首播

data/question/【2】风格.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
nm的风格是什么
2+
nm是什么风格的电影
3+
nm的格调是什么
4+
nm是什么格调的电影
5+
nm是什么类型的电影
6+
nm的类型是什么
7+
nm是什么类型的

data/question/【3】剧情.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
nm的剧情是什么
2+
nm主要讲什么内容
3+
nm的主要剧情是什么
4+
nm主要讲什么故事
5+
nm的故事线索是什么
6+
nm讲了什么
7+
nm的剧情简介
8+
nm的故事内容
9+
nm的主要情节
10+
nm的情节梗概
11+
nm的故事梗概
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
nm有哪些演员出演
2+
nm是由哪些人演的
3+
nm中参演的演员都有哪些
4+
nm中哪些人演过
5+
nm这部电影的演员都有哪些
6+
nm这部电影中哪些人演过

data/question/【5】演员简介.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
nnt
2+
nnt
3+
nnt
4+
nnt
5+
nnt
6+
nnt是
7+
nnt是谁
8+
nnt的介绍
9+
nnt的简介
10+
谁是nnt
11+
nnt的详细信息
12+
nnt的信息
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
nnt演过哪些ng电影
2+
nnt演哪些ng电影
3+
nnt演过ng电影
4+
nnt演过什么ng电影
5+
nnt演过ng电影
6+
nnt演过的ng电影有哪些
7+
nnt出演的ng电影有哪些

0 commit comments

Comments
 (0)