YYL469

Merge branch 'main' of github.com:666ghj/Weibo_PublicOpinion_AnalysisSystem

# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
... ...
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="Flask">
<option name="enabled" value="true" />
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/templates" />
</list>
</option>
</component>
</module>
\ No newline at end of file
... ...
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
</list>
</option>
</inspection_tool>
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
... ...
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.12 (Desktop)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (Desktop)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Weibo_PublicOpinion_AnalysisSystem.iml" filepath="$PROJECT_DIR$/.idea/Weibo_PublicOpinion_AnalysisSystem.iml" />
</modules>
</component>
</project>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
... ...
... ... @@ -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
... ...
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
... ...