Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
brandkbs2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shenjunjie
brandkbs2
Commits
d300091b
Commit
d300091b
authored
Jan 05, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'dev'
词云图由hanLp调整为ansj 2 See merge request
!141
parents
9928b97f
53c0e739
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
14 deletions
+22
-14
src/main/java/com/zhiwei/brandkbs2/ansjSeg/AnsjSeg.java
+0
-0
src/main/java/com/zhiwei/brandkbs2/ansjSeg/MyDic.java
+7
-9
src/main/java/com/zhiwei/brandkbs2/service/impl/CustomEventServiceImpl.java
+5
-1
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+6
-2
src/main/java/com/zhiwei/brandkbs2/util/TextUtil.java
+4
-2
No files found.
src/main/java/com/zhiwei/brandkbs2/ansjSeg/AnsjSeg.java
View file @
d300091b
This diff is collapsed.
Click to expand it.
src/main/java/com/zhiwei/brandkbs2/ansjSeg/MyDic.java
View file @
d300091b
...
...
@@ -39,13 +39,11 @@ public class MyDic {
public
void
init
()
{
try
{
// 读取词典
List
<
String
>
customDics
=
Tools
.
readListFile
(
customDic
.
getInputStream
());
List
<
String
>
stopDics
=
Tools
.
readListFile
(
stopDic
.
getInputStream
());
InputStream
inputStream
=
negativeDic
.
getInputStream
();
List
<
String
>
negativeDic
=
Tools
.
readListFile
(
inputStream
);
InputStream
inputStream2
=
positiveDic
.
getInputStream
();
List
<
String
>
positiveDic
=
Tools
.
readListFile
(
inputStream2
);
log
.
info
(
"ansj自定义词典加载:{}条,停用词加载:{}条,负面词典加载:{}条,正面词典加载:{}条"
,
customDics
.
size
(),
stopDics
.
size
(),
negativeDic
.
size
(),
positiveDic
.
size
());
customWords
=
Tools
.
readListFile
(
customDic
.
getInputStream
());
stopWords
=
Tools
.
readListFile
(
stopDic
.
getInputStream
());
negativeWords
=
Tools
.
readListFile
(
negativeDic
.
getInputStream
());
positiveWords
=
Tools
.
readListFile
(
positiveDic
.
getInputStream
());
log
.
info
(
"ansj自定义词典加载:{}条,停用词加载:{}条,负面词典加载:{}条,正面词典加载:{}条"
,
customWords
.
size
(),
stopWords
.
size
(),
negativeWords
.
size
(),
positiveWords
.
size
());
}
catch
(
Exception
e
)
{
log
.
info
(
"MyDic-init 异常"
,
e
);
}
...
...
@@ -78,8 +76,8 @@ public class MyDic {
* @Description: TODO(获取正面词)
* 设定文件
*/
public
static
List
<
String
>
getPosi
v
tiveWords
()
{
return
nega
tiveWords
;
public
static
List
<
String
>
getPositiveWords
()
{
return
posi
tiveWords
;
}
/**
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/CustomEventServiceImpl.java
View file @
d300091b
...
...
@@ -33,6 +33,7 @@ import org.apache.logging.log4j.LogManager;
import
org.apache.logging.log4j.Logger
;
import
org.joda.time.Period
;
import
org.joda.time.PeriodType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
...
...
@@ -81,6 +82,9 @@ public class CustomEventServiceImpl implements CustomEventService {
@Resource
MongoUtil
mongoUtil
;
@Autowired
TextUtil
textUtil
;
@Override
public
List
<
JSONObject
>
getCustomEventRankList
(
Long
startTime
,
Long
endTime
)
{
List
<
JSONObject
>
resultList
=
null
;
...
...
@@ -375,7 +379,7 @@ public class CustomEventServiceImpl implements CustomEventService {
private
List
<
JSONObject
>
getHotKeyword
(
List
<
BaseMap
>
articleList
)
{
List
<
String
>
texts
=
articleList
.
stream
().
map
(
article
->
article
.
getTitle
()
+
article
.
getContent
()).
collect
(
Collectors
.
toList
());
//分析热评词
return
T
extUtil
.
getHighWordsJson
(
texts
,
30
);
return
t
extUtil
.
getHighWordsJson
(
texts
,
30
);
}
/**
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
d300091b
...
...
@@ -137,6 +137,9 @@ public class MarkDataServiceImpl implements MarkDataService {
@Resource
(
name
=
"mongoUtil"
)
MongoUtil
mongoUtil
;
@Autowired
TextUtil
textUtil
;
@Override
public
PageVO
<
MarkFlowEntity
>
getYuqingMarkList
(
MarkSearchDTO
markSearchDTO
)
{
try
{
...
...
@@ -504,12 +507,13 @@ public class MarkDataServiceImpl implements MarkDataService {
log
.
info
(
"es查询size:{},耗时:{}"
,
texts
.
size
(),
System
.
currentTimeMillis
()
-
s
);
long
s1
=
System
.
currentTimeMillis
();
// 分析高频词
List
<
JSONObject
>
highWords
=
T
extUtil
.
getHighWordsJson
(
texts
,
30
);
List
<
JSONObject
>
highWords
=
t
extUtil
.
getHighWordsJson
(
texts
,
30
);
log
.
info
(
"分析高频词耗时:{}"
,
(
System
.
currentTimeMillis
()
-
s1
));
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
highWords
));
return
highWords
;
}
catch
(
IOException
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"es查询异常"
,
e
);
log
.
error
(
"getMarkHighWord-"
,
e
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
);
}
return
null
;
}
...
...
src/main/java/com/zhiwei/brandkbs2/util/TextUtil.java
View file @
d300091b
...
...
@@ -15,6 +15,7 @@ import com.zhiwei.nlp.vo.KResult;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.elasticsearch.search.SearchHit
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.Resource
;
import
org.springframework.stereotype.Component
;
...
...
@@ -39,7 +40,8 @@ public class TextUtil {
private
Resource
customDic
;
@Value
(
"classpath:wordDic/stopWordDictionary.txt"
)
private
Resource
stopDic
;
private
static
AnsjSeg
ansjSeg
;
@Autowired
private
AnsjSeg
ansjSeg
;
@PostConstruct
public
void
init
()
{
...
...
@@ -105,7 +107,7 @@ public class TextUtil {
return
Tools
.
sortMap
(
result
,
maxSize
);
}
public
static
List
<
JSONObject
>
getHighWordsJson
(
List
<
String
>
texts
,
Integer
maxSize
)
{
public
List
<
JSONObject
>
getHighWordsJson
(
List
<
String
>
texts
,
Integer
maxSize
)
{
// Map<String, Integer> highWords = getHighWords(texts, maxSize);
List
<
Map
.
Entry
<
String
,
Integer
>>
wordRate
=
ansjSeg
.
getFenCi
(
texts
,
maxSize
);
List
<
JSONObject
>
result
=
new
ArrayList
<>(
wordRate
.
size
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment