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