摘虫
This commit is contained in:
+19
-19
@@ -93,14 +93,14 @@ def getArticleRepotsLen(type):
|
||||
Y[11] += 1
|
||||
return X,Y
|
||||
|
||||
def getIPCharByArticleRegion():
|
||||
def getIPByArticleRegion():
|
||||
articleRegionDic = {}
|
||||
for i in articleList:
|
||||
if i[4] != '无':
|
||||
if articleRegionDic.get(i[4],-1) == -1:
|
||||
articleRegionDic[i[4]] = 1
|
||||
else:
|
||||
if i[4] in articleRegionDic.keys():
|
||||
articleRegionDic[i[4]] += 1
|
||||
else:
|
||||
articleRegionDic[i[4]] = 1
|
||||
resultData = []
|
||||
for key,value in articleRegionDic.items():
|
||||
resultData.append({
|
||||
@@ -109,14 +109,14 @@ def getIPCharByArticleRegion():
|
||||
})
|
||||
return resultData
|
||||
|
||||
def getIPCharByCommentsRegion():
|
||||
def getIPByCommentsRegion():
|
||||
commentRegionDic = {}
|
||||
for i in commentList:
|
||||
if i[3] != '无':
|
||||
if commentRegionDic.get(i[3],-1) == -1:
|
||||
commentRegionDic[i[3]] = 1
|
||||
else:
|
||||
if i[3] in commentRegionDic.keys():
|
||||
commentRegionDic[i[3]] += 1
|
||||
else:
|
||||
commentRegionDic[i[3]] = 1
|
||||
resultData = []
|
||||
for key,value in commentRegionDic.items():
|
||||
resultData.append({
|
||||
@@ -163,19 +163,19 @@ def getYuQingCharDataOne():
|
||||
Y[2] += 1
|
||||
else:
|
||||
Y[1] += 1
|
||||
finaldata = [{
|
||||
biedata = [{
|
||||
'name':x,
|
||||
'value':Y[index]
|
||||
} for index,x in enumerate(X)]
|
||||
return X,Y,finaldata
|
||||
return X,Y,biedata
|
||||
|
||||
def getYuQingCharDataTwo():
|
||||
X = ['正面', '中性', '负面']
|
||||
finaldata1 = [{
|
||||
biedata1 = [{
|
||||
'name':x,
|
||||
'value':0
|
||||
} for x in X]
|
||||
finaldata2 = [{
|
||||
biedata2 = [{
|
||||
'name': x,
|
||||
'value': 0
|
||||
} for x in X]
|
||||
@@ -183,20 +183,20 @@ def getYuQingCharDataTwo():
|
||||
for comment in commentList:
|
||||
emotionValue = SnowNLP(comment[4]).sentiments
|
||||
if emotionValue > 0.4:
|
||||
finaldata1[0]['value'] += 1
|
||||
biedata1[0]['value'] += 1
|
||||
elif emotionValue < 0.2:
|
||||
finaldata1[2]['value'] += 1
|
||||
biedata1[2]['value'] += 1
|
||||
else:
|
||||
finaldata1[1]['value'] += 1
|
||||
biedata1[1]['value'] += 1
|
||||
for artile in articleList:
|
||||
emotionValue = SnowNLP(artile[5]).sentiments
|
||||
if emotionValue > 0.4:
|
||||
finaldata2[0]['value'] += 1
|
||||
biedata2[0]['value'] += 1
|
||||
elif emotionValue < 0.2:
|
||||
finaldata2[2]['value'] += 1
|
||||
biedata2[2]['value'] += 1
|
||||
else:
|
||||
finaldata2[1]['value'] += 1
|
||||
return finaldata1,finaldata2
|
||||
biedata2[1]['value'] += 1
|
||||
return biedata1,biedata2
|
||||
|
||||
def getYuQingCharDataThree():
|
||||
hotWordList = getAllHotWords()
|
||||
|
||||
+19
-19
@@ -28,8 +28,8 @@ def home():
|
||||
likeCountMaxAuthorName=likeCountMaxAuthorName,
|
||||
cityMax=cityMax,
|
||||
commentsLikeCountTopFore=commentsLikeCountTopFore,
|
||||
X=X,
|
||||
Y=Y,
|
||||
xData=X,
|
||||
yData=Y,
|
||||
typeChart=typeChart,
|
||||
createAtChart=createAtChart)
|
||||
|
||||
@@ -59,8 +59,8 @@ def hotWord():
|
||||
defaultHotWord=defaultHotWord,
|
||||
hotWordLen=hotWordLen,
|
||||
sentences=sentences,
|
||||
X=X,
|
||||
Y=Y,
|
||||
xData=X,
|
||||
yData=Y,
|
||||
comments=comments)
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@ def hotTopic():
|
||||
defaultTopic=defaultTopic,
|
||||
topicLen=topicLen,
|
||||
sentences=sentences,
|
||||
X=X,
|
||||
Y=Y,
|
||||
xData=X,
|
||||
yData=Y,
|
||||
comments=comments)
|
||||
|
||||
|
||||
@@ -114,8 +114,8 @@ def articleChar():
|
||||
username=username,
|
||||
typeList=typeList,
|
||||
defaultType=defaultType,
|
||||
X=X,
|
||||
Y=Y,
|
||||
xData=X,
|
||||
yData=Y,
|
||||
x1Data=x1Data,
|
||||
y1Data=y1Data,
|
||||
x2Data=x2Data,
|
||||
@@ -125,8 +125,8 @@ def articleChar():
|
||||
@pb.route('/ipChar')
|
||||
def ipChar():
|
||||
username = session.get('username')
|
||||
articleRegionData = getIPCharByArticleRegion()
|
||||
commentRegionData = getIPCharByCommentsRegion()
|
||||
articleRegionData = getIPByArticleRegion()
|
||||
commentRegionData = getIPByCommentsRegion()
|
||||
return render_template('ipChar.html',
|
||||
username=username,
|
||||
articleRegionData=articleRegionData,
|
||||
@@ -140,24 +140,24 @@ def commentChar():
|
||||
genderPieData = getCommentDataTwo()
|
||||
return render_template('commentChar.html',
|
||||
username=username,
|
||||
X=X,
|
||||
Y=Y,
|
||||
xData=X,
|
||||
yData=Y,
|
||||
genderPieData=genderPieData)
|
||||
|
||||
|
||||
@pb.route('/yuqingChar')
|
||||
def yuqingChar():
|
||||
username = session.get('username')
|
||||
X, Y, finaldata = getYuQingCharDataOne()
|
||||
finaldata1, finaldata2 = getYuQingCharDataTwo()
|
||||
X, Y, biedata = getYuQingCharDataOne()
|
||||
biedata1, biedata2 = getYuQingCharDataTwo()
|
||||
x1Data, y1Data = getYuQingCharDataThree()
|
||||
return render_template('yuqingChar.html',
|
||||
username=username,
|
||||
X=X,
|
||||
Y=Y,
|
||||
finaldata=finaldata,
|
||||
finaldata1=finaldata1,
|
||||
finaldata2=finaldata2,
|
||||
xData=X,
|
||||
yData=Y,
|
||||
biedata=biedata,
|
||||
biedata1=biedata1,
|
||||
biedata2=biedata2,
|
||||
x1Data=x1Data,
|
||||
y1Data=y1Data)
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
series: [
|
||||
{
|
||||
type: 'treemap',
|
||||
data: {{ finaldata | tojson }}
|
||||
data: {{ biedata | tojson }}
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -272,7 +272,7 @@
|
||||
labelLine: {
|
||||
show: false
|
||||
},
|
||||
data: {{ finaldata1 | tojson }}
|
||||
data: {{ biedata1 | tojson }}
|
||||
},
|
||||
{
|
||||
name: '文章舆情结果',
|
||||
@@ -313,7 +313,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
data: {{ finaldata2 | tojson }}
|
||||
data: {{ biedata2 | tojson }}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user