Toggle navigation
Toggle navigation
This project
Loading...
Sign in
万朱浩
/
Venue-Ops
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
juanboy
2024-07-02 20:49:26 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
46bbc003172314ec5ff2255fd619dbb22fdc859f
46bbc003
1 parent
d2b2a26a
【getTableData.py】情感分析接管数据的函数定义
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
utils/getEchartsData.py
utils/getTableData.py
utils/getEchartsData.py
View file @
46bbc00
...
...
@@ -152,3 +152,59 @@ def getCommentCharDataTwo():# 统计评论数据中不同性别的数量
})
return
resultData
def
getYuQingCharDataOne
():
# 统计热词中正面、中性、负面的数量
hotWordList
=
getAllHotWords
()
xData
=
[
'正面'
,
'中性'
,
'负面'
]
yData
=
[
0
,
0
,
0
]
for
word
in
hotWordList
:
emotionValue
=
SnowNLP
(
word
[
0
])
.
sentiments
if
emotionValue
>
0.5
:
yData
[
0
]
+=
1
elif
emotionValue
==
0.5
:
yData
[
1
]
+=
1
elif
emotionValue
<
0.5
:
yData
[
2
]
+=
1
finalData
=
[{
'name'
:
x
,
'value'
:
yData
[
index
]
}
for
index
,
x
in
enumerate
(
xData
)]
return
xData
,
yData
,
finalData
def
getYuQingCharDataTwo
():
# 统计评论列表和文章列表中的情感值
xData
=
[
'正面'
,
'中性'
,
'负面'
]
finalData1
=
[{
'name'
:
x
,
'value'
:
0
}
for
x
in
xData
]
finalData2
=
[{
'name'
:
x
,
'value'
:
0
}
for
x
in
xData
]
for
comment
in
commentList
:
emotionValue
=
SnowNLP
(
comment
[
4
])
.
sentiments
if
emotionValue
>
0.5
:
finalData1
[
0
][
'value'
]
+=
1
elif
emotionValue
==
0.5
:
finalData1
[
1
][
'value'
]
+=
1
elif
emotionValue
<
0.5
:
finalData1
[
2
][
'value'
]
+=
1
for
artile
in
articleList
:
emotionValue
=
SnowNLP
(
artile
[
5
])
.
sentiments
if
emotionValue
>
0.5
:
finalData2
[
0
][
'value'
]
+=
1
elif
emotionValue
==
0.5
:
finalData2
[
1
][
'value'
]
+=
1
elif
emotionValue
<
0.5
:
finalData2
[
2
][
'value'
]
+=
1
return
finalData1
,
finalData2
def
getYuQingCharDataThree
():
# 提取前10个热词及其对应的出现频率
hotWordList
=
getAllHotWords
()
xData
=
[]
yData
=
[]
for
i
in
hotWordList
[:
10
]:
xData
.
append
(
i
[
0
])
yData
.
append
(
int
(
i
[
1
]))
return
xData
,
yData
...
...
utils/getTableData.py
0 → 100644
View file @
46bbc00
from
utils.getPublicData
import
getAllArticleData
from
snownlp
import
SnowNLP
def
getTableDataList
(
flag
):
if
flag
:
tableList
=
[]
articeList
=
getAllArticleData
()
for
article
in
articeList
:
item
=
list
(
article
)
value
=
''
if
SnowNLP
(
item
[
5
])
.
sentiments
>
0.5
:
value
=
'正面'
elif
SnowNLP
(
item
[
5
])
.
sentiments
<
0.5
:
value
=
'负面'
else
:
value
=
'中性'
item
.
append
(
value
)
tableList
.
append
(
item
)
return
tableList
else
:
return
getAllArticleData
()
\ No newline at end of file
...
...
Please
register
or
login
to post a comment