Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
石磊
/
cihai
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 56839b02
authored
Dec 07, 2017
by
侯昆
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
主题 关联词 与 图谱数据
1 parent
be04608f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
1 deletions
serverside/cihai-wechat/src/main/java/com/dookay/cihai/wechat/controller/ThemeController.java
serverside/cihai-wechat/src/main/resources/application-dev.properties
serverside/cihai-wechat/src/main/java/com/dookay/cihai/wechat/controller/ThemeController.java
View file @
56839b0
...
@@ -14,16 +14,26 @@
...
@@ -14,16 +14,26 @@
package
com
.
dookay
.
cihai
.
wechat
.
controller
;
package
com
.
dookay
.
cihai
.
wechat
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.dookay.cihai.core.aip.AipWordUtilBean
;
import
com.dookay.cihai.core.aip.model.WordRelation
;
import
com.dookay.cihai.core.aip.model.WordSequence
;
import
com.dookay.cihai.core.theme.domain.ThemeDomain
;
import
com.dookay.cihai.core.theme.domain.ThemeDomain
;
import
com.dookay.cihai.core.theme.service.IThemeService
;
import
com.dookay.cihai.core.theme.service.IThemeService
;
import
com.dookay.coral.common.web.controller.BaseController
;
import
com.dookay.coral.common.web.controller.BaseController
;
import
com.dookay.coral.common.web.response.JsonResult
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.ModelAndView
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* @author 石磊
* @author 石磊
* @date 2017/12/6
* @date 2017/12/6
...
@@ -34,6 +44,8 @@ public class ThemeController extends BaseController {
...
@@ -34,6 +44,8 @@ public class ThemeController extends BaseController {
@Autowired
@Autowired
private
IThemeService
themeService
;
private
IThemeService
themeService
;
@Autowired
private
AipWordUtilBean
aipWordUtilBean
;
/**
/**
* @author 石磊
* @author 石磊
...
@@ -47,4 +59,39 @@ public class ThemeController extends BaseController {
...
@@ -47,4 +59,39 @@ public class ThemeController extends BaseController {
mv
.
addObject
(
"theme"
,
themeDomain
);
mv
.
addObject
(
"theme"
,
themeDomain
);
return
mv
;
return
mv
;
}
}
/**
* 关联词出现次数
*
* @author houkun
* @date 2017/12/7
*/
@RequestMapping
(
value
=
"/detail/{id}/related"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
JsonResult
related
(
@PathVariable
Long
id
)
{
ThemeDomain
themeDomain
=
themeService
.
get
(
id
);
String
document
=
themeDomain
.
getIntroduce
();
Map
<
String
,
Long
>
wordCountMap
=
aipWordUtilBean
.
extractNounWordsWithCount
(
document
);
return
successResult
(
"关联词出现次数"
,
wordCountMap
);
}
/**
* 图谱信息
*
* @author houkun
* @date 2017/12/7
*/
@RequestMapping
(
value
=
"/detail/{id}/map"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
JsonResult
map
(
@PathVariable
Long
id
)
{
ThemeDomain
themeDomain
=
themeService
.
get
(
id
);
String
document
=
themeDomain
.
getIntroduce
();
List
<
String
>
keywords
=
aipWordUtilBean
.
extractKeyWords
(
themeDomain
.
getTitle
(),
document
,
15
);
List
<
WordSequence
>
wordSequences
=
keywords
.
stream
().
map
(
l
->
new
WordSequence
(
keywords
.
indexOf
(
l
),
l
)).
collect
(
Collectors
.
toList
());
List
<
WordRelation
>
wordRelations
=
aipWordUtilBean
.
generateWordsMap
(
keywords
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"nodes"
,
wordSequences
);
jsonObject
.
put
(
"edges"
,
wordRelations
);
return
successResult
(
"success"
,
jsonObject
);
}
}
}
serverside/cihai-wechat/src/main/resources/application-dev.properties
View file @
56839b0
...
@@ -11,7 +11,7 @@ logging.level.root=info
...
@@ -11,7 +11,7 @@ logging.level.root=info
logging.level.com.dookay.core
=
trace
logging.level.com.dookay.core
=
trace
# redis
# redis
spring.redis.host
=
192.168.2.27
spring.redis.host
=
192.168.2.27
spring.redis.password
=
lyd123456
spring.redis.password
=
100001
# 文件存储
# 文件存储
coral.web.resource.mapping.uploads-
inner
=
/uploads/*
coral.web.resource.mapping.uploads-
inner
=
/uploads/*
coral.web.resource.mapping.uploads-
mapping
=
/data/www/uploads/cihai
coral.web.resource.mapping.uploads-
mapping
=
/data/www/uploads/cihai
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment