redhongx

【getEchartsData.py】修改正面/中性/负面的判断值

1 from utils.getPublicData import * 1 from utils.getPublicData import *
2 -from snownlp import SnowNLP 2 +from utils.mynlp import SnowNLP
3 articleList = getAllArticleData() 3 articleList = getAllArticleData()
4 commentList = getAllCommentsData() 4 commentList = getAllCommentsData()
5 5
@@ -157,12 +157,12 @@ def getYuQingCharDataOne(): @@ -157,12 +157,12 @@ def getYuQingCharDataOne():
157 yData = [0,0,0] 157 yData = [0,0,0]
158 for word in hotWordList: 158 for word in hotWordList:
159 emotionValue = SnowNLP(word[0]).sentiments 159 emotionValue = SnowNLP(word[0]).sentiments
160 - if emotionValue > 0.5: 160 + if emotionValue > 0.4:
161 yData[0] += 1 161 yData[0] += 1
162 - elif emotionValue == 0.5:  
163 - yData[1] += 1  
164 - elif emotionValue < 0.5: 162 + elif emotionValue < 0.2:
165 yData[2] += 1 163 yData[2] += 1
  164 + else:
  165 + yData[1] += 1
166 bieData = [{ 166 bieData = [{
167 'name':x, 167 'name':x,
168 'value':yData[index] 168 'value':yData[index]
@@ -182,20 +182,20 @@ def getYuQingCharDataTwo(): @@ -182,20 +182,20 @@ def getYuQingCharDataTwo():
182 182
183 for comment in commentList: 183 for comment in commentList:
184 emotionValue = SnowNLP(comment[4]).sentiments 184 emotionValue = SnowNLP(comment[4]).sentiments
185 - if emotionValue > 0.5: 185 + if emotionValue > 0.4:
186 bieData1[0]['value'] += 1 186 bieData1[0]['value'] += 1
187 - elif emotionValue == 0.5:  
188 - bieData1[1]['value'] += 1  
189 - elif emotionValue < 0.5: 187 + elif emotionValue < 0.2:
190 bieData1[2]['value'] += 1 188 bieData1[2]['value'] += 1
  189 + else:
  190 + bieData1[1]['value'] += 1
191 for artile in articleList: 191 for artile in articleList:
192 emotionValue = SnowNLP(artile[5]).sentiments 192 emotionValue = SnowNLP(artile[5]).sentiments
193 - if emotionValue > 0.5: 193 + if emotionValue > 0.4:
194 bieData2[0]['value'] += 1 194 bieData2[0]['value'] += 1
195 - elif emotionValue == 0.5:  
196 - bieData2[1]['value'] += 1  
197 - elif emotionValue < 0.5: 195 + elif emotionValue < 0.2:
198 bieData2[2]['value'] += 1 196 bieData2[2]['value'] += 1
  197 + else:
  198 + bieData2[1]['value'] += 1
199 return bieData1,bieData2 199 return bieData1,bieData2
200 200
201 def getYuQingCharDataThree(): 201 def getYuQingCharDataThree():