From 3ee5a70fa646ae0c1e94aa95b7fbd78326881101 Mon Sep 17 00:00:00 2001 From: redhong-xy <13591594+redhong-xy@user.noreply.gitee.com> Date: Tue, 2 Jul 2024 20:41:09 +0800 Subject: [PATCH 1/4] hong --- .idea/.gitignore | 5 +++++ .idea/Weibo_PublicOpinion_AnalysisSystem.iml | 19 +++++++++++++++++++ .idea/inspectionProfiles/Project_Default.xml | 17 +++++++++++++++++ .../inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 7 +++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ model/cipingTotal.py | 0 model/sentiment.marshal.3.py | 0 9 files changed, 68 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Weibo_PublicOpinion_AnalysisSystem.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 model/cipingTotal.py create mode 100644 model/sentiment.marshal.3.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/Weibo_PublicOpinion_AnalysisSystem.iml b/.idea/Weibo_PublicOpinion_AnalysisSystem.iml new file mode 100644 index 0000000..a4e9024 --- /dev/null +++ b/.idea/Weibo_PublicOpinion_AnalysisSystem.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..b8ef0fa --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..31a993c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b4049e4 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/model/cipingTotal.py b/model/cipingTotal.py new file mode 100644 index 0000000..e69de29 diff --git a/model/sentiment.marshal.3.py b/model/sentiment.marshal.3.py new file mode 100644 index 0000000..e69de29 From 46bbc003172314ec5ff2255fd619dbb22fdc859f Mon Sep 17 00:00:00 2001 From: juanboy <2980526980@qq.com> Date: Tue, 2 Jul 2024 20:49:26 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E3=80=90getTableData.py=E3=80=91=E6=83=85?= =?UTF-8?q?=E6=84=9F=E5=88=86=E6=9E=90=E6=8E=A5=E7=AE=A1=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84=E5=87=BD=E6=95=B0=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/getEchartsData.py | 56 +++++++++++++++++++++++++++++++++++++++++ utils/getTableData.py | 21 ++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 utils/getTableData.py diff --git a/utils/getEchartsData.py b/utils/getEchartsData.py index f4a3cde..771e1be 100644 --- a/utils/getEchartsData.py +++ b/utils/getEchartsData.py @@ -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 + diff --git a/utils/getTableData.py b/utils/getTableData.py new file mode 100644 index 0000000..87c4824 --- /dev/null +++ b/utils/getTableData.py @@ -0,0 +1,21 @@ +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 From ceb9d6b137a3f2554788f6358a69c236963e283f Mon Sep 17 00:00:00 2001 From: redhong-xy <13591594+redhong-xy@user.noreply.gitee.com> Date: Tue, 2 Jul 2024 20:51:57 +0800 Subject: [PATCH 3/4] hong --- model/cutComments.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 model/cutComments.py diff --git a/model/cutComments.py b/model/cutComments.py new file mode 100644 index 0000000..e69de29 From ca357b2ff13c536b17e0190ec73c48caaeb7c47e Mon Sep 17 00:00:00 2001 From: juanboy <2980526980@qq.com> Date: Tue, 2 Jul 2024 20:54:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/cipingTotal.py | 0 model/cutComments.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 model/cipingTotal.py delete mode 100644 model/cutComments.py diff --git a/model/cipingTotal.py b/model/cipingTotal.py deleted file mode 100644 index e69de29..0000000 diff --git a/model/cutComments.py b/model/cutComments.py deleted file mode 100644 index e69de29..0000000