Merge branch 'main' of github.com:666ghj/Weibo_PublicOpinion_AnalysisSystem
Showing
10 changed files
with
145 additions
and
0 deletions
.idea/.gitignore
0 → 100644
.idea/Weibo_PublicOpinion_AnalysisSystem.iml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<module type="PYTHON_MODULE" version="4"> | ||
| 3 | + <component name="Flask"> | ||
| 4 | + <option name="enabled" value="true" /> | ||
| 5 | + </component> | ||
| 6 | + <component name="NewModuleRootManager"> | ||
| 7 | + <content url="file://$MODULE_DIR$" /> | ||
| 8 | + <orderEntry type="inheritedJdk" /> | ||
| 9 | + <orderEntry type="sourceFolder" forTests="false" /> | ||
| 10 | + </component> | ||
| 11 | + <component name="TemplatesService"> | ||
| 12 | + <option name="TEMPLATE_CONFIGURATION" value="Jinja2" /> | ||
| 13 | + <option name="TEMPLATE_FOLDERS"> | ||
| 14 | + <list> | ||
| 15 | + <option value="$MODULE_DIR$/templates" /> | ||
| 16 | + </list> | ||
| 17 | + </option> | ||
| 18 | + </component> | ||
| 19 | +</module> |
.idea/inspectionProfiles/Project_Default.xml
0 → 100644
| 1 | +<component name="InspectionProjectProfileManager"> | ||
| 2 | + <profile version="1.0"> | ||
| 3 | + <option name="myName" value="Project Default" /> | ||
| 4 | + <inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true"> | ||
| 5 | + <option name="ignoredErrors"> | ||
| 6 | + <list> | ||
| 7 | + <option value="N802" /> | ||
| 8 | + </list> | ||
| 9 | + </option> | ||
| 10 | + </inspection_tool> | ||
| 11 | + <inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false"> | ||
| 12 | + <option name="processCode" value="true" /> | ||
| 13 | + <option name="processLiterals" value="true" /> | ||
| 14 | + <option name="processComments" value="true" /> | ||
| 15 | + </inspection_tool> | ||
| 16 | + </profile> | ||
| 17 | +</component> |
.idea/misc.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<project version="4"> | ||
| 3 | + <component name="Black"> | ||
| 4 | + <option name="sdkName" value="Python 3.12 (Desktop)" /> | ||
| 5 | + </component> | ||
| 6 | + <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (Desktop)" project-jdk-type="Python SDK" /> | ||
| 7 | +</project> |
.idea/modules.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<project version="4"> | ||
| 3 | + <component name="ProjectModuleManager"> | ||
| 4 | + <modules> | ||
| 5 | + <module fileurl="file://$PROJECT_DIR$/.idea/Weibo_PublicOpinion_AnalysisSystem.iml" filepath="$PROJECT_DIR$/.idea/Weibo_PublicOpinion_AnalysisSystem.iml" /> | ||
| 6 | + </modules> | ||
| 7 | + </component> | ||
| 8 | +</project> |
.idea/vcs.xml
0 → 100644
model/sentiment.marshal.3.py
0 → 100644
| @@ -152,3 +152,59 @@ def getCommentCharDataTwo():# 统计评论数据中不同性别的数量 | @@ -152,3 +152,59 @@ def getCommentCharDataTwo():# 统计评论数据中不同性别的数量 | ||
| 152 | }) | 152 | }) |
| 153 | return resultData | 153 | return resultData |
| 154 | 154 | ||
| 155 | +def getYuQingCharDataOne():# 统计热词中正面、中性、负面的数量 | ||
| 156 | + hotWordList = getAllHotWords() | ||
| 157 | + xData = ['正面','中性','负面'] | ||
| 158 | + yData = [0,0,0] | ||
| 159 | + for word in hotWordList: | ||
| 160 | + emotionValue = SnowNLP(word[0]).sentiments | ||
| 161 | + if emotionValue > 0.5: | ||
| 162 | + yData[0] += 1 | ||
| 163 | + elif emotionValue == 0.5: | ||
| 164 | + yData[1] += 1 | ||
| 165 | + elif emotionValue < 0.5: | ||
| 166 | + yData[2] += 1 | ||
| 167 | + finalData = [{ | ||
| 168 | + 'name':x, | ||
| 169 | + 'value':yData[index] | ||
| 170 | + } for index,x in enumerate(xData)] | ||
| 171 | + return xData,yData,finalData | ||
| 172 | + | ||
| 173 | +def getYuQingCharDataTwo():# 统计评论列表和文章列表中的情感值 | ||
| 174 | + xData = ['正面', '中性', '负面'] | ||
| 175 | + finalData1 = [{ | ||
| 176 | + 'name':x, | ||
| 177 | + 'value':0 | ||
| 178 | + } for x in xData] | ||
| 179 | + finalData2 = [{ | ||
| 180 | + 'name': x, | ||
| 181 | + 'value': 0 | ||
| 182 | + } for x in xData] | ||
| 183 | + | ||
| 184 | + for comment in commentList: | ||
| 185 | + emotionValue = SnowNLP(comment[4]).sentiments | ||
| 186 | + if emotionValue > 0.5: | ||
| 187 | + finalData1[0]['value'] += 1 | ||
| 188 | + elif emotionValue == 0.5: | ||
| 189 | + finalData1[1]['value'] += 1 | ||
| 190 | + elif emotionValue < 0.5: | ||
| 191 | + finalData1[2]['value'] += 1 | ||
| 192 | + for artile in articleList: | ||
| 193 | + emotionValue = SnowNLP(artile[5]).sentiments | ||
| 194 | + if emotionValue > 0.5: | ||
| 195 | + finalData2[0]['value'] += 1 | ||
| 196 | + elif emotionValue == 0.5: | ||
| 197 | + finalData2[1]['value'] += 1 | ||
| 198 | + elif emotionValue < 0.5: | ||
| 199 | + finalData2[2]['value'] += 1 | ||
| 200 | + return finalData1,finalData2 | ||
| 201 | + | ||
| 202 | +def getYuQingCharDataThree():# 提取前10个热词及其对应的出现频率 | ||
| 203 | + hotWordList = getAllHotWords() | ||
| 204 | + xData = [] | ||
| 205 | + yData = [] | ||
| 206 | + for i in hotWordList[:10]: | ||
| 207 | + xData.append(i[0]) | ||
| 208 | + yData.append(int(i[1])) | ||
| 209 | + return xData,yData | ||
| 210 | + |
utils/getTableData.py
0 → 100644
| 1 | +from utils.getPublicData import getAllArticleData | ||
| 2 | +from snownlp import SnowNLP | ||
| 3 | + | ||
| 4 | +def getTableDataList(flag): | ||
| 5 | + if flag: | ||
| 6 | + tableList = [] | ||
| 7 | + articeList = getAllArticleData() | ||
| 8 | + for article in articeList: | ||
| 9 | + item = list(article) | ||
| 10 | + value = '' | ||
| 11 | + if SnowNLP(item[5]).sentiments > 0.5: | ||
| 12 | + value = '正面' | ||
| 13 | + elif SnowNLP(item[5]).sentiments < 0.5: | ||
| 14 | + value = '负面' | ||
| 15 | + else: | ||
| 16 | + value = '中性' | ||
| 17 | + item.append(value) | ||
| 18 | + tableList.append(item) | ||
| 19 | + return tableList | ||
| 20 | + else: | ||
| 21 | + return getAllArticleData() |
-
Please register or login to post a comment