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 ce622134
authored
Dec 07, 2017
by
侯昆
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
整合主题页
1 parent
20856bae
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
9 deletions
serverside/cihai-core/src/main/java/com/dookay/cihai/core/aip/AipWordUtilBean.java
serverside/cihai-wechat/src/main/java/com/dookay/cihai/wechat/controller/HomeController.java
serverside/cihai-wechat/src/main/java/com/dookay/cihai/wechat/controller/ThemeController.java
serverside/cihai-wechat/src/main/webapp/WEB-INF/jsp/portal/theme/detail.jsp
serverside/cihai-core/src/main/java/com/dookay/cihai/core/aip/AipWordUtilBean.java
View file @
ce62213
...
...
@@ -58,7 +58,7 @@ public final class AipWordUtilBean {
private
static
final
String
SCORE_KEY_PREFIX
=
"WORD_SCORE:"
;
private
static
final
double
CRITICAL_VALUE
=
0.4
D
;
private
static
final
double
RELATE_CRITICAL_VALUE
=
0.6
D
;
private
static
final
double
RELATE_CRITICAL_VALUE
=
0.6
5
D
;
/**
* 内部错误
...
...
serverside/cihai-wechat/src/main/java/com/dookay/cihai/wechat/controller/HomeController.java
View file @
ce62213
...
...
@@ -18,6 +18,7 @@ import com.dookay.cihai.core.aip.AipWordUtilBean;
import
com.dookay.cihai.core.theme.domain.ThemeDomain
;
import
com.dookay.cihai.core.theme.query.ThemeQuery
;
import
com.dookay.cihai.core.theme.service.IThemeService
;
import
com.dookay.cihai.core.word.domain.CustomDictionaryDomain
;
import
com.dookay.cihai.core.word.query.CustomDictionaryQuery
;
import
com.dookay.cihai.core.word.service.ICustomDictionaryService
;
import
com.dookay.cihai.core.word.service.IWordService
;
...
...
@@ -30,6 +31,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
java.util.List
;
/**
* @author 石磊
* @date 2017/12/6
...
...
@@ -70,23 +73,26 @@ public class HomeController extends BaseController {
public
JsonResult
search
(
String
keyword
)
{
System
.
out
.
println
(
"进入搜索"
);
String
result
=
null
;
CustomDictionaryQuery
query1
=
new
CustomDictionaryQuery
();
query1
.
setWord
(
keyword
);
boolean
inDic
=
false
;
List
<
CustomDictionaryDomain
>
dictionaryDomainList
=
customDictionaryService
.
getList
(
new
CustomDictionaryQuery
());
for
(
CustomDictionaryDomain
dic
:
dictionaryDomainList
)
{
if
(
keyword
.
contains
(
dic
.
getWord
()))
{
result
=
dic
.
getWord
();
inDic
=
true
;
}
}
try
{
int
count
=
customDictionaryService
.
count
(
query1
);
if
(
count
>
0
)
{
result
=
keyword
;
}
else
{
if
(!
inDic
)
{
result
=
aipWordUtilBean
.
extractQueryKeyword
(
keyword
);
}
ThemeQuery
query
=
new
ThemeQuery
();
query
.
setKeyword
(
result
);
ThemeDomain
themeDomain
=
themeService
.
getFirst
(
query
);
if
(
themeDomain
==
null
)
return
errorResult
(
String
.
format
(
"暂无\"%s\"检索结果"
,
keyword
));
if
(
themeDomain
==
null
)
return
errorResult
(
String
.
format
(
"暂无\"%s\"检索结果"
,
keyword
));
System
.
out
.
println
(
themeDomain
);
return
successResult
(
"success"
,
"/theme/detail/"
+
themeDomain
.
getId
());
}
catch
(
Exception
ex
)
{
return
errorResult
(
String
.
format
(
"暂无\"%s\"检索结果"
,
keyword
));
return
errorResult
(
String
.
format
(
"暂无\"%s\"检索结果"
,
keyword
));
}
}
...
...
serverside/cihai-wechat/src/main/java/com/dookay/cihai/wechat/controller/ThemeController.java
View file @
ce62213
...
...
@@ -23,6 +23,7 @@ import com.dookay.cihai.core.theme.domain.ThemeDomain;
import
com.dookay.cihai.core.theme.service.IThemeService
;
import
com.dookay.coral.common.web.controller.BaseController
;
import
com.dookay.coral.common.web.response.JsonResult
;
import
com.dookay.coral.common.web.utils.HtmlUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
@@ -57,8 +58,16 @@ public class ThemeController extends BaseController {
@RequestMapping
(
value
=
"/detail/{id}"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
detail
(
@PathVariable
Long
id
)
{
ThemeDomain
themeDomain
=
themeService
.
get
(
id
);
String
document
=
themeDomain
.
getIntroduce
();
document
=
HtmlUtils
.
removeTag
(
document
);
List
<
WordCount
>
wordCounts
=
aipWordUtilBean
.
extractNounWordsWithCount
(
document
)
.
stream
().
sorted
(
Comparator
.
comparing
(
WordCount:
:
getValue
).
reversed
())
.
filter
(
w
->
!
w
.
getLabel
().
equals
(
themeDomain
.
getTitle
()))
.
limit
(
10
)
.
collect
(
Collectors
.
toList
());
ModelAndView
mv
=
new
ModelAndView
(
"portal/theme/detail"
);
mv
.
addObject
(
"theme"
,
themeDomain
);
mv
.
addObject
(
"wordCounts"
,
wordCounts
);
return
mv
;
}
...
...
@@ -73,6 +82,7 @@ public class ThemeController extends BaseController {
public
JsonResult
related
(
@PathVariable
Long
id
)
{
ThemeDomain
themeDomain
=
themeService
.
get
(
id
);
String
document
=
themeDomain
.
getIntroduce
();
document
=
HtmlUtils
.
removeTag
(
document
);
List
<
WordCount
>
wordCounts
=
aipWordUtilBean
.
extractNounWordsWithCount
(
document
);
List
<
WordCount
>
collect
=
wordCounts
.
stream
().
sorted
(
Comparator
.
comparingDouble
(
l
->
Math
.
random
())).
limit
(
8
).
collect
(
Collectors
.
toList
());
JSONObject
result
=
new
JSONObject
();
...
...
@@ -92,6 +102,7 @@ public class ThemeController extends BaseController {
public
JsonResult
map
(
@PathVariable
Long
id
)
{
ThemeDomain
themeDomain
=
themeService
.
get
(
id
);
String
document
=
themeDomain
.
getIntroduce
();
document
=
HtmlUtils
.
removeTag
(
document
);
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
);
...
...
serverside/cihai-wechat/src/main/webapp/WEB-INF/jsp/portal/theme/detail.jsp
View file @
ce62213
This diff is collapsed.
Click to expand it.
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