├── ._.DS_Store
├── .idea
├── $CACHE_FILE$
├── .gitignore
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── compiler.xml
├── dictionaries
├── jarRepositories.xml
├── knowlodeg_graph.iml
├── kotlinc.xml
├── misc.xml
├── uiDesigner.xml
└── vcs.xml
├── README.md
├── image
├── flowchart.png
├── movie_graph.png
└── reponse_result.png
├── movie_kg.iml
├── pom.xml
├── src
└── main
│ ├── java
│ └── com
│ │ └── sy
│ │ ├── base
│ │ └── abs
│ │ │ ├── AbstractCSVRead.java
│ │ │ ├── AbstractNode.java
│ │ │ └── AbstractRelation.java
│ │ ├── mainclass
│ │ ├── GraphApocBuild.java
│ │ ├── GraphCypherBuild.java
│ │ ├── MovieQA.java
│ │ ├── MovieRec.java
│ │ └── MovieSearch.java
│ │ ├── manipulation
│ │ ├── apoc
│ │ │ ├── CreateNode.java
│ │ │ ├── CreateRelation.java
│ │ │ └── readme.txt
│ │ ├── basic_operation
│ │ │ ├── GraphCount.java
│ │ │ └── GraphDelete.java
│ │ └── cypher
│ │ │ ├── CreateNode.java
│ │ │ ├── CreateRelation.java
│ │ │ ├── node
│ │ │ ├── Country.java
│ │ │ ├── Movie.java
│ │ │ └── Person.java
│ │ │ ├── readme.txt
│ │ │ └── relation
│ │ │ ├── Actor.java
│ │ │ ├── Composer.java
│ │ │ ├── Director.java
│ │ │ └── District.java
│ │ ├── qa
│ │ ├── QuestionAnswer.java
│ │ ├── QuestionClassification.java
│ │ └── QuestionMine.java
│ │ ├── reco
│ │ └── Recommender.java
│ │ ├── search
│ │ └── Search.java
│ │ ├── type
│ │ ├── LabelTypes.java
│ │ └── RelTypes.java
│ │ └── util
│ │ ├── InitNeo4j.java
│ │ ├── InitSparkSession.java
│ │ └── PropertiesReader.java
│ └── resources
│ ├── Country.csv
│ ├── Movie.csv
│ ├── Person.csv
│ ├── actor.csv
│ ├── classification_data.txt
│ ├── classification_segment_data.txt
│ ├── composer.csv
│ ├── data
│ └── dictionary
│ │ └── custom
│ │ ├── other.txt
│ │ └── 电影类型.txt
│ ├── director.csv
│ ├── district.csv
│ ├── hanlp.properties
│ ├── metadata.json
│ ├── model
│ ├── metadata
│ │ ├── ._SUCCESS.crc
│ │ ├── .part-00000.crc
│ │ ├── _SUCCESS
│ │ └── part-00000
│ └── stages
│ │ ├── 0_tok_2fb8147c2ee2
│ │ └── metadata
│ │ │ ├── ._SUCCESS.crc
│ │ │ ├── .part-00000.crc
│ │ │ ├── _SUCCESS
│ │ │ └── part-00000
│ │ ├── 1_hashingTF_ff55c4499186
│ │ └── metadata
│ │ │ ├── ._SUCCESS.crc
│ │ │ ├── .part-00000.crc
│ │ │ ├── _SUCCESS
│ │ │ └── part-00000
│ │ ├── 2_idf_109a95453ddb
│ │ ├── data
│ │ │ ├── ._SUCCESS.crc
│ │ │ ├── .part-00000-35b34b06-d2fa-47ae-b558-4ee22e00c780-c000.snappy.parquet.crc
│ │ │ ├── _SUCCESS
│ │ │ └── part-00000-35b34b06-d2fa-47ae-b558-4ee22e00c780-c000.snappy.parquet
│ │ └── metadata
│ │ │ ├── ._SUCCESS.crc
│ │ │ ├── .part-00000.crc
│ │ │ ├── _SUCCESS
│ │ │ └── part-00000
│ │ └── 3_nb_7764900c7e06
│ │ ├── data
│ │ ├── ._SUCCESS.crc
│ │ ├── .part-00000-f597d0cb-8767-4712-95c5-fc3cab975b3a-c000.snappy.parquet.crc
│ │ ├── _SUCCESS
│ │ └── part-00000-f597d0cb-8767-4712-95c5-fc3cab975b3a-c000.snappy.parquet
│ │ └── metadata
│ │ ├── ._SUCCESS.crc
│ │ ├── .part-00000.crc
│ │ ├── _SUCCESS
│ │ └── part-00000
│ ├── properties.properties
│ └── question_classification.txt
└── target
└── classes
├── Country.csv
├── META-INF
└── movie_kg.kotlin_module
├── Movie.csv
├── Person.csv
├── actor.csv
├── com
└── sy
│ ├── base
│ └── abs
│ │ ├── AbstractCSVRead.class
│ │ ├── AbstractNode.class
│ │ └── AbstractRelation.class
│ ├── mainclass
│ ├── GraphApocBuild.class
│ ├── GraphCypherBuild.class
│ └── MovieQA.class
│ ├── manipulation
│ ├── apoc
│ │ ├── CreateNode.class
│ │ └── CreateRelation.class
│ ├── basic_operation
│ │ ├── GraphCount.class
│ │ ├── GraphDelete.class
│ │ └── GraphSearch.class
│ └── cypher
│ │ ├── CreateNode.class
│ │ ├── CreateRelation.class
│ │ ├── node
│ │ ├── Country.class
│ │ ├── Movie.class
│ │ └── Person.class
│ │ └── relation
│ │ ├── Actor.class
│ │ ├── Composer.class
│ │ ├── Director.class
│ │ └── District.class
│ ├── qa
│ └── QuestionAnswer.class
│ ├── type
│ ├── LabelTypes.class
│ └── RelTypes.class
│ └── util
│ ├── InitNeo4j.class
│ └── PropertiesReader.class
├── composer.csv
├── director.csv
├── district.csv
├── metadata.json
└── properties.properties
/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/._.DS_Store
--------------------------------------------------------------------------------
/.idea/$CACHE_FILE$:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | AOP
10 |
11 |
12 | Abstraction issuesJava
13 |
14 |
15 | ActionScript specificJavaScript and TypeScript
16 |
17 |
18 | Android
19 |
20 |
21 | Application Servers
22 |
23 |
24 | ArquillianJava
25 |
26 |
27 | Assignment issuesJava
28 |
29 |
30 | Assignment issuesJavaScript and TypeScript
31 |
32 |
33 | Async code and promisesJavaScript and TypeScript
34 |
35 |
36 | Bitwise operation issuesJava
37 |
38 |
39 | Bitwise operation issuesJavaScript and TypeScript
40 |
41 |
42 | CDI (Contexts and Dependency Injection)
43 |
44 |
45 | Class metricsJava
46 |
47 |
48 | Class structureJava
49 |
50 |
51 | Cloning issuesJava
52 |
53 |
54 | Code maturityJava
55 |
56 |
57 | Code quality toolsJavaScript and TypeScript
58 |
59 |
60 | Code style issuesJava
61 |
62 |
63 | Code style issuesJavaScript and TypeScript
64 |
65 |
66 | CodePlugin DevKit
67 |
68 |
69 | CodeSpring CoreSpring
70 |
71 |
72 | Compiler issuesJava
73 |
74 |
75 | Concurrency annotation issuesJava
76 |
77 |
78 | Control flow issuesJava
79 |
80 |
81 | Control flow issuesJavaScript and TypeScript
82 |
83 |
84 | CorrectnessLintAndroid
85 |
86 |
87 | DOM issuesJavaScript and TypeScript
88 |
89 |
90 | Data flowJava
91 |
92 |
93 | Data flowJavaScript and TypeScript
94 |
95 |
96 | Declaration redundancyJava
97 |
98 |
99 | Dependency issuesJava
100 |
101 |
102 | ECMAScript 6 migration aidsJavaScript and TypeScript
103 |
104 |
105 | EmbeddedPerformanceJava
106 |
107 |
108 | EncapsulationJava
109 |
110 |
111 | Error handlingJava
112 |
113 |
114 | Faces Model
115 |
116 |
117 | FinalizationJava
118 |
119 |
120 | Flow type checkerJavaScript and TypeScript
121 |
122 |
123 | Function metricsJavaScript and TypeScript
124 |
125 |
126 | GPathGroovy
127 |
128 |
129 | General
130 |
131 |
132 | GeneralJava
133 |
134 |
135 | GeneralJavaScript and TypeScript
136 |
137 |
138 | Google Web Toolkit
139 |
140 |
141 | Groovy
142 |
143 |
144 | Hibernate
145 |
146 |
147 | Imports and dependenciesJavaScript and TypeScript
148 |
149 |
150 | ImportsJava
151 |
152 |
153 | Inheritance issuesJava
154 |
155 |
156 | InitializationJava
157 |
158 |
159 | InternationalizationJava
160 |
161 |
162 | InteroperabilityLintAndroid
163 |
164 |
165 | JBoss Seam
166 |
167 |
168 | JPA
169 |
170 |
171 | JSP
172 |
173 |
174 | JUnitJava
175 |
176 |
177 | Java
178 |
179 |
180 | Java 10Java language level migration aidsJava
181 |
182 |
183 | Java 11Java language level migration aidsJava
184 |
185 |
186 | Java 14Java language level migration aidsJava
187 |
188 |
189 | Java 5Java language level migration aidsJava
190 |
191 |
192 | Java 7Java language level migration aidsJava
193 |
194 |
195 | Java 8Java language level migration aidsJava
196 |
197 |
198 | Java 9Java language level migration aidsJava
199 |
200 |
201 | Java EE
202 |
203 |
204 | Java interop issuesKotlin
205 |
206 |
207 | Java language level issuesJava
208 |
209 |
210 | Java language level migration aidsJava
211 |
212 |
213 | JavaBeans issuesJava
214 |
215 |
216 | JavaFX
217 |
218 |
219 | JavaScript and TypeScript
220 |
221 |
222 | JavadocJava
223 |
224 |
225 | Kotlin
226 |
227 |
228 | Kotlin InteroperabilityInteroperabilityLintAndroid
229 |
230 |
231 | Language injection
232 |
233 |
234 | LintAndroid
235 |
236 |
237 | LoggingJava
238 |
239 |
240 | Manifest
241 |
242 |
243 | MemoryJava
244 |
245 |
246 | MessagesCorrectnessLintAndroid
247 |
248 |
249 | Method metricsJava
250 |
251 |
252 | Modularization issuesJava
253 |
254 |
255 | Naming conventionsGroovy
256 |
257 |
258 | Naming conventionsJava
259 |
260 |
261 | Naming conventionsJavaScript and TypeScript
262 |
263 |
264 | Node.jsJavaScript and TypeScript
265 |
266 |
267 | Nullability problemsProbable bugsJava
268 |
269 |
270 | Numeric issuesJava
271 |
272 |
273 | OSGi
274 |
275 |
276 | Packaging issuesJava
277 |
278 |
279 | PerformanceJava
280 |
281 |
282 | PerformanceLintAndroid
283 |
284 |
285 | Plugin DevKit
286 |
287 |
288 | PortabilityJava
289 |
290 |
291 | Potentially confusing code constructsGroovy
292 |
293 |
294 | Potentially confusing code constructsJavaScript and TypeScript
295 |
296 |
297 | Potentially undesirable code constructsJavaScript and TypeScript
298 |
299 |
300 | Probable bugsGroovy
301 |
302 |
303 | Probable bugsJava
304 |
305 |
306 | Probable bugsJavaScript and TypeScript
307 |
308 |
309 | Probable bugsKotlin
310 |
311 |
312 | Properties files
313 |
314 |
315 | Properties filesJava
316 |
317 |
318 | Quarkus
319 |
320 |
321 | RESTful Web Service (JAX-RS)
322 |
323 |
324 | Reflective accessJava
325 |
326 |
327 | Resource managementJava
328 |
329 |
330 | SecurityJava
331 |
332 |
333 | SecurityLintAndroid
334 |
335 |
336 | Serialization issuesJava
337 |
338 |
339 | Spring
340 |
341 |
342 | Spring CoreSpring
343 |
344 |
345 | Spring DataSpring
346 |
347 |
348 | Style issuesKotlin
349 |
350 |
351 | StyleGroovy
352 |
353 |
354 | Switch statement issuesJavaScript and TypeScript
355 |
356 |
357 | TestNGJava
358 |
359 |
360 | Threading issuesGroovy
361 |
362 |
363 | Threading issuesJava
364 |
365 |
366 | Try statement issuesJavaScript and TypeScript
367 |
368 |
369 | TypeScriptJavaScript and TypeScript
370 |
371 |
372 | Unit testingJavaScript and TypeScript
373 |
374 |
375 | Unused symbolsJavaScript and TypeScript
376 |
377 |
378 | UsabilityLintAndroid
379 |
380 |
381 | Validity issuesJavaScript and TypeScript
382 |
383 |
384 | Verbose or redundant code constructsJava
385 |
386 |
387 | VisibilityJava
388 |
389 |
390 | Web Services
391 |
392 |
393 | WebSocket
394 |
395 |
396 | toString() issuesJava
397 |
398 |
399 |
400 |
401 |
402 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Datasource local storage ignored files
5 | /dataSources/
6 | /dataSources.local.xml
7 | # Editor-based HTTP Client requests
8 | /httpRequests/
9 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/dictionaries:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.idea/knowlodeg_graph.iml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 | -
9 |
10 |
11 | -
12 |
13 |
14 | -
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 | -
30 |
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 |
40 |
41 | -
42 |
43 |
44 |
45 |
46 | -
47 |
48 |
49 |
50 |
51 | -
52 |
53 |
54 |
55 |
56 | -
57 |
58 |
59 |
60 |
61 | -
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
69 |
70 |
71 | -
72 |
73 |
74 | -
75 |
76 |
77 |
78 |
79 | -
80 |
81 |
82 |
83 |
84 | -
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 |
93 |
94 | -
95 |
96 |
97 |
98 |
99 | -
100 |
101 |
102 | -
103 |
104 |
105 | -
106 |
107 |
108 | -
109 |
110 |
111 | -
112 |
113 |
114 |
115 |
116 | -
117 |
118 |
119 | -
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # introduction
2 | 电影知识图谱问答,利用spark,neo4j以及hanlp完成一个简易的电影问答系统,java实现。
3 |
4 | # requirement
5 | 利用java-driver方式,使用cypher和apoc构建节点和关系,使用spark完成问句分类。
6 | 1.neo4j3.5.22
7 | 2.apoc3.5.0.13-all
8 | 3.algo-3.5.4.0(图算法库)
9 | 4.jdk1.8
10 | 5.hanlp1.7.7 下载data(包括dictionary和model,配置hanlp.properties路径)放在resources目录下即可
11 | 6.spark3.0
12 | 7.neo4j-java-driver1.7.1
13 | 8.neo4j-graph-data-science-1.1.6-standalone(图算法库gds[包含algo算法库],两个库不兼容)
14 |
15 | # quick start
16 | 一.节点和关系构建模块
17 | 这里提供两种方法,分别用cypher和apoc构建。
18 | 1.cypher构建node与relation(较慢,一个一个语句create)
19 | \src\main\java\com\sy\mainclass\GraphCypherBuild.java
20 | (1).构建节点
21 | createNode();
22 | (2).构建关系
23 | createRelation();
24 |
25 | 2.apoc批量构建node与relation(建议利用apoc构建,不需要stop neo4j,速度和数据量中等)
26 | \src\main\java\com\sy\mainclass\GraphApocBuild.java
27 | (1).构建节点
28 | createNode();
29 | (2).构建关系
30 | createRelation();
31 |
32 | 二.问答模块
33 | 意图识别为以下几类(样本较少,可以增加更多的数据以提高识别精度):
34 | * 0:电影评分
35 | * 1:电影上映时间
36 | * 2:电影类型
37 | * 3:电影简介 (暂时没数据)
38 | * 4:电影演员列表
39 | * 5:演员介绍 (暂时没数据)
40 | * 6:演员参演的某类型的电影作品
41 | * 7:演员的电影作品
42 | * 8:演员参演评分大于x的电影
43 | * 9:演员参演评分小于x的电影
44 | * 10:演员参演演的电影类型有哪些
45 | * 11:演员和演员合作电影有哪些
46 | * 12:演员参数的电影数量
47 | * 13:演员的出生日期 (暂时没数据)
48 | \src\main\java\com\sy\mainclass\MovieQA.java(问答部分,问句意图识别和模板匹配,并转为查询语句)
49 | 问答模型的程序在\src\main\java\com\sy\qa中,主要有
50 | 1.利用spark训练意图分类模型
51 | 2.对问句进行意图识别和模板匹配
52 | 3.提取问答语句中的实体,包括人名和电影名
53 | 4.将问句模板和提取的实体转为cypher或apoc语句进行查询
54 |
55 | 三.推荐模块
56 | \src\main\java\com\sy\mainclass\MovieRec.java
57 | 1.根据相同的演员或导演,返回top-n评分的电影
58 | recCBF1()
59 | 2.根据电影的类型进行推荐,返回topn评分的电影
60 | recCBF2()
61 |
62 | 四.搜索模块
63 | \src\main\java\com\sy\mainclass\MovieSearch.java
64 | 1.返回类型为category,评分最高的前10部电影名称
65 | getMostRatedScoreMovie()
66 |
67 |
68 |
69 | # data
70 | 主要数据在resources中,数据中包含(数据来源http://www.openkg.cn/dataset/douban-movie-kg)
71 |
72 | 三类实体(节点):
73 | 实体类型 数据文件 数量 说明
74 | Movie Movie.csv 4587 电影实体
75 | Person Person.csv 22937 人员实体
76 | Country Country.csv 84 国家实体
77 |
78 | 四类关系:
79 | 关系类型 主语实体类型 宾语实体类型 数据文件 数量 说明
80 | ACTOR_OF Movie Person actor.csv 35257 电影的主演
81 | COMPOSER_OF Movie Person composer.csv 8345 电影的编剧
82 | DIRECTOR_OF Movie Person director.csv 5015 电影的导演
83 | DISTRICT_OF Movie Country district.csv 6227 电影的制片国家/地区
84 |
85 | # flowchart
86 |
87 | 
88 |
89 | # result
90 |
91 | 1.关系图
92 |
93 | 
94 |
95 | 2.问答
96 |
97 | 
98 |
99 | # references
100 |
101 | 1)http://www.openkg.cn/dataset/douban-movie-kg
102 |
103 | 2)https://www.zmonster.me/2019/04/30/neo4j-introduction.html
104 |
105 | # contact
106 |
107 | 如有搜索、推荐、nlp以及大数据挖掘等问题或合作,可联系我:
108 |
109 | 1、我的github项目介绍:https://github.com/jiangnanboy
110 |
111 | 2、我的博客园技术博客:https://www.cnblogs.com/little-horse/
112 |
113 | 3、我的QQ号:2229029156
114 |
--------------------------------------------------------------------------------
/image/flowchart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/image/flowchart.png
--------------------------------------------------------------------------------
/image/movie_graph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/image/movie_graph.png
--------------------------------------------------------------------------------
/image/reponse_result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/image/reponse_result.png
--------------------------------------------------------------------------------
/movie_kg.iml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.example
8 | movie_kg
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
13 |
14 | junit
15 | junit
16 | 4.13
17 | test
18 |
19 |
20 |
21 | org.slf4j
22 | slf4j-api
23 | 1.7.30
24 |
25 |
26 |
27 | org.neo4j.driver
28 | neo4j-java-driver
29 | 1.7.1
30 | compile
31 |
32 |
33 |
34 | com.opencsv
35 | opencsv
36 | 4.2
37 | compile
38 |
39 |
40 |
41 | com.hankcs
42 | hanlp
43 | portable-1.7.7
44 |
45 |
46 |
47 | org.apache.spark
48 | spark-core_2.12
49 | 3.0.0
50 | compile
51 |
52 |
53 |
54 | org.apache.spark
55 | spark-sql_2.12
56 | 3.0.0
57 | compile
58 |
59 |
60 |
61 | org.apache.spark
62 | spark-mllib_2.12
63 | 3.0.0
64 | compile
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/base/abs/AbstractCSVRead.java:
--------------------------------------------------------------------------------
1 | package com.sy.base.abs;
2 |
3 | import com.opencsv.bean.CsvToBean;
4 | import com.opencsv.bean.CsvToBeanBuilder;
5 | import com.opencsv.bean.HeaderColumnNameMappingStrategy;
6 | import org.neo4j.driver.v1.Driver;
7 |
8 | import java.io.BufferedReader;
9 | import java.util.Iterator;
10 |
11 | /**
12 | * Created by YanShi on 2020/7/31 10:34 上午
13 | */
14 | public abstract class AbstractCSVRead {
15 | public Driver driver = null;
16 | public AbstractCSVRead(Driver drive){this.driver = drive;}
17 |
18 | /**
19 | * read csv file
20 | * @param br
21 | * @param clazz
22 | * @param
23 | * @return
24 | */
25 | public Iterator readCSV(BufferedReader br, Class clazz) {
26 | Iterator iterator = null;
27 | HeaderColumnNameMappingStrategy mappingStrategy = new HeaderColumnNameMappingStrategy<>();
28 | mappingStrategy.setType(clazz);
29 | CsvToBean build = new CsvToBeanBuilder(br)
30 | .withMappingStrategy(mappingStrategy)
31 | .withSeparator(',')
32 | .withQuoteChar('\"')
33 | .build();
34 | iterator = build.iterator();
35 | return iterator;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/base/abs/AbstractNode.java:
--------------------------------------------------------------------------------
1 | package com.sy.base.abs;
2 |
3 | import com.opencsv.bean.CsvBindByName;
4 |
5 | /**
6 | * Created by YanShi on 2020/7/30 5:25 下午
7 | */
8 | public abstract class AbstractNode {
9 |
10 | @CsvBindByName(column = "id:ID")
11 | public String id;
12 |
13 | @CsvBindByName(column = ":LABEL")
14 | public String label;
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/base/abs/AbstractRelation.java:
--------------------------------------------------------------------------------
1 | package com.sy.base.abs;
2 |
3 | import com.opencsv.bean.CsvBindByName;
4 |
5 | /**
6 | * Created by YanShi on 2020/7/31 10:53 上午
7 | */
8 | public abstract class AbstractRelation {
9 |
10 | @CsvBindByName(column = ":START_ID")
11 | public String startID;
12 |
13 | @CsvBindByName(column = ":END_ID")
14 | public String endID;
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/mainclass/GraphApocBuild.java:
--------------------------------------------------------------------------------
1 | package com.sy.mainclass;
2 |
3 |
4 | import com.sy.manipulation.apoc.CreateNode;
5 | import com.sy.manipulation.apoc.CreateRelation;
6 | import com.sy.type.LabelTypes;
7 | import com.sy.type.RelTypes;
8 | import com.sy.util.InitNeo4j;
9 | import org.neo4j.driver.v1.Driver;
10 |
11 | /**
12 | * Created by YanShi on 2020/7/24 1:10 下午
13 | */
14 | public class GraphApocBuild {
15 | public static void main(String[] args) {
16 | createNode(InitNeo4j.getDriver());
17 | createRelation(InitNeo4j.getDriver());
18 | InitNeo4j.closeDriver();
19 | }
20 |
21 | /**
22 | * 构建 node
23 | * @param driver
24 | */
25 | public static void createNode(Driver driver) {
26 | CreateNode createNode = new CreateNode(driver);
27 | createNode.createNode("/node/Person.csv", LabelTypes.Person.name());
28 | createNode.createOnlyIndex(LabelTypes.Person.name(), "id");
29 | createNode.createNode( "/node/Movie.csv", LabelTypes.Movie.name());
30 | createNode.createOnlyIndex(LabelTypes.Movie.name(), "id");
31 | createNode.createNode( "/node/Country.csv", LabelTypes.Country.name());
32 | createNode.createOnlyIndex(LabelTypes.Country.name(), "id");
33 | }
34 |
35 | /**
36 | * 构建 relation
37 | * @param driver
38 | */
39 | public static void createRelation(Driver driver) {
40 | CreateRelation createRelation = new CreateRelation(driver);
41 | createRelation.createRelation("/relation/actor.csv", LabelTypes.Movie.name(), LabelTypes.Person.name(), RelTypes.ACTOR_OF.name());
42 | createRelation.createRelation("/relation/composer.csv", LabelTypes.Movie.name(), LabelTypes.Person.name(), RelTypes.COMPOSER_OF.name());
43 | createRelation.createRelation("/relation/director.csv", LabelTypes.Movie.name(), LabelTypes.Person.name(), RelTypes.DIRECTOR_OF.name());
44 | createRelation.createRelation("/relation/district.csv", LabelTypes.Movie.name(), LabelTypes.Country.name(), RelTypes.DISTRICT_OF.name());
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/mainclass/GraphCypherBuild.java:
--------------------------------------------------------------------------------
1 | package com.sy.mainclass;
2 |
3 | import com.sy.manipulation.cypher.CreateNode;
4 | import com.sy.manipulation.cypher.CreateRelation;
5 | import com.sy.util.InitNeo4j;
6 |
7 | import com.sy.util.PropertiesReader;
8 | import org.neo4j.driver.v1.Driver;
9 |
10 | /**
11 | * Created by YanShi on 2020/7/24 1:11 下午
12 | */
13 | public class GraphCypherBuild {
14 | public static void main(String[] args) {
15 | createNode(InitNeo4j.getDriver());
16 | createRelation(InitNeo4j.getDriver());
17 | InitNeo4j.closeDriver();
18 | }
19 |
20 | /**
21 | * 创建entity
22 | * @param driver
23 | */
24 | public static void createNode(Driver driver) {
25 | String personEntityCsv = PropertiesReader.get("personEntity");
26 | String movieEntityCsv = PropertiesReader.get("movieEntity");
27 | String countryEntityCsv = PropertiesReader.get("countryEntity");
28 | String[] entities = {personEntityCsv, movieEntityCsv, countryEntityCsv};
29 | CreateNode createNode = new CreateNode(driver);
30 | createNode.createPersonNode(entities[0]);
31 | createNode.createMovieNode(entities[1]);
32 | createNode.createCountryNode(entities[2]);
33 | }
34 |
35 | /**
36 | * 创建relationship
37 | * @param driver
38 | */
39 | public static void createRelation(Driver driver) {
40 | String actorRelationCsv = PropertiesReader.get("actorRelation");
41 | String composerRelationCsv = PropertiesReader.get("composerRelation");
42 | String directorRelationCsv = PropertiesReader.get("directorRelation");
43 | String districtRelationCsv = PropertiesReader.get("districtRelation");
44 | String[] relations = {actorRelationCsv, composerRelationCsv, directorRelationCsv, districtRelationCsv};
45 | CreateRelation createRelation = new CreateRelation(driver);
46 | createRelation.createActorRel(relations[0]);
47 | createRelation.createComposerRel(relations[1]);
48 | createRelation.createDirectorRel(relations[2]);
49 | createRelation.createDistrictRel(relations[3]);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/mainclass/MovieQA.java:
--------------------------------------------------------------------------------
1 | package com.sy.mainclass;
2 |
3 | import com.hankcs.hanlp.seg.common.Term;
4 | import com.sy.qa.QuestionAnswer;
5 | import com.sy.qa.QuestionClassification;
6 | import com.sy.qa.QuestionMine;
7 | import com.sy.util.InitNeo4j;
8 | import com.sy.util.InitSparkSession;
9 | import com.sy.util.PropertiesReader;
10 |
11 | import java.io.BufferedReader;
12 | import java.io.BufferedWriter;
13 | import java.io.IOException;
14 | import java.nio.file.Files;
15 | import java.nio.file.Paths;
16 | import java.util.List;
17 | import java.util.Scanner;
18 |
19 | import org.apache.commons.lang.StringUtils;
20 | import org.apache.spark.sql.SparkSession;
21 |
22 | /**
23 | * @author YanShi
24 | * @date 2020/8/28 20:29
25 | */
26 | public class MovieQA {
27 | public static void main(String[] args) {
28 |
29 | //对训练数据进行分词并保存,这里使用hanlp进行分词(没有在spark中进行分词是因为使用hanlp时无法序列化)
30 | if(Files.notExists(Paths.get(PropertiesReader.get("questionClassificatoinSegmentTrain")))) {
31 | trainDataToSegment(PropertiesReader.get("questionClassificationTrain"), PropertiesReader.get("questionClassificatoinSegmentTrain"));
32 | }
33 |
34 | //训练
35 | SparkSession sparkSession = InitSparkSession.getSparkSession();
36 | sparkSession.sparkContext().setLogLevel("ERROR");
37 | QuestionClassification classification = new QuestionClassification(sparkSession);
38 | if(Files.notExists(Paths.get(PropertiesReader.get("modelFile")))) {
39 | classification.train(PropertiesReader.get("questionClassificatoinSegmentTrain"), PropertiesReader.get("modelFile"));
40 | }
41 |
42 | //对话预测
43 | Scanner sc = new Scanner(System.in);
44 | String question = null;
45 | System.out.println("小嘉:您好,我是小嘉,请问您想知道些什么呢?");
46 | while (true) {
47 | System.out.print("you:");
48 | question = sc.nextLine();
49 | if(StringUtils.equals(question, "exit")) {
50 | break;
51 | }
52 | List listTerm = QuestionMine.extractNer(question);
53 | StringBuffer sb = new StringBuffer();
54 | for(Term term:listTerm) {
55 | if (term.nature.toString().equals("nnt")) {
56 | sb.append("nnt").append(" ");
57 | } else if(term.nature.toString().equals("nm")) {
58 | sb.append("nm").append(" ");
59 | } else if(term.nature.toString().equals("ng")) {
60 | sb.append("ng").append(" ");
61 | } else {
62 | sb.append(term.word).append(" ");
63 | }
64 | }
65 | double label = classification.predict(PropertiesReader.get("modelFile"), sb.toString().trim());
66 | //System.out.println("预测的类型label为:" + label);
67 | QuestionAnswer questionAnswer = new QuestionAnswer(InitNeo4j.getDriver());
68 | StringBuffer resultLine = new StringBuffer();
69 | List responseResult = questionAnswer.response(label, listTerm);
70 | //打印结果
71 | for(String s : responseResult) {
72 | resultLine.append(s).append(" ");
73 | }
74 | System.out.println("小嘉:" + resultLine.toString());
75 | }
76 | InitNeo4j.closeDriver();
77 | }
78 |
79 | /**
80 | * 对训练数据进行分词并保存
81 | * @param trainDataPath
82 | * @param trainDataSavePath
83 | */
84 | public static void trainDataToSegment(String trainDataPath, String trainDataSavePath) {
85 | try(BufferedReader br = Files.newBufferedReader(Paths.get(trainDataPath));
86 | BufferedWriter bw = Files.newBufferedWriter(Paths.get(trainDataSavePath))) {
87 | String line = null;
88 | while ((line=br.readLine())!=null) {
89 | String[] str = line.split(",");
90 | String label = str[0];
91 | String features = QuestionMine.sentenceSegment(str[1]);
92 | bw.append(label).append(",").append(features);
93 | bw.newLine();
94 | bw.flush();
95 | }
96 | } catch (IOException e) {
97 | e.printStackTrace();
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/mainclass/MovieRec.java:
--------------------------------------------------------------------------------
1 | package com.sy.mainclass;
2 |
3 | import com.sy.reco.Recommender;
4 | import com.sy.util.InitNeo4j;
5 |
6 | /**
7 | * @author YanShi
8 | * @date 2020/9/24 22:41
9 | */
10 | public class MovieRec {
11 | public static void main(String[] args) {
12 | Recommender rec = new Recommender(InitNeo4j.getDriver());
13 | rec.recCBF1("泰坦尼克号", 10).stream().forEach(title -> System.out.println(title));
14 | System.out.println("------------------");
15 | rec.recCBF2("泰坦尼克号", 10).stream().forEach(title -> System.out.println(title));
16 | InitNeo4j.closeDriver();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/mainclass/MovieSearch.java:
--------------------------------------------------------------------------------
1 | package com.sy.mainclass;
2 |
3 | import com.sy.search.Search;
4 | import com.sy.util.InitNeo4j;
5 |
6 | /**
7 | * @author YanShi
8 | * @date 2020/9/29 21:39
9 | */
10 | public class MovieSearch {
11 | public static void main(String[] args) {
12 | Search search = new Search(InitNeo4j.getDriver());
13 | search.getMostRatedScoreMovie(String.valueOf(7.5), "科幻").stream().forEach(movie -> System.out.println(movie));
14 | InitNeo4j.closeDriver();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/apoc/CreateNode.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.apoc;
2 |
3 | import org.neo4j.driver.v1.Driver;
4 | import org.neo4j.driver.v1.Session;
5 |
6 | import org.neo4j.driver.v1.summary.ResultSummary;
7 | import org.slf4j.Logger;
8 | import org.slf4j.LoggerFactory;
9 |
10 |
11 | /**
12 | * Created by YanShi on 2020/7/24 1:10 下午
13 | */
14 | public class CreateNode {
15 |
16 | private Driver driver = null;
17 |
18 | public CreateNode(Driver driver) {
19 | this.driver = driver;
20 | }
21 |
22 | /**
23 | * 构建node
24 | * @param file
25 | * @param nodeLabel
26 | * @return
27 | */
28 | public void createNode(String file, String nodeLabel) {
29 | System.out.println("start create node of " + nodeLabel + "...");
30 | try(Session session = driver.session()) {
31 | session.writeTransaction(tx -> tx.run(" call apoc.periodic.iterate(" +
32 | "'call apoc.load.csv(\"" + file + "\",{header:true,sep:\",\",ignore:[\"label\"]}) yield map as row return row'," +
33 | "'create(p:" + nodeLabel +") set p=row'," +
34 | "{batchSize:1000,iterateList:true, parallel:true}) "));
35 | } catch (Exception e) {
36 | e.printStackTrace();
37 | }
38 | System.out.println("create node " + nodeLabel + " done!");
39 | }
40 |
41 | /**
42 | * 构建索引
43 | * @param nodeLabel
44 | * @param property
45 | */
46 | public boolean createIndex(String nodeLabel, String property) {
47 | ResultSummary summary = null;
48 | try(Session session = driver.session()) {
49 | summary = session.writeTransaction(tx -> tx.run("create index on :" + nodeLabel+ "( " + property+ ")")).summary();
50 | } catch (Exception e) {
51 | e.printStackTrace();
52 | }
53 | System.out.println("create index on " + nodeLabel + "." +property + " done!");
54 | return summary.counters().indexesAdded() == 1;
55 | }
56 |
57 | /**
58 | * 构建唯一索引
59 | * @param nodeLabel
60 | * @param property
61 | * @return
62 | */
63 | public boolean createOnlyIndex(String nodeLabel, String property) {
64 | ResultSummary summary = null;
65 | try(Session session = driver.session()) {
66 | summary = session.writeTransaction(tx -> tx.run("create constraint on (s:" + nodeLabel + ") assert s." + property + " is unique")).summary();
67 | } catch (Exception e) {
68 | e.printStackTrace();
69 | }
70 | System.out.println("create only index on " + nodeLabel + "." +property + " done!");
71 | return summary.counters().constraintsAdded() == 1;
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/apoc/CreateRelation.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.apoc;
2 |
3 | import org.neo4j.driver.v1.Driver;
4 | import org.neo4j.driver.v1.Session;
5 | import org.neo4j.driver.v1.summary.ResultSummary;
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 |
9 | /**
10 | * Created by YanShi on 2020/7/24 1:10 下午
11 | */
12 | public class CreateRelation {
13 |
14 | private Driver driver = null;
15 |
16 | public CreateRelation(Driver driver) {this.driver = driver;}
17 |
18 | /**
19 | * 构建关系
20 | * @param file
21 | * @param startNodeLabel
22 | * @param endNodeLabel
23 | * @param relType
24 | * @return
25 | */
26 | public boolean createRelation(String file, String startNodeLabel, String endNodeLabel, String relType) {
27 | ResultSummary summary = null;
28 | System.out.println("start create relation of " + relType + "...");
29 | try (Session session = driver.session()){
30 | summary = session.writeTransaction(tx -> tx.run("call apoc.periodic.iterate(" +
31 | "'call apoc.load.csv(\""+ file + "\",{header:true,sep:\",\",ignore:[\"type\"]}) yield map as row match (start:" + startNodeLabel + "{id:row.startId}), (end:" + endNodeLabel + "{id:row.endId}) return start,end'," +
32 | "'create (start)-[:" + relType + "]->(end)'," +
33 | "{batchSize:1000,iterateList:true, parallel:false});")).summary(); //这里注意parallel为false,保证在创建节点之间关系时不会产生死锁问题
34 | } catch(Exception e) {
35 | e.printStackTrace();
36 | }
37 | System.out.println("create relation of " + relType + " done!");
38 | return summary.counters().relationshipsCreated() == 1;
39 | }
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/apoc/readme.txt:
--------------------------------------------------------------------------------
1 | 利用apoc批量构建node和relation
2 | 将数据放到neo4j的import目录下
3 | 节点数据目录:import/node/
4 | 关系数据目录:import/relation/
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/basic_operation/GraphCount.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.basic_operation;
2 |
3 | import org.neo4j.driver.v1.Driver;
4 | import org.neo4j.driver.v1.Record;
5 | import org.neo4j.driver.v1.Session;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * Created by YanShi on 2020/9/4 22:27
11 | */
12 | public class GraphCount {
13 |
14 | Driver driver = null;
15 | public GraphCount(Driver driver) {
16 | this.driver = driver;
17 | }
18 |
19 | /**
20 | * 统计label为nodeLabel的节点数量
21 | * @param nodeLabel
22 | */
23 | public int countNode(String nodeLabel) {
24 | int nodeCount =0;
25 | try(Session session = driver.session()) {
26 | List listRecord = session.readTransaction(tx -> tx.run("match(:" + nodeLabel + ") return count(*)")).list();
27 | nodeCount = listRecord.get(0).get(0).asInt();
28 | } catch (Exception e) {
29 | e.printStackTrace();
30 | }
31 | return nodeCount;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/basic_operation/GraphDelete.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.basic_operation;
2 |
3 | import org.neo4j.driver.v1.Driver;
4 | import org.neo4j.driver.v1.Session;
5 | import org.neo4j.driver.v1.summary.ResultSummary;
6 |
7 | /**
8 | * Created by YanShi on 2020/9/4 22:27
9 | */
10 | public class GraphDelete {
11 |
12 | Driver driver = null;
13 | public GraphDelete(Driver driver) {
14 | this.driver = driver;
15 | }
16 |
17 | /**
18 | * 删除label为nodeLabel的所有节点(无关系)
19 | * @param nodeLabel
20 | */
21 | public boolean deleteAllNode(String nodeLabel) {
22 | ResultSummary summary = null;
23 | try(Session session = driver.session()) {
24 | summary = session.writeTransaction(tx -> tx.run("match(n) delete n")).summary();
25 | } catch (Exception e) {
26 | e.printStackTrace();
27 | }
28 | return summary.counters().nodesDeleted() == 1;
29 | }
30 |
31 | /**
32 | * 删除label为nodeLabel的所有节点以及与之相关的所有关系
33 | * @param nodeLabel
34 | * @return
35 | */
36 | public boolean deleteAllRelation(String nodeLabel) {
37 | ResultSummary summary = null;
38 | try(Session session = driver.session()) {
39 | summary = session.writeTransaction(tx -> tx.run("match (n:"+nodeLabel+")-[r]-() delete r,n")).summary();
40 | } catch (Exception e) {
41 | e.printStackTrace();
42 | }
43 | return (summary.counters().nodesDeleted() == 1) || (summary.counters().relationshipsDeleted() == 1);
44 | }
45 |
46 | /**
47 | * 删除index
48 | * @param nodeLabel
49 | * @param property
50 | */
51 | public boolean deleteIndex(String nodeLabel, String property) {
52 | ResultSummary summary =null;
53 | try(Session session = driver.session()) {
54 | summary = session.writeTransaction(tx -> tx.run("drop index on:" + nodeLabel + "(" + property + ")")).summary();
55 | } catch (Exception e) {
56 | e.printStackTrace();
57 | }
58 | return summary.counters().indexesRemoved() == 1;
59 | }
60 |
61 | /**
62 | * 删除唯一索引
63 | * @param nodeLabel
64 | * @param property
65 | * @return
66 | */
67 | public boolean deleteOnlyIndex(String nodeLabel, String property) {
68 | ResultSummary summary =null;
69 | try(Session session = driver.session()) {
70 | summary = session.writeTransaction(tx -> tx.run("drop constraint on (s:" + nodeLabel + ") assert s." + property + " is unique")).summary();
71 | } catch (Exception e) {
72 | e.printStackTrace();
73 | }
74 | return summary.counters().constraintsRemoved() == 1;
75 | }
76 |
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/cypher/CreateNode.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.cypher;
2 |
3 | import com.sy.base.abs.AbstractCSVRead;
4 | import com.sy.manipulation.cypher.node.Country;
5 | import com.sy.manipulation.cypher.node.Movie;
6 | import com.sy.manipulation.cypher.node.Person;
7 |
8 | import org.neo4j.driver.v1.Driver;
9 | import org.neo4j.driver.v1.Session;
10 |
11 | import static org.neo4j.driver.v1.Values.parameters;
12 |
13 | import java.io.BufferedReader;
14 | import java.nio.file.Files;
15 | import java.nio.file.Path;
16 | import java.nio.file.Paths;
17 | import java.util.Iterator;
18 |
19 |
20 | /**
21 | * Created by YanShi on 2020/7/24 9:22 上午
22 | */
23 | public class CreateNode extends AbstractCSVRead {
24 |
25 | public CreateNode(Driver drive) {
26 | super(drive);
27 | }
28 |
29 | /**
30 | * 创建 person node
31 | * @param csvFile
32 | */
33 | public void createPersonNode(String csvFile) {
34 | Path fPath = Paths.get(csvFile);
35 | try(BufferedReader br = Files.newBufferedReader((fPath)); Session session = driver.session(); ) {//Transaction tx = session.beginTransaction()
36 | Iterator iterator = readCSV(br, Person.class);
37 | while (iterator.hasNext()) {
38 | Person person = iterator.next();
39 | session.writeTransaction(tx -> tx.run("create (p:Person {name:{name}, id:{id}})", parameters("name", person.name, "id", person.id)));
40 | }
41 | session.writeTransaction(tx -> tx.run("create index on :Person(id)"));
42 | } catch (Exception e) {
43 | e.printStackTrace();
44 | }
45 | System.out.println("create person node done!");
46 | }
47 |
48 | /**
49 | * 创建 country node
50 | * @param csvFile
51 | */
52 | public void createCountryNode(String csvFile) {
53 | Path fPath = Paths.get(csvFile);
54 | try(BufferedReader br = Files.newBufferedReader((fPath));Session session = driver.session(); ) {//Transaction tx = session.beginTransaction()
55 | Iterator iterator = readCSV(br, Country.class);
56 | while (iterator.hasNext()) {
57 | Country country = iterator.next();
58 | session.writeTransaction(tx -> tx.run("create (c:Country {name:{name}, id:{id}})", parameters("name", country.name, "id", country.id)));
59 | }
60 | session.writeTransaction(tx -> tx.run("create index on :Country(id)"));
61 | } catch (Exception e) {
62 | e.printStackTrace();
63 | }
64 | System.out.println("create country node done!");
65 | }
66 |
67 | /**
68 | * 创建 movie node
69 | * @param csvFile
70 | */
71 | public void createMovieNode(String csvFile) {
72 | Path fPath = Paths.get(csvFile);
73 | try(BufferedReader br = Files.newBufferedReader((fPath));Session session = driver.session(); ) {//Transaction tx = session.beginTransaction()
74 | Iterator iterator = readCSV(br, Movie.class);
75 | while (iterator.hasNext()) {
76 | Movie movie = iterator.next();
77 | session.writeTransaction(tx -> tx.run("create (m:Movie {title:{title}, url:{url}, cover:{cover}, rate:{rate}, category:{category}, language:{language}, showtime:{showtime}, length:{length}, othername:{othername}, id:{id}})",
78 | parameters("title", movie.title, "url", movie.url, "cover", movie.cover, "rate", movie.rate, "category", movie.category, "language", movie.language, "showtime", movie.showtime, "length", movie.length, "othername", movie.othername, "id", movie.id)));
79 | }
80 | session.writeTransaction(tx -> tx.run("create index on :Movie(id)"));
81 | } catch (Exception e) {
82 | e.printStackTrace();
83 | }
84 | System.out.println("create movie node done!");
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/cypher/CreateRelation.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.cypher;
2 |
3 | import com.sy.base.abs.AbstractCSVRead;
4 |
5 | import org.neo4j.driver.v1.*;
6 |
7 | import java.io.BufferedReader;
8 | import java.nio.file.Files;
9 | import java.nio.file.Path;
10 | import java.nio.file.Paths;
11 | import java.util.Iterator;
12 |
13 | import com.sy.manipulation.cypher.relation.Actor;
14 | import com.sy.manipulation.cypher.relation.Composer;
15 | import com.sy.manipulation.cypher.relation.Director;
16 | import com.sy.manipulation.cypher.relation.District;
17 |
18 | /**
19 | * Created by YanShi on 2020/7/24 1:10 下午
20 | */
21 | public class CreateRelation extends AbstractCSVRead {
22 |
23 | public CreateRelation(Driver driver) {super(driver);}
24 |
25 | /**
26 | * 创建 the relatin of actor
27 | * @param csvFile
28 | */
29 | public void createActorRel(String csvFile) {
30 | Path fPath = Paths.get(csvFile);
31 | try(BufferedReader br = Files.newBufferedReader((fPath));Session session = driver.session();){
32 | Iterator iterator = readCSV(br, Actor.class);
33 | while (iterator.hasNext()) {
34 | Actor actor = iterator.next();
35 | session.writeTransaction(tx -> tx.run("match (m:Movie), (p:Person) where m.id = " +
36 | "\"" + actor.startID + "\" and p.id = \"" + actor.endID + "\" merge (m)-[:actor]->(p)"));
37 | }
38 |
39 | } catch (Exception e) {
40 | e.printStackTrace();
41 | }
42 | System.out.println("create relationship of actor done!");
43 | }
44 |
45 | /**
46 | * 创建 the relation of composer
47 | * @param csvFile
48 | */
49 | public void createComposerRel(String csvFile) {
50 | Path fPath = Paths.get(csvFile);
51 | try(BufferedReader br = Files.newBufferedReader((fPath));Session session = driver.session();){
52 | Iterator iterator = readCSV(br, Composer.class);
53 | while (iterator.hasNext()) {
54 | Composer composer = iterator.next();
55 | session.writeTransaction(tx -> tx.run("match (m:Movie), (p:Person) where m.id = " +
56 | "\"" + composer.startID + "\" and p.id = \"" + composer.endID + "\" merge (m)-[:composer]->(p)"));
57 | }
58 | } catch (Exception e) {
59 | e.printStackTrace();
60 | }
61 | System.out.println("create relationship of composer done!");
62 | }
63 |
64 | /**
65 | * 创建 the relation of director
66 | * @param csvFile
67 | */
68 | public void createDirectorRel(String csvFile) {
69 | Path fPath = Paths.get(csvFile);
70 | try(BufferedReader br = Files.newBufferedReader((fPath));Session session = driver.session();){
71 | Iterator iterator = readCSV(br, Director.class);
72 | while (iterator.hasNext()) {
73 | Director director = iterator.next();
74 | session.writeTransaction(tx -> tx.run("match (m:Movie), (p:Person) where m.id = " +
75 | "\"" + director.startID + "\" and p.id = \"" + director.endID +"\" merge (m)-[:director]->(p)"));
76 | }
77 | } catch (Exception e) {
78 | e.printStackTrace();
79 | }
80 | System.out.println("create relationship of director done!");
81 | }
82 |
83 | /**
84 | * 创建 the relation of district
85 | * @param csvFile
86 | */
87 | public void createDistrictRel(String csvFile) {
88 | Path fPath = Paths.get(csvFile);
89 | try(BufferedReader br = Files.newBufferedReader((fPath));Session session = driver.session();){
90 | Iterator iterator = readCSV(br, District.class);
91 | while (iterator.hasNext()) {
92 | District district = iterator.next();
93 | session.writeTransaction(tx -> tx.run("match (m:Movie), (c:Country)" +
94 | "where m.id = \"" + district.startID + "\" AND c.id = \"" + district.endID + "\" merge (m)-[:district]->(c)"));
95 | }
96 | } catch (Exception e) {
97 | e.printStackTrace();
98 | }
99 | System.out.println("create relationship of district done!");
100 | }
101 |
102 | }
103 |
104 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/cypher/node/Country.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.cypher.node;
2 |
3 | import com.opencsv.bean.CsvBindByName;
4 | import com.sy.base.abs.AbstractNode;
5 |
6 | /**
7 | * Created by YanShi on 2020/7/30 4:01 下午
8 | */
9 | public class Country extends AbstractNode {
10 | /**
11 | * "name","id:ID",":LABEL"
12 | */
13 |
14 | @CsvBindByName(column = "name")
15 | public String name;
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/cypher/node/Movie.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.cypher.node;
2 |
3 | import com.opencsv.bean.CsvBindByName;
4 | import com.sy.base.abs.AbstractNode;
5 |
6 | /**
7 | * Created by YanShi on 2020/7/30 4:00 下午
8 | */
9 | public class Movie extends AbstractNode {
10 | /**"title",
11 | * "url",
12 | * "cover",
13 | * "rate",
14 | * "category:String[]",
15 | * "language:String[]",
16 | * "showtime",
17 | * "length",
18 | * "othername:String[]",
19 | * "id:ID",
20 | * ":LABEL"
21 | */
22 |
23 | @CsvBindByName(column = "title")
24 | public String title;
25 |
26 | @CsvBindByName(column = "url")
27 | public String url;
28 |
29 | @CsvBindByName(column = "cover")
30 | public String cover;
31 |
32 | @CsvBindByName(column = "rate")
33 | public float rate;
34 |
35 | @CsvBindByName(column = "category:String[]")
36 | public String category;
37 |
38 | @CsvBindByName(column = "language:String[]")
39 | public String language;
40 |
41 | @CsvBindByName(column = "showtime")
42 | public float showtime;
43 |
44 | @CsvBindByName(column = "length")
45 | public float length;
46 |
47 | @CsvBindByName(column = "othername:String[]")
48 | public String othername;
49 |
50 | }
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/cypher/node/Person.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.cypher.node;
2 |
3 | import com.sy.base.abs.AbstractNode;
4 |
5 | import com.opencsv.bean.CsvBindByName;
6 |
7 | /**
8 | * Created by YanShi on 2020/7/30 4:00 下午
9 | */
10 | public class Person extends AbstractNode {
11 | /**
12 | * "name","id:ID",":LABEL"
13 | */
14 |
15 | @CsvBindByName(column = "name")
16 | public String name;
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/cypher/readme.txt:
--------------------------------------------------------------------------------
1 | 利用cypher创建结点和关系
2 | 1.在保存节点和关系不重复的情况下,可用create创建节点和关系。
3 | 创建唯一性约束保证节点和关系的唯一性。
4 | 2.使用merge对存在的节点和关系返回,不存在则创建。create比merge效率高。
5 | 关系的创建需要搜索节点,所以可以创建索引,以提高效率。
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/cypher/relation/Actor.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.cypher.relation;
2 |
3 | import com.sy.base.abs.AbstractRelation;
4 |
5 | /**
6 | * Created by YanShi on 2020/7/30 4:01 下午
7 | */
8 | public class Actor extends AbstractRelation {
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/cypher/relation/Composer.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.cypher.relation;
2 |
3 | import com.sy.base.abs.AbstractRelation;
4 |
5 | /**
6 | * Created by YanShi on 2020/7/31 10:57 上午
7 | */
8 | public class Composer extends AbstractRelation {
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/cypher/relation/Director.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.cypher.relation;
2 |
3 | import com.sy.base.abs.AbstractRelation;
4 |
5 | /**
6 | * Created by YanShi on 2020/7/31 10:59 上午
7 | */
8 | public class Director extends AbstractRelation {
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/manipulation/cypher/relation/District.java:
--------------------------------------------------------------------------------
1 | package com.sy.manipulation.cypher.relation;
2 |
3 | import com.sy.base.abs.AbstractRelation;
4 |
5 | /**
6 | * Created by YanShi on 2020/7/31 10:59 上午
7 | */
8 | public class District extends AbstractRelation {
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/qa/QuestionAnswer.java:
--------------------------------------------------------------------------------
1 | package com.sy.qa;
2 |
3 | import com.hankcs.hanlp.seg.common.Term;
4 | import org.apache.commons.lang.StringUtils;
5 | import org.neo4j.driver.v1.Driver;
6 | import org.neo4j.driver.v1.Record;
7 | import org.neo4j.driver.v1.Session;
8 | import org.neo4j.driver.v1.Values;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | /**
14 | * @author YanShi
15 | * @date 2020/8/28 20:29
16 | */
17 | public class QuestionAnswer {
18 | Driver driver = null;
19 | public QuestionAnswer(Driver driver) {
20 | this.driver = driver;
21 | }
22 |
23 | /**
24 | * 回答
25 | * @param label
26 | * @param listTerm
27 | */
28 | public List response(double label, List listTerm) {
29 | /**【nm:电影名,nnt:演员名,ng:电影类型】
30 | * 0:nm 评分
31 | * 1:nm 上映时间
32 | * 2:nm 类型
33 | * 3:nm 简介 (暂时没数据)
34 | * 4:nm 演员列表
35 | * 5:nnt 介绍 (暂时没数据)
36 | * 6:nnt ng 电影作品
37 | * 7:nnt 电影作品
38 | * 8:nnt 参演评分 大于 x
39 | * 9:nnt 参演评分 小于 x
40 | * 10:nnt 电影类型
41 | * 11:nnt nnt 合作 电影列表
42 | * 12:nnt 电影数量
43 | * 13:nnt 出生日期 (暂时没数据)
44 | */
45 | List responseResult = new ArrayList<>();
46 | List result = null;
47 | String movieTitle = null; // 电影名称
48 | String movieShowtime = null; // 电影上映时间
49 | String movieCategory = null; // 电影类型
50 | String movieStar = null; // 演员名称
51 | String movieOtherStar = null; //另一个演员
52 | float rate = 0.0f; //评分
53 | String questionType = String.valueOf(label);
54 | switch (questionType) {
55 | case "0.0":
56 | for(Term term : listTerm) {
57 | if(StringUtils.equals(term.nature.toString(), "nm")) {
58 | movieTitle = term.word;
59 | break;
60 | }
61 | }
62 | for(Record record : movieRate(movieTitle)) {
63 | responseResult.add(record.get("rate").toString());
64 | }
65 | break;
66 | case "1.0":
67 | for(Term term : listTerm) {
68 | if(StringUtils.equals(term.nature.toString(), "nm")) {
69 | movieTitle = term.word;
70 | break;
71 | }
72 | }
73 | for(Record record : movieShowtime(movieTitle)) {
74 | responseResult.add(record.get("showtime").toString());
75 | }
76 | break;
77 | case "2.0":
78 | for(Term term : listTerm) {
79 | if(StringUtils.equals(term.nature.toString(), "nm")) {
80 | movieTitle = term.word;
81 | break;
82 | }
83 | }
84 | for(Record record : movieCategory(movieTitle)) {
85 | responseResult.add(record.get("category").toString());
86 | }
87 | break;
88 | case "3.0": //(暂时没数据)
89 | break;
90 | case "4.0":
91 | for(Term term : listTerm) {
92 | if(StringUtils.equals(term.nature.toString(), "nm")) {
93 | movieTitle = term.word;
94 | break;
95 | }
96 | }
97 | for(Record record : movieActorOfAllPerson(movieTitle)) {
98 | responseResult.add(record.get("name").toString());
99 | }
100 | break;
101 | case "5.0": //(暂时没数据)
102 | break;
103 | case "6.0":
104 | for(Term term : listTerm) {
105 | if(StringUtils.equals(term.nature.toString(), "nnt")) {
106 | movieStar = term.word;
107 | } else if(StringUtils.equals(term.nature.toString(), "ng")) {
108 | movieCategory = term.word;
109 | }
110 | }
111 | for(Record record : personActorOfCategoryMovie(movieStar, movieCategory)){
112 | responseResult.add(record.get("title").toString());
113 | }
114 | break;
115 | case "7.0":
116 | for(Term term : listTerm) {
117 | if(StringUtils.equals(term.nature.toString(), "nnt")) {
118 | movieStar = term.word;
119 | break;
120 | }
121 | }
122 | for(Record record : movieActorByPerson(movieStar)) {
123 | responseResult.add(record.get("title").toString());
124 | }
125 | break;
126 | case "8.0":
127 | for(Term term : listTerm) {
128 | if(StringUtils.equals(term.nature.toString(), "nnt")) {
129 | movieStar = term.word;
130 | } else if(StringUtils.equals(term.nature.toString(), "m")) {
131 | rate = Float.parseFloat(term.word);
132 | }
133 | }
134 | for(Record record : getAboveScorePersonActorOfMovie(movieStar, rate)) {
135 | responseResult.add(record.get("title").toString());
136 | }
137 | break;
138 | case "9.0":
139 | for(Term term : listTerm) {
140 | if(StringUtils.equals(term.nature.toString(), "nnt")) {
141 | movieStar = term.word;
142 | } else if(StringUtils.equals(term.nature.toString(), "m")) {
143 | rate = Float.parseFloat(term.word);
144 | }
145 | }
146 | for(Record record : getBelowScorePersonActorOfMovie(movieStar, rate)) {
147 | responseResult.add(record.get("title").toString());
148 | }
149 | break;
150 | case "10.0":
151 | for(Term term : listTerm) {
152 | if(StringUtils.equals(term.nature.toString(), "nnt")) {
153 | movieStar = term.word;
154 | break;
155 | }
156 | }
157 | for(Record record : getCategoryOfMovieActorByPerson(movieStar)) {
158 | responseResult.add(record.get("category").toString());
159 | }
160 | break;
161 | case "11.0":
162 | for(Term term : listTerm) {
163 | if(StringUtils.equals(term.nature.toString(), "nnt")) {
164 | if(StringUtils.isBlank(movieStar)) {
165 | movieStar = term.word;
166 | } else {
167 | movieOtherStar = term.word;
168 | break;
169 | }
170 | }
171 | }
172 | for(Record record : getMoviesOfPersonActWithOthers(movieStar, movieOtherStar)) {
173 | responseResult.add(record.get("title").toString());
174 | }
175 | break;
176 | case "12.0":
177 | for(Term term : listTerm) {
178 | if(StringUtils.equals(term.nature.toString(), "nnt")) {
179 | movieStar = term.word;
180 | break;
181 | }
182 | }
183 | for(Record record : getCountMovieActorByPerson(movieStar)) {
184 | responseResult.add(record.get("count").toString());
185 | }
186 | break;
187 | case "13.0": //(暂时没数据)
188 | break;
189 | default:
190 | System.out.println("真的不好意思,我还小呢,不懂您在説些什么?");
191 | break;
192 | }
193 | return responseResult;
194 | }
195 |
196 | /**
197 | * 查询电影评分
198 | * @param title
199 | * @return
200 | */
201 | public List movieRate(String title) {
202 | List listRecord = null;
203 | try(Session session = driver.session()) {
204 | listRecord = session.readTransaction(tx -> tx.run("match (m:Movie) where m.title = $title return m.rate as rate",
205 | Values.parameters("title", title))).list();
206 | }
207 | return listRecord;
208 | }
209 |
210 | /**
211 | * 查询电影上映时间
212 | * @param title
213 | * @return
214 | */
215 | public List movieShowtime(String title) {
216 | List listRecord = null;
217 | try(Session session = driver.session()) {
218 | listRecord = session.readTransaction(tx -> tx.run("match (m:Movie) where m.title = $title return m.showtime as showtime",
219 | Values.parameters("title", title))).list();
220 | }
221 | return listRecord;
222 | }
223 |
224 | /**
225 | * 查询电影类型
226 | * @param title
227 | * @return
228 | */
229 | public List movieCategory(String title) {
230 | List listRecord = null;
231 | try(Session session = driver.session()) {
232 | listRecord = session.readTransaction(tx -> tx.run("match (m:Movie) where m.title = $title return m.category as category",
233 | Values.parameters("title", title))).list();
234 | }
235 | return listRecord;
236 | }
237 |
238 | /**
239 | * 查询参演该电影的演员
240 | * @param title
241 | * @return
242 | */
243 | public List movieActorOfAllPerson(String title) {
244 | List listRecord = null;
245 | try(Session session = driver.session()) {
246 | listRecord = session.readTransaction(tx -> tx.run("MATCH path=(m:Movie)-[r:ACTOR_OF]->(p:Person) where m.title = $title return p.name as name",
247 | Values.parameters("title", title))).list();
248 | }
249 | return listRecord;
250 | }
251 |
252 | /**
253 | * 演员参的类型为category的电影
254 | * @param person
255 | * @param category
256 | * @return
257 | */
258 | public List personActorOfCategoryMovie(String person, String category) {
259 | List listRecord = null;
260 | try(Session session = driver.session()) {
261 | listRecord = session.readTransaction(tx -> tx.run("MATCH path=(m:Movie)-[r:ACTOR_OF]->(p:Person) where p.name=$name and m.category =~'.*{category}.*' return m.title as title",
262 | Values.parameters("name", person, "category", category))).list();
263 | }
264 | return listRecord;
265 | }
266 |
267 | /**
268 | * 返回演员为person参演的评分高于rating的电影影名称
269 | * @param person
270 | * @param rating
271 | * @return
272 | */
273 | public List getAboveScorePersonActorOfMovie(String person, float rating) {
274 | List listRecord = null;
275 | try (Session session = driver.session()){
276 | listRecord = session.readTransaction(tx ->
277 | tx.run("match (m:Movie)-[:ACTOR_OF]->(p:Person) where m.rate>$rate and p.name=~'.*{person}.*' return m.title as title",
278 | Values.parameters("rate", rating, "person", person))).list();
279 | }
280 | return listRecord;
281 | }
282 |
283 | /**
284 | * 返回演员为person参演的评分低于rating的电影影名称
285 | * @param person
286 | * @param rating
287 | * @return
288 | */
289 | public List getBelowScorePersonActorOfMovie(String person, float rating) {
290 | List listRecord = null;
291 | try (Session session = driver.session()){
292 | listRecord = session.readTransaction(tx ->
293 | tx.run("match (m:Movie)-[:ACTOR_OF]->(p:Person) where m.rate<$rate and p.name=~'.*{person}.*' return m.title as title",
294 | Values.parameters("rate", rating, "person", person))).list();
295 | }
296 | return listRecord;
297 | }
298 |
299 | /**
300 | * 查询名为name的person参演的电影
301 | * @param name
302 | * @return
303 | */
304 | public List movieActorByPerson(String name) {
305 | List listRecord = null;
306 | try (Session session = driver.session()){
307 | listRecord = session.readTransaction(tx ->
308 | tx.run("match(m:Movie)-[:ACTOR_OF]->(p:Person{name:$name}) return m.title as title",
309 | Values.parameters("name", name))).list();
310 | }
311 | return listRecord;
312 | }
313 |
314 | /**
315 | * 查询名为name的person参演的电影数量
316 | * @param name
317 | * @return
318 | */
319 | public List getCountMovieActorByPerson(String name) {
320 | List listRecord = null;
321 | try (Session session = driver.session()){
322 | listRecord = session.readTransaction(tx ->
323 | tx.run("match(m:Movie)-[:ACTOR_OF]->(p:Person) where p.name = $name return count(m) as count",
324 | Values.parameters("name", name))).list();
325 | }
326 | return listRecord;
327 | }
328 |
329 | /**
330 | * 查询名为name的person参演的电影类型(风格)
331 | * @param name
332 | * @return
333 | */
334 | public List getCategoryOfMovieActorByPerson(String name) {
335 | List listRecord = null;
336 | try (Session session = driver.session()){
337 | listRecord = session.readTransaction(tx ->
338 | tx.run("match(m:Movie)-[:ACTOR_OF]->(p:Person{name:$name}) return m.category as category",
339 | Values.parameters("name", name))).list();
340 | }
341 | return listRecord;
342 | }
343 |
344 | /**
345 | * name1和name2共同出演的电影
346 | * @param name1
347 | * @param name2
348 | * @return
349 | */
350 | public List getMoviesOfPersonActWithOthers(String name1, String name2) {
351 | List lisRecord = null;
352 | try(Session session = driver.session()) {
353 | lisRecord = session.readTransaction(tx ->
354 | tx.run("match(p:Person{name:$pname})<-[:ACTOR_OF]-(m:Movie)-[:ACTOR_OF]->(other:Person{name:$oname}) return m.title as title",
355 | Values.parameters("pname", name1, "oname", name2))).list();
356 | }
357 | return lisRecord;
358 | }
359 |
360 | }
361 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/qa/QuestionClassification.java:
--------------------------------------------------------------------------------
1 | package com.sy.qa;
2 |
3 | import java.io.IOException;
4 | import java.io.Serializable;
5 | import java.util.ArrayList;
6 | import java.util.Iterator;
7 | import java.util.List;
8 | import org.apache.spark.api.java.JavaRDD;
9 | import org.apache.spark.api.java.function.FlatMapFunction;
10 | import org.apache.spark.ml.Pipeline;
11 | import org.apache.spark.ml.PipelineModel;
12 | import org.apache.spark.ml.PipelineStage;
13 | import org.apache.spark.ml.classification.NaiveBayes;
14 | import org.apache.spark.ml.feature.HashingTF;
15 | import org.apache.spark.ml.feature.IDF;
16 | import org.apache.spark.ml.feature.Tokenizer;
17 | import org.apache.spark.sql.*;
18 | import org.apache.spark.sql.types.DataTypes;
19 | import org.apache.spark.sql.types.Metadata;
20 | import org.apache.spark.sql.types.StructField;
21 | import org.apache.spark.sql.types.StructType;
22 |
23 | /**
24 | * @author YanShi
25 | * @date 2020/9/9 22:06
26 | */
27 | public class QuestionClassification implements Serializable {
28 |
29 | SparkSession session = null;
30 | public QuestionClassification(SparkSession session) {
31 | this.session = session;
32 | }
33 |
34 | /**
35 | * 训练
36 | * @param trainFile
37 | * @param modelFile
38 | */
39 | public void train(String trainFile, String modelFile) {
40 |
41 | StructType schema = new StructType(new StructField[] {
42 | new StructField("label", DataTypes.IntegerType, false, Metadata.empty()),
43 | new StructField("sentence", DataTypes.StringType, false, Metadata.empty())
44 | });
45 |
46 | JavaRDD rowJavaRDD = session.read().textFile(trainFile).repartition(14).toJavaRDD().mapPartitions(new FlatMapFunction, Row>() {
47 | @Override
48 | public Iterator call(Iterator input) throws Exception {
49 | List listRow = new ArrayList<>();
50 | while(input.hasNext()) {
51 | String[] line = input.next().split(",");
52 | Integer label = Integer.valueOf(line[0]);
53 | String feature = line[1];
54 | listRow.add(RowFactory.create(label, feature));
55 | }
56 | return listRow.iterator();
57 | }
58 | });
59 | System.out.println("训练样本数据总数: " + rowJavaRDD.collect().size());
60 | Dataset dataset = session.createDataFrame(rowJavaRDD, schema);
61 |
62 | Tokenizer tokenizer = new Tokenizer()
63 | .setInputCol("sentence")
64 | .setOutputCol("words");
65 | HashingTF hashingTF = new HashingTF()
66 | .setNumFeatures(1000)
67 | .setInputCol(tokenizer.getOutputCol())
68 | .setOutputCol("rowfeatures");
69 | IDF idf = new IDF()
70 | .setInputCol(hashingTF.getOutputCol())
71 | .setOutputCol("features");
72 | NaiveBayes nb = new NaiveBayes()
73 | .setSmoothing(0.001);
74 | Pipeline pipeline = new Pipeline()
75 | .setStages(new PipelineStage[] {tokenizer, hashingTF, idf, nb});
76 | PipelineModel model = pipeline.fit(dataset);
77 | try {
78 | model.save(modelFile);
79 | System.out.println("model save to : " + modelFile);
80 | } catch (IOException e) {
81 | e.printStackTrace();
82 | }
83 |
84 | }
85 |
86 | /**
87 | * 预测
88 | * @param modelFile
89 | * @param text
90 | * @return
91 | */
92 | public double predict(String modelFile, String text) {
93 | StructType schema = new StructType(new StructField[] {
94 | new StructField("sentence", DataTypes.StringType, false, Metadata.empty())
95 | });
96 | List predictRow = new ArrayList<>();
97 | predictRow.add(RowFactory.create(text));
98 | Dataset prediction = session.createDataFrame(predictRow, schema);
99 | PipelineModel model = PipelineModel.load(modelFile);
100 | Dataset predictions = model.transform(prediction);
101 | return predictions.select("prediction").collectAsList().get(0).getDouble(0);
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/qa/QuestionMine.java:
--------------------------------------------------------------------------------
1 | package com.sy.qa;
2 |
3 | import com.hankcs.hanlp.HanLP;
4 | import com.hankcs.hanlp.corpus.dependency.CoNll.CoNLLSentence;
5 | import com.hankcs.hanlp.corpus.dependency.CoNll.CoNLLWord;
6 | import com.hankcs.hanlp.corpus.tag.Nature;
7 | import com.hankcs.hanlp.dictionary.stopword.CoreStopWordDictionary;
8 | import com.hankcs.hanlp.seg.Segment;
9 | import com.hankcs.hanlp.seg.common.Term;
10 |
11 | import java.util.List;
12 | import java.util.regex.Pattern;
13 | import java.util.regex.Matcher;
14 |
15 | /**
16 | * @author YanShi
17 | * @date 2020/9/7 22:03
18 | */
19 | public class QuestionMine {
20 | private static Segment segment = null;
21 | static {
22 | segment = HanLP.newSegment().enableCustomDictionaryForcing(true);//强制使用自定义词典
23 | }
24 |
25 | /**
26 | * 抽取人名和电影名
27 | * @param question
28 | * @return
29 | */
30 | public static List extractNer(String question) {
31 | List listTerm = CoreStopWordDictionary.apply(segment.seg(question));
32 | return listTerm;
33 | }
34 |
35 | /**
36 | * 分词
37 | * @param text
38 | * @return
39 | */
40 | public static String sentenceSegment(String text) {
41 | StringBuffer sb = new StringBuffer();
42 | for(Term term : segment.seg(text)) {
43 | sb.append(term.word).append(" ");
44 | }
45 | return sb.toString().trim();
46 | }
47 |
48 | }
49 |
50 |
51 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/reco/Recommender.java:
--------------------------------------------------------------------------------
1 | package com.sy.reco;
2 |
3 | import org.neo4j.driver.v1.Driver;
4 | import org.neo4j.driver.v1.Record;
5 | import org.neo4j.driver.v1.Session;
6 | import org.neo4j.driver.v1.Values;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | /**
12 | * @author YanShi
13 | * @date 2020/9/24 21:54
14 | */
15 | public class Recommender {
16 |
17 | Driver driver = null;
18 | public Recommender(Driver driver) {
19 | this.driver = driver;
20 | }
21 |
22 | /**
23 | * 根据相同的演员或导演,返回top-n评分的电影
24 | * @param movieTitle
25 | * @param topn
26 | * @return
27 | */
28 | public List recCBF1(String movieTitle, int topn) {
29 | List result = new ArrayList<>();
30 | List listRecord = null;
31 | try(Session session = driver.session()) {
32 | listRecord = session.readTransaction(tx -> tx.run("MATCH path=(m:Movie)-[:ACTOR_OF|:DIRECTOR_OF]->(p:Person)<-[:ACTOR_OF|:DIRECTOR_OF]-(rec:Movie) " +
33 | "where m.title = {title} with distinct rec order by rec.rate desc return rec.title as title limit {topn}", Values.parameters("title", movieTitle, "topn", topn))).list();
34 | }
35 | if(0 != listRecord.size())
36 | for(Record record : listRecord){
37 | result.add(record.get("title").toString());
38 | }
39 | return result;
40 | }
41 |
42 | /**
43 | * 根据电影的类型进行推荐,返回topn评分的电影
44 | * @param movieTitle
45 | * @param topn
46 | * @return
47 | */
48 | public List recCBF2(String movieTitle, int topn) {
49 | List result = new ArrayList<>();
50 | List listRecord = null;
51 | try(Session session = driver.session()) {
52 | listRecord = session.readTransaction(tx -> tx.run("match (m:Movie) where m.title={title} with split(m.category, ';') as categoryList " +
53 | "unwind categoryList as category with category match(rec:Movie) where category in split(rec.category, ';') " +
54 | "with distinct rec order by rec.rete desc return rec.title as title limit {topn}", Values.parameters("title", movieTitle, "topn", topn))).list();
55 | }
56 | if(0 != listRecord.size())
57 | for(Record record : listRecord){
58 | result.add(record.get("title").toString());
59 | }
60 | return result;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/search/Search.java:
--------------------------------------------------------------------------------
1 | package com.sy.search;
2 |
3 | import org.neo4j.driver.v1.Driver;
4 | import org.neo4j.driver.v1.Record;
5 | import org.neo4j.driver.v1.Session;
6 | import org.neo4j.driver.v1.Values;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | /**
12 | * @Author Shi Yan
13 | * @Date 2020/8/7 16:00
14 | */
15 | public class Search {
16 | public Driver driver = null;
17 | public Search(Driver driver) {
18 | this.driver = driver;
19 | }
20 |
21 | /**
22 | * 查找名为name的person信息
23 | * @param name
24 | * @return
25 | */
26 | public List findPerson(String name) {
27 | List result = new ArrayList<>();
28 | List listRecord = null;
29 | try (Session session = driver.session()){
30 | listRecord = session.readTransaction(tx ->
31 | tx.run("match(p:Person) where p.name = $name return p.name as name,p.id as id",
32 | Values.parameters("name", name))).list();
33 | }
34 | if(0 != listRecord.size())
35 | for(Record record : listRecord){
36 | result.add(record.get("name").toString() + " : " + record.get("id").toString());
37 | }
38 | return result;
39 | }
40 |
41 | /**
42 | * 查找名为title的movie信息
43 | * @param title
44 | * @return
45 | */
46 | public List findMovie(String title) {
47 | List result = new ArrayList<>();
48 | List listRecord = null;
49 | try (Session session = driver.session()){
50 | listRecord = session.readTransaction(tx ->
51 | tx.run("match(m:Movie) where m.title = $title return m.title as title, m.category as category,m.language as language,m.rate as rate,m.showtime as time,m.length as length",
52 | Values.parameters("title", title))).list();
53 | }
54 | if(0 != listRecord.size())
55 | for(Record record : listRecord){
56 | result.add(record.get("title").toString() + " : " + record.get("category").toString() + " : " + record.get("language").toString() + " : " + record.get("rate").toString() + " : " + record.get("time").toString() + " : " + record.get("length").toString());
57 | }
58 | return result;
59 | }
60 |
61 | /**
62 | * 查找名为name的country信息
63 | * @param name
64 | * @return
65 | */
66 | public List findCountry(String name){
67 | List result = new ArrayList<>();
68 | List listRecord = null;
69 | try (Session session = driver.session()){
70 | listRecord = session.readTransaction(tx ->
71 | tx.run("match(c:Country) where c.name = $name return c.name as name,c.id as id",
72 | Values.parameters("name", name))).list();
73 | }
74 | if(0 != listRecord.size())
75 | for(Record record : listRecord){
76 | result.add(record.get("name").toString() + " : " + record.get("id").toString());
77 | }
78 | return result;
79 | }
80 |
81 | /**
82 | * 查询名为name person创作的电影
83 | * @param name
84 | * @return
85 | */
86 | public List movieComposerByPerson(String name) {
87 | List result = new ArrayList<>();
88 | List listRecord = null;
89 | try (Session session = driver.session()){
90 | listRecord = session.readTransaction(tx ->
91 | tx.run("match(m:Movie)-[:composer]->(p:Person{name:$name}) return p.name as name,m.title as title",
92 | Values.parameters("name", name))).list();
93 | }
94 | if(0 != listRecord.size())
95 | for(Record record : listRecord){
96 | result.add(record.get("name").toString() + " : " + record.get("title").toString());
97 | }
98 | return result;
99 | }
100 |
101 | /**
102 | * 查询名为name的person导演的电影
103 | * @param name
104 | * @return
105 | */
106 | public List movieDirectorByPerson(String name) {
107 | List result = new ArrayList<>();
108 | List listRecord = null;
109 | try (Session session = driver.session()){
110 | listRecord = session.readTransaction(tx ->
111 | tx.run("match(m:Movie)-[:director]->(p:Person{name:$name}) return p.name as name,m.title as title",
112 | Values.parameters("name", name))).list();
113 | }
114 | if(0 != listRecord.size())
115 | for(Record record : listRecord){
116 | result.add(record.get("name").toString() + " : " + record.get("title").toString());
117 | }
118 | return result;
119 | }
120 |
121 | /**
122 | * 查询名为name的country有哪些电影
123 | * @param name
124 | * @return
125 | */
126 | public List movieDistrictByCountry(String name) {
127 | List result = new ArrayList<>();
128 | List listRecord = null;
129 | try (Session session = driver.session()){
130 | listRecord = session.readTransaction(tx ->
131 | tx.run("match(m:Movie)-[:district]->(c:Country{name:$name}) return c.name as name,m.title as title",
132 | Values.parameters("name", name))).list();
133 | }
134 | if(0 != listRecord.size())
135 | for(Record record : listRecord){
136 | result.add(record.get("name").toString() + " : " + record.get("title").toString());
137 | }
138 | return result;
139 | }
140 |
141 | /**
142 | * 返回和name一起出演的明星名称和电影名称
143 | * @param name
144 | * @return
145 | */
146 | public List personActWithOthers(String name) {
147 | List result = new ArrayList<>();
148 | List listRecord = null;
149 | try(Session session = driver.session()) {
150 | listRecord = session.readTransaction(tx ->
151 | tx.run("match(p:Person{name:$name})<-[:ACTOR_OF]-(m:Movie)-[:ACTOR_OF]->(other:Person) return m.title as title,other.name as name",
152 | Values.parameters("name", name))).list();
153 | }
154 | if(0 != listRecord.size())
155 | for(Record record : listRecord){
156 | result.add(record.get("title").toString() + " : " + record.get("name").toString());
157 | }
158 | return result;
159 | }
160 |
161 | /**
162 | * name1与name2最短路径
163 | * @param name1
164 | * @param name2
165 | * @return
166 | */
167 | public List shortestPathBetweenPerson(String name1, String name2) {
168 | List listRecord = null;
169 | try(Session session = driver.session()) {
170 | listRecord = session.readTransaction(tx ->
171 | tx.run("match (m:Person{name:$mname}),(n:Person{name:$nname}),p=shortestpath((m)-[*..]-(n)) return p",
172 | Values.parameters("mname", name1, "nname", name2))).list();
173 | }
174 | return listRecord;
175 | }
176 |
177 | /**
178 | * 返回类型为category,评分最高的前10部电影名称
179 | * @param rating
180 | * @param category
181 | * @return
182 | */
183 | public List getMostRatedScoreMovie(String rating, String category) {
184 | List result = new ArrayList<>();
185 | List listRecord = null;
186 | try (Session session = driver.session()){
187 | listRecord = session.readTransaction(tx ->
188 | tx.run("match (m:Movie) where m.rate>'" + rating + "' and m.category=~'.*" + category+ ".*' return m.title as title order by m.rate desc limit 10")).list();
189 | }
190 | if(0 != listRecord.size())
191 | for(Record record : listRecord){
192 | result.add(record.get("title").toString());
193 | }
194 | return result;
195 | }
196 |
197 | }
198 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/type/LabelTypes.java:
--------------------------------------------------------------------------------
1 | package com.sy.type;
2 |
3 |
4 | /**
5 | * Created by YanShi on 2020/7/24 9:22 上午
6 | */
7 | public enum LabelTypes {
8 | Person,
9 | Movie,
10 | Country
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/type/RelTypes.java:
--------------------------------------------------------------------------------
1 | package com.sy.type;
2 |
3 |
4 | /**
5 | * Created by YanShi on 2020/7/24 9:22 上午
6 | */
7 | public enum RelTypes {
8 | ACTOR_OF,
9 | COMPOSER_OF,
10 | DIRECTOR_OF,
11 | DISTRICT_OF
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/util/InitNeo4j.java:
--------------------------------------------------------------------------------
1 | package com.sy.util;
2 |
3 | import org.neo4j.driver.v1.*;
4 |
5 | /**
6 | * Created by YanShi on 2020/7/24 9:22 上午
7 | */
8 | public class InitNeo4j {
9 | private static Driver driver = null;
10 | static String url = null;
11 | static String name = null;
12 | static String password = null;
13 | /**
14 | * 初始化 driver
15 | * @param url
16 | * @param name
17 | * @param password
18 | * @return
19 | */
20 | private static Driver initDriver(String url, String name, String password) {
21 | if(null == driver) {
22 | driver = GraphDatabase.driver(url, AuthTokens.basic(name, password));
23 | }
24 | return driver;
25 | }
26 |
27 | /**
28 | * 关闭 driver
29 | */
30 | public static void closeDriver() {
31 | if(null != driver) {
32 | driver.close();
33 | }
34 | }
35 |
36 | public static Driver getDriver() {
37 | return driver;
38 | }
39 |
40 | static {
41 | url = PropertiesReader.get("url");
42 | name = PropertiesReader.get("name");
43 | password = PropertiesReader.get("password");
44 | driver = InitNeo4j.initDriver(url, name, password);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/util/InitSparkSession.java:
--------------------------------------------------------------------------------
1 | package com.sy.util;
2 |
3 | import org.apache.spark.SparkConf;
4 | import org.apache.spark.api.java.JavaSparkContext;
5 | import org.apache.spark.sql.SparkSession;
6 |
7 | /**
8 | * Created by YanShi on 2020/9/9 21:22
9 | */
10 | public class InitSparkSession {
11 |
12 | private static SparkSession sparkSession = null;
13 | private static JavaSparkContext javaSparkContext = null;
14 | private static SparkConf sparkConf = null;
15 |
16 | private static void initSparkConf() {
17 | sparkConf = new SparkConf()
18 | .setAppName("ProcessData")
19 | .setMaster("local[*]")
20 | .set("spark.executor.memory", "4g")
21 | .set("spark.network.timeout", "1000")
22 | .set("spark.sql.broadcastTimeout", "2000")
23 | .set("spark.executor.heartbeatInterval", "100");
24 | }
25 |
26 | private static void initSparkSession() {
27 | if(null == sparkConf)
28 | initSparkConf();
29 | sparkSession = SparkSession.builder().config(sparkConf).getOrCreate();
30 | /*sparkSession = SparkSession
31 | .builder()
32 | .appName("Test")
33 | .master("local[*")
34 | .config("spark.executor.memory", "4g")
35 | .getOrCreate();*/
36 | }
37 |
38 | private static void initJavaSparkContext() {
39 | if(null == sparkConf)
40 | initSparkConf();
41 | javaSparkContext = new JavaSparkContext(sparkConf);
42 | }
43 |
44 | public static SparkSession getSparkSession() {
45 | if(null == sparkSession)
46 | initSparkSession();
47 | return sparkSession;
48 | }
49 |
50 | public static JavaSparkContext getJavaSparkContext() {
51 | if(null == javaSparkContext)
52 | initJavaSparkContext();
53 | return javaSparkContext;
54 | }
55 |
56 | public static void closeSparkSession() {
57 | if(null != sparkSession)
58 | sparkSession.close();
59 | }
60 |
61 | public static void closeJavaSparkContext() {
62 | if(null != javaSparkContext)
63 | javaSparkContext.close();
64 | }
65 |
66 | public static void closeSparkSessionAndJavaContext() {
67 | if(null != sparkSession)
68 | sparkSession.close();
69 | if(null != javaSparkContext)
70 | javaSparkContext.close();
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/com/sy/util/PropertiesReader.java:
--------------------------------------------------------------------------------
1 | package com.sy.util;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStreamReader;
5 | import java.util.Properties;
6 |
7 |
8 | /**
9 | * Created by YanShi on 2020/7/31 10:04 上午
10 | */
11 | public class PropertiesReader {
12 |
13 | private static Properties properties = new Properties();
14 |
15 | static {
16 | try {
17 | properties.load(new InputStreamReader(PropertiesReader.class.getClassLoader().getResourceAsStream("properties.properties"), "UTF-8"));
18 | } catch (IOException e) {
19 | e.printStackTrace();
20 | }
21 | }
22 |
23 | public static String get(String keyName) {
24 | return properties.getProperty(keyName);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/resources/Country.csv:
--------------------------------------------------------------------------------
1 | "name","id:ID",":LABEL"
2 | "China_中国大陆","7fc2b2562e9d98efe2d09a55a27f9f13","Country"
3 | "United States of America_美国","13ad3107c64998a9128531822b7976b7","Country"
4 | "Italy_意大利","1fad328df48d832e0382031f36066fcf","Country"
5 | "Iceland_冰岛","366f5bcb109610eda07e536792ac413a","Country"
6 | "Japan_日本","f4305630b4e7042ea22223d8753b3da9","Country"
7 | "France_法国","408aca7ceebe0dba7fb2d786b5bd9623","Country"
8 | "United Kingdom_英国","91555ed6368341bd97f97a2d57c82583","Country"
9 | "South Korea_韩国","d053bb9a1fda259db265f41f77e33d76","Country"
10 | "Mexico_墨西哥","7fd6a20b14fd1433023e483dcbe0720c","Country"
11 | "China_香港","595a5c8d5ec6a10417245c8fef169601","Country"
12 | "Australia_澳大利亚","4c7075111ad3ed1dbaa0058f37868120","Country"
13 | "Germany_德国","c4eeabd06fbf951284036ebe063722c5","Country"
14 | "Belgium_比利时","cd66146336fa6f25a68e971bf952a963","Country"
15 | "India_印度","c64316b019b7180c96d364b0a06f8557","Country"
16 | "China_台湾","3ad3cc769448c856df0c7f6a57a576a3","Country"
17 | "South Africa_南非","34f523d8b129f0946dcc5935b363f937","Country"
18 | "Canada_加拿大","353ed122a4f013e84a170f3c927c7e03","Country"
19 | "New Zealand_新西兰","88cd709b60c818400c5db8822c0d6b3f","Country"
20 | "Denmark_丹麦","634363fba0655a51616c851b18e64b53","Country"
21 | "Malaysia_马来西亚","4af33c50d90badf3c7d254106d08ad1b","Country"
22 | "Russia_俄罗斯","b86adccacadf0662368ffda5e17d2b1e","Country"
23 | "Spain_西班牙","f0b64d75d69b1f5cc313612b81b02833","Country"
24 | "Estonia_爱沙尼亚","214496a51831759d1dd3cc187db9ba0d","Country"
25 | "Poland_波兰","a540f2f518f238afdd92a1fd18f2e560","Country"
26 | "Ukraine_乌克兰","df3179423fb0582637118989a1cdfa87","Country"
27 | "Brazil_巴西","aaa9647b7d3422904a65c332bd0608db","Country"
28 | "Turkey_土耳其","ce114a06c3815927c11ebd704d6cd949","Country"
29 | "Bulgaria_保加利亚","377f6489b166e81528dae518f01b902a","Country"
30 | "Czech Republic_捷克","620b4a502ecfd4d0ae29eb415e1376f2","Country"
31 | "Thailand_泰国","1c5e6a1ec87338f28c86b943dc62d7b0","Country"
32 | "Hungary_匈牙利","9dc307e681dfa70d4904499a68bfeb90","Country"
33 | "Netherlands_荷兰","992b906c919a3045e83885f45b808b44","Country"
34 | "Iran_伊朗","77dd5183456a56014dda906b7975701f","Country"
35 | "Ireland_爱尔兰","22e2494f8ccb36eb804c3124cea6c8fe","Country"
36 | "Austria_奥地利","6bf8c1118d218cf823daa03b070a890b","Country"
37 | "Georgia_格鲁吉亚","a7be27d200b8133935b802b3fb9425ed","Country"
38 | "Kazakhstan_哈萨克斯坦","c4428254efafb170c59e1b3425658236","Country"
39 | "Sweden_瑞典","c392af313929f8ebce85f13204ada9ab","Country"
40 | "Israel_以色列","8b9cd04de1c78d11b670ae5a5fc52fd2","Country"
41 | "Mauritania_毛里塔尼亚","cbce01ff315a31ac4d1beefa6444e7cc","Country"
42 | "Norway_挪威","2937211cb5f223051be211f846b30d30","Country"
43 | "Denmark_丹麦 Denmark","210b67ef04e5b203e879a5d3d35b2a12","Country"
44 | "Switzerland_瑞士","306751770e59b2868e3737a36fdf3631","Country"
45 | "Luxembourg_卢森堡","5bf92e3a3ca7597ed63762432138d668","Country"
46 | "Argentina_阿根廷","52059ed5efa83bfb77ae08f16ccf26a9","Country"
47 | "Lithuania_立陶宛","6c15117286728700bee75631ed4974bc","Country"
48 | "Myanmar_缅甸","23cdc190d8494816232409bb28dece11","Country"
49 | "Greece_希腊","0640a02469377e4b0f00e11266265e8a","Country"
50 | "Australia_澳大利亚 Australia","52c44be5712e9092fef3ba0a5436ed2d","Country"
51 | "Tunisia_突尼斯","9cd1c0b80cccfc24ffa57f53d13bd922","Country"
52 | "Botswana_博茨瓦纳","2ed8485a0a27a8d9bdcf754ec85c4cb5","Country"
53 | "Germany_西德","ca0d3ebdb9ce249b4f61593bc466b2af","Country"
54 | "China_中国","512c03bee5b71d5a8bf402a565121a3e","Country"
55 | "Colombia_哥伦比亚","12a7b3a231f6ab4225293d40f72d5754","Country"
56 | "Finland_芬兰","d7126aa5580c8b0456945277dae709c5","Country"
57 | "Latvia_拉脱维亚","80e699030b672bbaf49462228e290c33","Country"
58 | "United Arab Emirates_阿联酋","10277873a792d5cb7d1a9cd2c0b9a8b9","Country"
59 | "Vietnam_越南","6c27eb044f452fc727b752460227e428","Country"
60 | "Morocco_摩洛哥","c9b92a4f7211342749cca170a797680b","Country"
61 | "Russia_苏联","b626d6f734d5ef7168dd8f1bb0a784c2","Country"
62 | "Cuba_古巴","2ebf6a376d3b75a8fdf5e7d29a14071a","Country"
63 | "Chile_智利","3edfec7a296784c88bb7dddcfc922846","Country"
64 | "Germany_原西德","04e0f67ac1e2194015e69754e53b9229","Country"
65 | "Slovakia_捷克斯洛伐克","4224044d1891fdd2a7b85cba2836fd72","Country"
66 | "Portugal_葡萄牙","2a6e0ff94bafacfd2cb8dce95fa76fcb","Country"
67 | "Slovakia_斯洛伐克","fe9eaec3056037975fa7b710dc1ca567","Country"
68 | "Algeria_阿尔及尼亚","08a22df2eb905a50d21937b12f2c9959","Country"
69 | "Tajikistan_塔吉克斯坦","92ec190710aa4e35b41d800536d8e084","Country"
70 | "Uzbekistan_乌兹别克斯坦","12efe81308c79aef4a0315076f89fc18","Country"
71 | "Slovakia_捷克斯洛伐克 Czechoslovakia","35a0be8e14a547774ba83cdf4652ee0a","Country"
72 | "Romania_罗马尼亚","a640cd5f70acdb4e8a6092abb3eec0b5","Country"
73 | "Iceland_冰島 Iceland","351846bfccac87b5eae3b288e54a727f","Country"
74 | "Canada_加拿大 Canada","4857888cf5421e1b01fa1237870b2eb9","Country"
75 | "United States of America_USA","e25a690d9e9c083ecf7f26517d05324c","Country"
76 | "United Kingdom_UK","b4f35124b12f21728bee305719b15e2d","Country"
77 | "Philippines_菲律宾","ad5e7dc8cd49f7efa9d1cb06e181c581","Country"
78 | "Czech Republic_捷克 Czech Republic","a39acb6653978379a11791320f3d2b43","Country"
79 | "The Bahamas_巴哈马 Bahamas","767d7db6411a9bb459ffd764228d60c0","Country"
80 | "Indonesia_印度尼西亚","fdf65cd14ed9fbc522853eb1ac01f6a8","Country"
81 | "Egypt_埃及","94cec28ec9221c822fddf518d8f2e925","Country"
82 | "Puerto Rico_波多黎各","4064de8ddef6639e973b75aec418f9b3","Country"
83 | "Indonesia_印尼","8b92039adac6f65f1741700a96ed7681","Country"
84 | "Canada_Canada","976ad072b1e174d173d14e0ac0061b7f","Country"
85 | "Peru_秘鲁","46c9293d35be0c8714f6c3f8379f9255","Country"
86 |
--------------------------------------------------------------------------------
/src/main/resources/classification_data.txt:
--------------------------------------------------------------------------------
1 | 0,nm的评分是多少
2 | 0,nm得了多少分
3 | 0,nm的评分有多少
4 | 0,nm的评分
5 | 0,nm的分数是
6 | 0,nm电影分数是多少
7 | 0,nm评分
8 | 0,nm的分数是多少
9 | 0,nm这部电影的评分是多少
10 | 1,nm的上映时间是什么时候
11 | 1,nm的首映时间是什么时候
12 | 1,nm什么时候上映
13 | 1,nm什么时候首映
14 | 1,nm什么时候在影院上线
15 | 1,什么时候可以在影院看到nm
16 | 1,nm什么时候在影院放映
17 | 1,nm什么时候首播
18 | 2,nm的风格是什么
19 | 2,nm是什么风格的电影
20 | 2,nm的格调是什么
21 | 2,nm是什么格调的电影
22 | 2,nm是什么类型的电影
23 | 2,nm的类型是什么
24 | 2,nm是什么类型的
25 | 3,nm的剧情是什么
26 | 3,nm主要讲什么内容
27 | 3,nm的主要剧情是什么
28 | 3,nm主要讲什么故事
29 | 3,nm的故事线索是什么
30 | 3,nm讲了什么
31 | 3,nm的剧情简介
32 | 3,nm的故事内容
33 | 3,nm的主要情节
34 | 3,nm的情节梗概
35 | 3,nm的故事梗概
36 | 4,nm有哪些演员出演
37 | 4,nm是由哪些人演的
38 | 4,nm中参演的演员都有哪些
39 | 4,nm中哪些人演过
40 | 4,nm这部电影的演员都有哪些
41 | 4,nm这部电影中哪些人演过
42 | 5,nnt
43 | 5,nnt
44 | 5,nnt
45 | 5,nnt
46 | 5,nnt
47 | 5,nnt是
48 | 5,nnt是谁
49 | 5,nnt的介绍
50 | 5,nnt的简介
51 | 5,谁是nnt
52 | 5,nnt的详细信息
53 | 5,nnt的信息
54 | 6,nnt演过哪些ng电影
55 | 6,nnt演哪些ng电影
56 | 6,nnt演过ng电影
57 | 6,nnt演过什么ng电影
58 | 6,nnt演过ng电影
59 | 6,nnt演过的ng电影有哪些
60 | 6,nnt出演的ng电影有哪些
61 | 7,nnt演了什么电影
62 | 7,nnt出演了什么电影
63 | 7,nnt演过什么电影
64 | 7,nnt演过哪些电影
65 | 7,nnt过去演过哪些电影
66 | 7,nnt以前演过哪些电影
67 | 7,nnt演过的电影有什么
68 | 7,nnt有哪些电影
69 | 8,nnt参演的评分大于x的电影有哪些
70 | 8,nnt参演的电影评分大于x的有哪些
71 | 8,nnt参演的电影评分超过x的有哪些
72 | 8,nnt演的电影评分超过x的有哪些
73 | 8,nnt演的电影评分大于x的都有哪些
74 | 8,nnt演的电影评分在x以上的都有哪些
75 | 9,nnt参演的评分小于x的电影有哪些
76 | 9,nnt参演的电影评分小于x的有哪些
77 | 9,nnt参演的电影评分低于x的有哪些
78 | 9,nnt演的电影评分低于x的有哪些
79 | 9,nnt演的电影评分小于x的都有哪些
80 | 9,nnt演的电影评分在x以下的都有哪些
81 | 10,nnt演过哪些风格的电影
82 | 10,nnt演过的电影都有哪些风格
83 | 10,nnt演过的电影有哪些类型
84 | 10,nnt演过风格的电影
85 | 10,nnt演过类型的电影
86 | 10,nnt演过题材的电影
87 | 11,nnt和nnt合作的电影有哪些
88 | 11,nnt和nnt一起拍了哪些电影
89 | 11,nnt和nnt一起演过哪些电影
90 | 11,nnt与nnt合拍了哪些电影
91 | 11,nnt和nnt合作了哪些电影
92 | 12,nnt一共参演过多少电影
93 | 12,nnt演过多少部电影
94 | 12,nnt演过多少电影
95 | 12,nnt参演的电影有多少
96 | 13,nnt的出生日期
97 | 13,nnt的生日
98 | 13,nnt生日多少
99 | 13,nnt的出生是什么时候
100 | 13,nnt的出生是多少
101 | 13,nnt生日是什么时候
102 | 13,nnt生日什么时候
103 | 13,nnt出生日期是什么时候
104 | 13,nnt什么时候出生的
105 | 13,nnt出生于哪一天
106 | 13,nnt的出生日期是哪一天
107 | 13,nnt哪一天出生的
--------------------------------------------------------------------------------
/src/main/resources/classification_segment_data.txt:
--------------------------------------------------------------------------------
1 | 0,nm 的 评分 是 多少
2 | 0,nm 得了 多少 分
3 | 0,nm 的 评分 有 多少
4 | 0,nm 的 评分
5 | 0,nm 的 分数 是
6 | 0,nm 电影 分数 是 多少
7 | 0,nm 评分
8 | 0,nm 的 分数 是 多少
9 | 0,nm 这部 电影 的 评分 是 多少
10 | 1,nm 的 上映 时间 是 什么 时候
11 | 1,nm 的 首映 时间 是 什么 时候
12 | 1,nm 什么 时候 上映
13 | 1,nm 什么 时候 首映
14 | 1,nm 什么 时候 在 影院 上线
15 | 1,什么 时候 可以 在 影院 看到 nm
16 | 1,nm 什么 时候 在 影院 放映
17 | 1,nm 什么 时候 首播
18 | 2,nm 的 风格 是 什么
19 | 2,nm 是 什么 风格 的 电影
20 | 2,nm 的 格调 是 什么
21 | 2,nm 是 什么 格调 的 电影
22 | 2,nm 是 什么 类型 的 电影
23 | 2,nm 的 类型 是 什么
24 | 2,nm 是 什么 类型 的
25 | 3,nm 的 剧情 是 什么
26 | 3,nm 主要 讲 什么 内容
27 | 3,nm 的 主要 剧情 是 什么
28 | 3,nm 主要 讲 什么 故事
29 | 3,nm 的 故事 线索 是 什么
30 | 3,nm 讲 了 什么
31 | 3,nm 的 剧情简介
32 | 3,nm 的 故事 内容
33 | 3,nm 的 主要 情节
34 | 3,nm 的 情节 梗概
35 | 3,nm 的 故事梗概
36 | 4,nm 有 哪些 演员 出演
37 | 4,nm 是 由 哪些 人 演 的
38 | 4,nm 中 参演 的 演员 都有 哪些
39 | 4,nm 中 哪些 人 演过
40 | 4,nm 这部 电影 的 演员 都有 哪些
41 | 4,nm 这部 电影 中 哪些 人 演过
42 | 5,nnt
43 | 5,nnt
44 | 5,nnt
45 | 5,nnt
46 | 5,nnt
47 | 5,nnt 是
48 | 5,nnt 是 谁
49 | 5,nnt 的 介绍
50 | 5,nnt 的 简介
51 | 5,谁 是 nnt
52 | 5,nnt 的 详细信息
53 | 5,nnt 的 信息
54 | 6,nnt 演过 哪些 ng 电影
55 | 6,nnt 演 哪些 ng 电影
56 | 6,nnt 演过 ng 电影
57 | 6,nnt 演过 什么 ng 电影
58 | 6,nnt 演过 ng 电影
59 | 6,nnt 演过 的 ng 电影 有 哪些
60 | 6,nnt 出演 的 ng 电影 有 哪些
61 | 7,nnt 演 了 什么 电影
62 | 7,nnt 出演 了 什么 电影
63 | 7,nnt 演过 什么 电影
64 | 7,nnt 演过 哪些 电影
65 | 7,nnt 过去 演过 哪些 电影
66 | 7,nnt 以前 演过 哪些 电影
67 | 7,nnt 演过 的 电影 有 什么
68 | 7,nnt 有 哪些 电影
69 | 8,nnt 参演 的 评分 大于 x 的 电影 有 哪些
70 | 8,nnt 参演 的 电影 评分 大于 x 的 有 哪些
71 | 8,nnt 参演 的 电影 评分 超过 x 的 有 哪些
72 | 8,nnt 演 的 电影 评分 超过 x 的 有 哪些
73 | 8,nnt 演 的 电影 评分 大于 x 的 都有 哪些
74 | 8,nnt 演 的 电 影评 分在 x 以上 的 都有 哪些
75 | 9,nnt 参演 的 评分 小于 x 的 电影 有 哪些
76 | 9,nnt 参演 的 电影 评分 小于 x 的 有 哪些
77 | 9,nnt 参演 的 电影 评分 低于 x 的 有 哪些
78 | 9,nnt 演 的 电影 评分 低于 x 的 有 哪些
79 | 9,nnt 演 的 电影 评分 小于 x 的 都有 哪些
80 | 9,nnt 演 的 电 影评 分在 x 以下 的 都有 哪些
81 | 10,nnt 演过 哪些 风格 的 电影
82 | 10,nnt 演过 的 电 影都 有 哪些 风格
83 | 10,nnt 演过 的 电影 有 哪些 类型
84 | 10,nnt 演过 风格 的 电影
85 | 10,nnt 演过 类型 的 电影
86 | 10,nnt 演过 题材 的 电影
87 | 11,nnt 和 nnt 合作 的 电影 有 哪些
88 | 11,nnt 和 nnt 一 起拍 了 哪些 电影
89 | 11,nnt 和 nnt 一起 演过 哪些 电影
90 | 11,nnt 与 nnt 合拍 了 哪些 电影
91 | 11,nnt 和 nnt 合作 了 哪些 电影
92 | 12,nnt 一 共 参 演过 多少 电影
93 | 12,nnt 演过 多少 部 电影
94 | 12,nnt 演过 多少 电影
95 | 12,nnt 参演 的 电影 有 多少
96 | 13,nnt 的 出生日期
97 | 13,nnt 的 生日
98 | 13,nnt 生日 多少
99 | 13,nnt 的 出生 是 什么 时候
100 | 13,nnt 的 出生 是 多少
101 | 13,nnt 生日 是 什么 时候
102 | 13,nnt 生日 什么 时候
103 | 13,nnt 出生日期 是 什么 时候
104 | 13,nnt 什么 时候 出生 的
105 | 13,nnt 出生于 哪一天
106 | 13,nnt 的 出生日期 是 哪一天
107 | 13,nnt 哪一天 出生 的
108 |
--------------------------------------------------------------------------------
/src/main/resources/data/dictionary/custom/other.txt:
--------------------------------------------------------------------------------
1 | 一
2 | 地区
3 | 谁
4 | 口碑
5 | 分
6 | 哪家
7 | 公司
8 | 将
9 | 上
10 | 关键人物
11 | 下
12 | 准备
13 | 推动
14 | 喜欢
15 | 出品
16 | 故事梗概
17 | 与
18 | 怎么样
19 | 演
20 | 片长
21 | 吗
22 | 相同
23 | 多
24 | 拍摄
25 | 影院
26 | 拿到
27 | 编剧
28 | 分数
29 | 扮演者
30 | 还有
31 | 好看
32 | 在
33 | 哪里
34 | 来自
35 | 正在
36 | 个
37 | 背景
38 | 成就
39 | 中
40 | 类似
41 | 是
42 | 由
43 | 当中
44 | 剧情
45 | 列表
46 | 多少
47 | 风格
48 | 这部
49 | 放
50 | 分析
51 | 简介
52 | 时长
53 | 重要
54 | 片
55 | 格调
56 | 相似
57 | 之中
58 | 豆瓣
59 | 线索
60 | 收获
61 | 类似于
62 | 情节
63 | 网
64 | 打
65 | 国家
66 | 全篇
67 | 奖
68 | 国人
69 | 首映
70 | 做
71 | 公司出品
72 | 上映
73 | 多久
74 | 这个
75 | 出镜率
76 | 赢得
77 | 步
78 | 介绍
79 | 扮演
80 | 核心人物
81 | 受欢迎程度
82 | 代表作品
83 | 获奖
84 | 差不多
85 | 相关
86 | 影响
87 | 未来
88 | 执导
89 | 类型
90 | 影评
91 | 计划
92 | 要
93 | 出版
94 | 观众
95 | 了
96 | 哪个
97 | 看到
98 | 出生于
99 | 制片公司
100 | 和
101 | 中演
102 | 演员表
103 | 发行
104 | 导演
105 | 接受度
106 | 热门
107 | 得
108 | 写
109 | 情况
110 | 多长时间
111 | 什么样
112 | 评价
113 | 身份
114 | 较高
115 | 度
116 | 生日
117 | 题材
118 | 主要
119 | 多长
120 | 放映
121 | 发展
122 | 走向
123 | 时间
124 | 讲
125 | 筹划
126 | 饰演
127 | 人
128 | 评
129 | 首播
130 | 过去
131 | 梗概
132 | 过
133 | 演员
134 | 拍
135 | 经典作品
136 | 获得
137 | 电影
138 | 评分
139 | 成绩
140 | 网上
141 | 票房
142 | 高
143 | 角色介绍
144 | 还
145 | 给
146 | 个人
147 | 哪一天
148 | 制片
149 | 可以
150 | 内容
151 | 出品公司
152 | 名字
153 | 剧情简介
154 | 人物
155 | 片子
156 | 部
157 | 奖项
158 | 故事
159 | 哪
160 | 叫
161 | 作品
162 | 制作
163 | 时候
164 | 怎么
165 | 角色
166 | 程度
167 | 版权
168 | 出生日期
169 | 那天
170 | 对
171 | 即将
172 | 出
173 | 属于
174 | 上线
175 | 中的
176 | 拿
177 | 大于
178 | 出生
179 | 喜剧
180 | ng
181 | 出演
182 | 以上
183 | 以下
184 | 小于
185 | 种类
186 | 合作
187 | 一起
188 | 合拍
189 | nnt
190 | 信息
191 | nm
--------------------------------------------------------------------------------
/src/main/resources/data/dictionary/custom/电影类型.txt:
--------------------------------------------------------------------------------
1 | 冒险
2 | 奇幻
3 | 动画
4 | 剧情
5 | 恐怖
6 | 动作
7 | 喜剧
8 | 历史
9 | 西部
10 | 惊悚
11 | 犯罪
12 | 纪录
13 | 科幻
14 | 悬疑
15 | 音乐
16 | 爱情
17 | 家庭
18 | 战争
19 | 电视电影
--------------------------------------------------------------------------------
/src/main/resources/hanlp.properties:
--------------------------------------------------------------------------------
1 | #本配置文件中的路径的根目录,根目录+其他路径=完整路径(支持相对路径,请参考:https://github.com/hankcs/HanLP/pull/254)
2 | #Windows用户请注意,路径分隔符统一使用/
3 | root=src/main/resources/
4 |
5 | #好了,以上为唯一需要修改的部分,以下配置项按需反注释编辑。
6 |
7 | #核心词典路径
8 | CoreDictionaryPath=data/dictionary/CoreNatureDictionary.txt
9 | #2元语法词典路径
10 | #BiGramDictionaryPath=data/dictionary/CoreNatureDictionary.ngram.txt
11 | #自定义词典路径,用;隔开多个自定义词典,空格开头表示在同一个目录,使用“文件名 词性”形式则表示这个词典的词性默认是该词性。优先级递减。
12 | #所有词典统一使用UTF-8编码,每一行代表一个单词,格式遵从[单词] [词性A] [A的频次] [词性B] [B的频次] ... 如果不填词性则表示采用词典的默认词性。
13 | CustomDictionaryPath=data/dictionary/custom/CustomDictionary.txt; 现代汉语补充词库.txt; 全国地名大全.txt ns; 人名词典.txt; 机构名词典.txt; 上海地名.txt ns; 电影明星.txt nnt; 电影名称.txt nm; 电影类型.txt ng; other.txt;data/dictionary/person/nrf.txt nrf;
14 | #停用词词典路径
15 | CoreStopWordDictionaryPath=data/dictionary/stopwords.txt
16 | #同义词词典路径
17 | #CoreSynonymDictionaryDictionaryPath=data/dictionary/synonym/CoreSynonym.txt
18 | #人名词典路径
19 | PersonDictionaryPath=data/dictionary/person/nr.txt
20 | #人名词典转移矩阵路径
21 | #PersonDictionaryTrPath=data/dictionary/person/nr.tr.txt
22 | #繁简词典根目录
23 | #tcDictionaryRoot=data/dictionary/tc
24 | #HMM分词模型
25 | HMMSegmentModelPath=data/model/segment/HMMSegmentModel.bin
26 | #分词结果是否展示词性
27 | ShowTermNature=true
28 | #IO适配器,实现com.hankcs.hanlp.corpus.io.IIOAdapter接口以在不同的平台(Hadoop、Redis等)上运行HanLP
29 | #默认的IO适配器如下,该适配器是基于普通文件系统的。
30 | #IOAdapter=com.hankcs.hanlp.corpus.io.FileIOAdapter
31 | #感知机词法分析器
32 | #PerceptronCWSModelPath=data/model/perceptron/pku1998/cws.bin
33 | #PerceptronPOSModelPath=data/model/perceptron/pku1998/pos.bin
34 | #PerceptronNERModelPath=data/model/perceptron/pku1998/ner.bin
35 | #CRF词法分析器
36 | CRFCWSModelPath=data/model/crf/pku199801/cws.txt
37 | CRFPOSModelPath=data/model/crf/pku199801/pos.txt
38 | CRFNERModelPath=data/model/crf/pku199801/ner.txt
39 | #更多配置项请参考 https://github.com/hankcs/HanLP/blob/master/src/main/java/com/hankcs/hanlp/HanLP.java#L59 自行添加
40 | #在统计分词中,并不保证自定义词典中的词一定被切分出来。用户可在理解后果的情况下通过
41 |
--------------------------------------------------------------------------------
/src/main/resources/metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "entity-data": {
3 | "Person": "Person.csv",
4 | "Movie": "Movie.csv",
5 | "Country": "Country.csv"
6 | },
7 | "relation-data": {
8 | "Movie|actor|Person": "actor.csv",
9 | "Movie|composer|Person": "composer.csv",
10 | "Movie|director|Person": "director.csv",
11 | "Movie|district|Country": "district.csv"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/resources/model/metadata/._SUCCESS.crc:
--------------------------------------------------------------------------------
1 | crc
--------------------------------------------------------------------------------
/src/main/resources/model/metadata/.part-00000.crc:
--------------------------------------------------------------------------------
1 | crc G˪�
--------------------------------------------------------------------------------
/src/main/resources/model/metadata/_SUCCESS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/metadata/_SUCCESS
--------------------------------------------------------------------------------
/src/main/resources/model/metadata/part-00000:
--------------------------------------------------------------------------------
1 | {"class":"org.apache.spark.ml.PipelineModel","timestamp":1600611291083,"sparkVersion":"3.0.0","uid":"pipeline_9d596a99546b","paramMap":{"stageUids":["tok_2fb8147c2ee2","hashingTF_ff55c4499186","idf_109a95453ddb","nb_7764900c7e06"]},"defaultParamMap":{}}
2 |
--------------------------------------------------------------------------------
/src/main/resources/model/stages/0_tok_2fb8147c2ee2/metadata/._SUCCESS.crc:
--------------------------------------------------------------------------------
1 | crc
--------------------------------------------------------------------------------
/src/main/resources/model/stages/0_tok_2fb8147c2ee2/metadata/.part-00000.crc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/0_tok_2fb8147c2ee2/metadata/.part-00000.crc
--------------------------------------------------------------------------------
/src/main/resources/model/stages/0_tok_2fb8147c2ee2/metadata/_SUCCESS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/0_tok_2fb8147c2ee2/metadata/_SUCCESS
--------------------------------------------------------------------------------
/src/main/resources/model/stages/0_tok_2fb8147c2ee2/metadata/part-00000:
--------------------------------------------------------------------------------
1 | {"class":"org.apache.spark.ml.feature.Tokenizer","timestamp":1600611291305,"sparkVersion":"3.0.0","uid":"tok_2fb8147c2ee2","paramMap":{"inputCol":"sentence","outputCol":"words"},"defaultParamMap":{"outputCol":"tok_2fb8147c2ee2__output"}}
2 |
--------------------------------------------------------------------------------
/src/main/resources/model/stages/1_hashingTF_ff55c4499186/metadata/._SUCCESS.crc:
--------------------------------------------------------------------------------
1 | crc
--------------------------------------------------------------------------------
/src/main/resources/model/stages/1_hashingTF_ff55c4499186/metadata/.part-00000.crc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/1_hashingTF_ff55c4499186/metadata/.part-00000.crc
--------------------------------------------------------------------------------
/src/main/resources/model/stages/1_hashingTF_ff55c4499186/metadata/_SUCCESS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/1_hashingTF_ff55c4499186/metadata/_SUCCESS
--------------------------------------------------------------------------------
/src/main/resources/model/stages/1_hashingTF_ff55c4499186/metadata/part-00000:
--------------------------------------------------------------------------------
1 | {"class":"org.apache.spark.ml.feature.HashingTF","timestamp":1600611291365,"sparkVersion":"3.0.0","uid":"hashingTF_ff55c4499186","paramMap":{"outputCol":"rowfeatures","inputCol":"words","numFeatures":1000},"defaultParamMap":{"outputCol":"hashingTF_ff55c4499186__output","binary":false,"numFeatures":262144}}
2 |
--------------------------------------------------------------------------------
/src/main/resources/model/stages/2_idf_109a95453ddb/data/._SUCCESS.crc:
--------------------------------------------------------------------------------
1 | crc
--------------------------------------------------------------------------------
/src/main/resources/model/stages/2_idf_109a95453ddb/data/.part-00000-35b34b06-d2fa-47ae-b558-4ee22e00c780-c000.snappy.parquet.crc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/2_idf_109a95453ddb/data/.part-00000-35b34b06-d2fa-47ae-b558-4ee22e00c780-c000.snappy.parquet.crc
--------------------------------------------------------------------------------
/src/main/resources/model/stages/2_idf_109a95453ddb/data/_SUCCESS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/2_idf_109a95453ddb/data/_SUCCESS
--------------------------------------------------------------------------------
/src/main/resources/model/stages/2_idf_109a95453ddb/data/part-00000-35b34b06-d2fa-47ae-b558-4ee22e00c780-c000.snappy.parquet:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/2_idf_109a95453ddb/data/part-00000-35b34b06-d2fa-47ae-b558-4ee22e00c780-c000.snappy.parquet
--------------------------------------------------------------------------------
/src/main/resources/model/stages/2_idf_109a95453ddb/metadata/._SUCCESS.crc:
--------------------------------------------------------------------------------
1 | crc
--------------------------------------------------------------------------------
/src/main/resources/model/stages/2_idf_109a95453ddb/metadata/.part-00000.crc:
--------------------------------------------------------------------------------
1 | crc ?mG�
--------------------------------------------------------------------------------
/src/main/resources/model/stages/2_idf_109a95453ddb/metadata/_SUCCESS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/2_idf_109a95453ddb/metadata/_SUCCESS
--------------------------------------------------------------------------------
/src/main/resources/model/stages/2_idf_109a95453ddb/metadata/part-00000:
--------------------------------------------------------------------------------
1 | {"class":"org.apache.spark.ml.feature.IDFModel","timestamp":1600611291440,"sparkVersion":"3.0.0","uid":"idf_109a95453ddb","paramMap":{"inputCol":"rowfeatures","outputCol":"features"},"defaultParamMap":{"minDocFreq":0,"outputCol":"idf_109a95453ddb__output"}}
2 |
--------------------------------------------------------------------------------
/src/main/resources/model/stages/3_nb_7764900c7e06/data/._SUCCESS.crc:
--------------------------------------------------------------------------------
1 | crc
--------------------------------------------------------------------------------
/src/main/resources/model/stages/3_nb_7764900c7e06/data/.part-00000-f597d0cb-8767-4712-95c5-fc3cab975b3a-c000.snappy.parquet.crc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/3_nb_7764900c7e06/data/.part-00000-f597d0cb-8767-4712-95c5-fc3cab975b3a-c000.snappy.parquet.crc
--------------------------------------------------------------------------------
/src/main/resources/model/stages/3_nb_7764900c7e06/data/_SUCCESS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/3_nb_7764900c7e06/data/_SUCCESS
--------------------------------------------------------------------------------
/src/main/resources/model/stages/3_nb_7764900c7e06/data/part-00000-f597d0cb-8767-4712-95c5-fc3cab975b3a-c000.snappy.parquet:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/3_nb_7764900c7e06/data/part-00000-f597d0cb-8767-4712-95c5-fc3cab975b3a-c000.snappy.parquet
--------------------------------------------------------------------------------
/src/main/resources/model/stages/3_nb_7764900c7e06/metadata/._SUCCESS.crc:
--------------------------------------------------------------------------------
1 | crc
--------------------------------------------------------------------------------
/src/main/resources/model/stages/3_nb_7764900c7e06/metadata/.part-00000.crc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/3_nb_7764900c7e06/metadata/.part-00000.crc
--------------------------------------------------------------------------------
/src/main/resources/model/stages/3_nb_7764900c7e06/metadata/_SUCCESS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/src/main/resources/model/stages/3_nb_7764900c7e06/metadata/_SUCCESS
--------------------------------------------------------------------------------
/src/main/resources/model/stages/3_nb_7764900c7e06/metadata/part-00000:
--------------------------------------------------------------------------------
1 | {"class":"org.apache.spark.ml.classification.NaiveBayesModel","timestamp":1600611292585,"sparkVersion":"3.0.0","uid":"nb_7764900c7e06","paramMap":{"smoothing":0.001},"defaultParamMap":{"modelType":"multinomial","rawPredictionCol":"rawPrediction","featuresCol":"features","predictionCol":"prediction","smoothing":1.0,"probabilityCol":"probability","labelCol":"label"}}
2 |
--------------------------------------------------------------------------------
/src/main/resources/properties.properties:
--------------------------------------------------------------------------------
1 | url = bolt://localhost:7687
2 | name = neo4j
3 | password = 123
4 |
5 | personEntity = D:/project/idea_workspace/movie_kg/src/main/resources/Person.csv
6 | movieEntity = D:/project/idea_workspace/movie_kg/src/main/resources/Movie.csv
7 | countryEntity = D:/project/idea_workspace/movie_kg/src/main/resources/Country.csv
8 |
9 | actorRelation = D:/project/idea_workspace/movie_kg/src/main/resources/actor.csv
10 | composerRelation = D:/project/idea_workspace/movie_kg/src/main/resources/composer.csv
11 | directorRelation = D:/project/idea_workspace/movie_kg/src/main/resources/director.csv
12 | districtRelation = D:/project/idea_workspace/movie_kg/src/main/resources/district.csv
13 |
14 | questionClassificationTrain = D:/project/idea_workspace/movie_kg/src/main/resources/classification_data.txt
15 | questionClassificatoinSegmentTrain = D:/project/idea_workspace/movie_kg/src/main/resources/classification_segment_data.txt
16 | questionClassification = D:/project/idea_workspace/movie_kg/src/main/resources/question_classification.txt
17 | modelFile = D:/project/idea_workspace/movie_kg/src/main/resources/model
--------------------------------------------------------------------------------
/src/main/resources/question_classification.txt:
--------------------------------------------------------------------------------
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 出生日期
--------------------------------------------------------------------------------
/target/classes/Country.csv:
--------------------------------------------------------------------------------
1 | "name","id:ID",":LABEL"
2 | "China_中国大陆","7fc2b2562e9d98efe2d09a55a27f9f13","Country"
3 | "United States of America_美国","13ad3107c64998a9128531822b7976b7","Country"
4 | "Italy_意大利","1fad328df48d832e0382031f36066fcf","Country"
5 | "Iceland_冰岛","366f5bcb109610eda07e536792ac413a","Country"
6 | "Japan_日本","f4305630b4e7042ea22223d8753b3da9","Country"
7 | "France_法国","408aca7ceebe0dba7fb2d786b5bd9623","Country"
8 | "United Kingdom_英国","91555ed6368341bd97f97a2d57c82583","Country"
9 | "South Korea_韩国","d053bb9a1fda259db265f41f77e33d76","Country"
10 | "Mexico_墨西哥","7fd6a20b14fd1433023e483dcbe0720c","Country"
11 | "China_香港","595a5c8d5ec6a10417245c8fef169601","Country"
12 | "Australia_澳大利亚","4c7075111ad3ed1dbaa0058f37868120","Country"
13 | "Germany_德国","c4eeabd06fbf951284036ebe063722c5","Country"
14 | "Belgium_比利时","cd66146336fa6f25a68e971bf952a963","Country"
15 | "India_印度","c64316b019b7180c96d364b0a06f8557","Country"
16 | "China_台湾","3ad3cc769448c856df0c7f6a57a576a3","Country"
17 | "South Africa_南非","34f523d8b129f0946dcc5935b363f937","Country"
18 | "Canada_加拿大","353ed122a4f013e84a170f3c927c7e03","Country"
19 | "New Zealand_新西兰","88cd709b60c818400c5db8822c0d6b3f","Country"
20 | "Denmark_丹麦","634363fba0655a51616c851b18e64b53","Country"
21 | "Malaysia_马来西亚","4af33c50d90badf3c7d254106d08ad1b","Country"
22 | "Russia_俄罗斯","b86adccacadf0662368ffda5e17d2b1e","Country"
23 | "Spain_西班牙","f0b64d75d69b1f5cc313612b81b02833","Country"
24 | "Estonia_爱沙尼亚","214496a51831759d1dd3cc187db9ba0d","Country"
25 | "Poland_波兰","a540f2f518f238afdd92a1fd18f2e560","Country"
26 | "Ukraine_乌克兰","df3179423fb0582637118989a1cdfa87","Country"
27 | "Brazil_巴西","aaa9647b7d3422904a65c332bd0608db","Country"
28 | "Turkey_土耳其","ce114a06c3815927c11ebd704d6cd949","Country"
29 | "Bulgaria_保加利亚","377f6489b166e81528dae518f01b902a","Country"
30 | "Czech Republic_捷克","620b4a502ecfd4d0ae29eb415e1376f2","Country"
31 | "Thailand_泰国","1c5e6a1ec87338f28c86b943dc62d7b0","Country"
32 | "Hungary_匈牙利","9dc307e681dfa70d4904499a68bfeb90","Country"
33 | "Netherlands_荷兰","992b906c919a3045e83885f45b808b44","Country"
34 | "Iran_伊朗","77dd5183456a56014dda906b7975701f","Country"
35 | "Ireland_爱尔兰","22e2494f8ccb36eb804c3124cea6c8fe","Country"
36 | "Austria_奥地利","6bf8c1118d218cf823daa03b070a890b","Country"
37 | "Georgia_格鲁吉亚","a7be27d200b8133935b802b3fb9425ed","Country"
38 | "Kazakhstan_哈萨克斯坦","c4428254efafb170c59e1b3425658236","Country"
39 | "Sweden_瑞典","c392af313929f8ebce85f13204ada9ab","Country"
40 | "Israel_以色列","8b9cd04de1c78d11b670ae5a5fc52fd2","Country"
41 | "Mauritania_毛里塔尼亚","cbce01ff315a31ac4d1beefa6444e7cc","Country"
42 | "Norway_挪威","2937211cb5f223051be211f846b30d30","Country"
43 | "Denmark_丹麦 Denmark","210b67ef04e5b203e879a5d3d35b2a12","Country"
44 | "Switzerland_瑞士","306751770e59b2868e3737a36fdf3631","Country"
45 | "Luxembourg_卢森堡","5bf92e3a3ca7597ed63762432138d668","Country"
46 | "Argentina_阿根廷","52059ed5efa83bfb77ae08f16ccf26a9","Country"
47 | "Lithuania_立陶宛","6c15117286728700bee75631ed4974bc","Country"
48 | "Myanmar_缅甸","23cdc190d8494816232409bb28dece11","Country"
49 | "Greece_希腊","0640a02469377e4b0f00e11266265e8a","Country"
50 | "Australia_澳大利亚 Australia","52c44be5712e9092fef3ba0a5436ed2d","Country"
51 | "Tunisia_突尼斯","9cd1c0b80cccfc24ffa57f53d13bd922","Country"
52 | "Botswana_博茨瓦纳","2ed8485a0a27a8d9bdcf754ec85c4cb5","Country"
53 | "Germany_西德","ca0d3ebdb9ce249b4f61593bc466b2af","Country"
54 | "China_中国","512c03bee5b71d5a8bf402a565121a3e","Country"
55 | "Colombia_哥伦比亚","12a7b3a231f6ab4225293d40f72d5754","Country"
56 | "Finland_芬兰","d7126aa5580c8b0456945277dae709c5","Country"
57 | "Latvia_拉脱维亚","80e699030b672bbaf49462228e290c33","Country"
58 | "United Arab Emirates_阿联酋","10277873a792d5cb7d1a9cd2c0b9a8b9","Country"
59 | "Vietnam_越南","6c27eb044f452fc727b752460227e428","Country"
60 | "Morocco_摩洛哥","c9b92a4f7211342749cca170a797680b","Country"
61 | "Russia_苏联","b626d6f734d5ef7168dd8f1bb0a784c2","Country"
62 | "Cuba_古巴","2ebf6a376d3b75a8fdf5e7d29a14071a","Country"
63 | "Chile_智利","3edfec7a296784c88bb7dddcfc922846","Country"
64 | "Germany_原西德","04e0f67ac1e2194015e69754e53b9229","Country"
65 | "Slovakia_捷克斯洛伐克","4224044d1891fdd2a7b85cba2836fd72","Country"
66 | "Portugal_葡萄牙","2a6e0ff94bafacfd2cb8dce95fa76fcb","Country"
67 | "Slovakia_斯洛伐克","fe9eaec3056037975fa7b710dc1ca567","Country"
68 | "Algeria_阿尔及尼亚","08a22df2eb905a50d21937b12f2c9959","Country"
69 | "Tajikistan_塔吉克斯坦","92ec190710aa4e35b41d800536d8e084","Country"
70 | "Uzbekistan_乌兹别克斯坦","12efe81308c79aef4a0315076f89fc18","Country"
71 | "Slovakia_捷克斯洛伐克 Czechoslovakia","35a0be8e14a547774ba83cdf4652ee0a","Country"
72 | "Romania_罗马尼亚","a640cd5f70acdb4e8a6092abb3eec0b5","Country"
73 | "Iceland_冰島 Iceland","351846bfccac87b5eae3b288e54a727f","Country"
74 | "Canada_加拿大 Canada","4857888cf5421e1b01fa1237870b2eb9","Country"
75 | "United States of America_USA","e25a690d9e9c083ecf7f26517d05324c","Country"
76 | "United Kingdom_UK","b4f35124b12f21728bee305719b15e2d","Country"
77 | "Philippines_菲律宾","ad5e7dc8cd49f7efa9d1cb06e181c581","Country"
78 | "Czech Republic_捷克 Czech Republic","a39acb6653978379a11791320f3d2b43","Country"
79 | "The Bahamas_巴哈马 Bahamas","767d7db6411a9bb459ffd764228d60c0","Country"
80 | "Indonesia_印度尼西亚","fdf65cd14ed9fbc522853eb1ac01f6a8","Country"
81 | "Egypt_埃及","94cec28ec9221c822fddf518d8f2e925","Country"
82 | "Puerto Rico_波多黎各","4064de8ddef6639e973b75aec418f9b3","Country"
83 | "Indonesia_印尼","8b92039adac6f65f1741700a96ed7681","Country"
84 | "Canada_Canada","976ad072b1e174d173d14e0ac0061b7f","Country"
85 | "Peru_秘鲁","46c9293d35be0c8714f6c3f8379f9255","Country"
86 |
--------------------------------------------------------------------------------
/target/classes/META-INF/movie_kg.kotlin_module:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/target/classes/com/sy/base/abs/AbstractCSVRead.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/base/abs/AbstractCSVRead.class
--------------------------------------------------------------------------------
/target/classes/com/sy/base/abs/AbstractNode.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/base/abs/AbstractNode.class
--------------------------------------------------------------------------------
/target/classes/com/sy/base/abs/AbstractRelation.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/base/abs/AbstractRelation.class
--------------------------------------------------------------------------------
/target/classes/com/sy/mainclass/GraphApocBuild.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/mainclass/GraphApocBuild.class
--------------------------------------------------------------------------------
/target/classes/com/sy/mainclass/GraphCypherBuild.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/mainclass/GraphCypherBuild.class
--------------------------------------------------------------------------------
/target/classes/com/sy/mainclass/MovieQA.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/mainclass/MovieQA.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/apoc/CreateNode.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/apoc/CreateNode.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/apoc/CreateRelation.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/apoc/CreateRelation.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/basic_operation/GraphCount.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/basic_operation/GraphCount.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/basic_operation/GraphDelete.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/basic_operation/GraphDelete.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/basic_operation/GraphSearch.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/basic_operation/GraphSearch.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/cypher/CreateNode.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/cypher/CreateNode.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/cypher/CreateRelation.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/cypher/CreateRelation.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/cypher/node/Country.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/cypher/node/Country.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/cypher/node/Movie.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/cypher/node/Movie.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/cypher/node/Person.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/cypher/node/Person.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/cypher/relation/Actor.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/cypher/relation/Actor.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/cypher/relation/Composer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/cypher/relation/Composer.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/cypher/relation/Director.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/cypher/relation/Director.class
--------------------------------------------------------------------------------
/target/classes/com/sy/manipulation/cypher/relation/District.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/manipulation/cypher/relation/District.class
--------------------------------------------------------------------------------
/target/classes/com/sy/qa/QuestionAnswer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/qa/QuestionAnswer.class
--------------------------------------------------------------------------------
/target/classes/com/sy/type/LabelTypes.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/type/LabelTypes.class
--------------------------------------------------------------------------------
/target/classes/com/sy/type/RelTypes.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/type/RelTypes.class
--------------------------------------------------------------------------------
/target/classes/com/sy/util/InitNeo4j.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/util/InitNeo4j.class
--------------------------------------------------------------------------------
/target/classes/com/sy/util/PropertiesReader.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiangnanboy/movie_kg/725bf90499e2cd5e11de6cdaf7e0377131c77eb6/target/classes/com/sy/util/PropertiesReader.class
--------------------------------------------------------------------------------
/target/classes/metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "entity-data": {
3 | "Person": "Person.csv",
4 | "Movie": "Movie.csv",
5 | "Country": "Country.csv"
6 | },
7 | "relation-data": {
8 | "Movie|actor|Person": "actor.csv",
9 | "Movie|composer|Person": "composer.csv",
10 | "Movie|director|Person": "director.csv",
11 | "Movie|district|Country": "district.csv"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/target/classes/properties.properties:
--------------------------------------------------------------------------------
1 | url = bolt://localhost:7687
2 | name = neo4j
3 | password = 123
4 |
5 | personEntity = Person.csv
6 | movieEntity = Movie.csv
7 | countryEntity = Country.csv
8 |
9 | actorRelation = actor.csv
10 | composerRelation = composer.csv
11 | directorRelation = director.csv
12 | districtRelation = district.csv
--------------------------------------------------------------------------------