Showing
3 changed files
with
41 additions
and
41 deletions
| @@ -93,14 +93,14 @@ def getArticleRepotsLen(type): | @@ -93,14 +93,14 @@ def getArticleRepotsLen(type): | ||
| 93 | Y[11] += 1 | 93 | Y[11] += 1 |
| 94 | return X,Y | 94 | return X,Y |
| 95 | 95 | ||
| 96 | -def getIPCharByArticleRegion(): | 96 | +def getIPByArticleRegion(): |
| 97 | articleRegionDic = {} | 97 | articleRegionDic = {} |
| 98 | for i in articleList: | 98 | for i in articleList: |
| 99 | if i[4] != '无': | 99 | if i[4] != '无': |
| 100 | - if articleRegionDic.get(i[4],-1) == -1: | ||
| 101 | - articleRegionDic[i[4]] = 1 | ||
| 102 | - else: | 100 | + if i[4] in articleRegionDic.keys(): |
| 103 | articleRegionDic[i[4]] += 1 | 101 | articleRegionDic[i[4]] += 1 |
| 102 | + else: | ||
| 103 | + articleRegionDic[i[4]] = 1 | ||
| 104 | resultData = [] | 104 | resultData = [] |
| 105 | for key,value in articleRegionDic.items(): | 105 | for key,value in articleRegionDic.items(): |
| 106 | resultData.append({ | 106 | resultData.append({ |
| @@ -109,14 +109,14 @@ def getIPCharByArticleRegion(): | @@ -109,14 +109,14 @@ def getIPCharByArticleRegion(): | ||
| 109 | }) | 109 | }) |
| 110 | return resultData | 110 | return resultData |
| 111 | 111 | ||
| 112 | -def getIPCharByCommentsRegion(): | 112 | +def getIPByCommentsRegion(): |
| 113 | commentRegionDic = {} | 113 | commentRegionDic = {} |
| 114 | for i in commentList: | 114 | for i in commentList: |
| 115 | if i[3] != '无': | 115 | if i[3] != '无': |
| 116 | - if commentRegionDic.get(i[3],-1) == -1: | ||
| 117 | - commentRegionDic[i[3]] = 1 | ||
| 118 | - else: | 116 | + if i[3] in commentRegionDic.keys(): |
| 119 | commentRegionDic[i[3]] += 1 | 117 | commentRegionDic[i[3]] += 1 |
| 118 | + else: | ||
| 119 | + commentRegionDic[i[3]] = 1 | ||
| 120 | resultData = [] | 120 | resultData = [] |
| 121 | for key,value in commentRegionDic.items(): | 121 | for key,value in commentRegionDic.items(): |
| 122 | resultData.append({ | 122 | resultData.append({ |
| @@ -163,19 +163,19 @@ def getYuQingCharDataOne(): | @@ -163,19 +163,19 @@ def getYuQingCharDataOne(): | ||
| 163 | Y[2] += 1 | 163 | Y[2] += 1 |
| 164 | else: | 164 | else: |
| 165 | Y[1] += 1 | 165 | Y[1] += 1 |
| 166 | - finaldata = [{ | 166 | + biedata = [{ |
| 167 | 'name':x, | 167 | 'name':x, |
| 168 | 'value':Y[index] | 168 | 'value':Y[index] |
| 169 | } for index,x in enumerate(X)] | 169 | } for index,x in enumerate(X)] |
| 170 | - return X,Y,finaldata | 170 | + return X,Y,biedata |
| 171 | 171 | ||
| 172 | def getYuQingCharDataTwo(): | 172 | def getYuQingCharDataTwo(): |
| 173 | X = ['正面', '中性', '负面'] | 173 | X = ['正面', '中性', '负面'] |
| 174 | - finaldata1 = [{ | 174 | + biedata1 = [{ |
| 175 | 'name':x, | 175 | 'name':x, |
| 176 | 'value':0 | 176 | 'value':0 |
| 177 | } for x in X] | 177 | } for x in X] |
| 178 | - finaldata2 = [{ | 178 | + biedata2 = [{ |
| 179 | 'name': x, | 179 | 'name': x, |
| 180 | 'value': 0 | 180 | 'value': 0 |
| 181 | } for x in X] | 181 | } for x in X] |
| @@ -183,20 +183,20 @@ def getYuQingCharDataTwo(): | @@ -183,20 +183,20 @@ def getYuQingCharDataTwo(): | ||
| 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.4: | 185 | if emotionValue > 0.4: |
| 186 | - finaldata1[0]['value'] += 1 | 186 | + biedata1[0]['value'] += 1 |
| 187 | elif emotionValue < 0.2: | 187 | elif emotionValue < 0.2: |
| 188 | - finaldata1[2]['value'] += 1 | 188 | + biedata1[2]['value'] += 1 |
| 189 | else: | 189 | else: |
| 190 | - finaldata1[1]['value'] += 1 | 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.4: | 193 | if emotionValue > 0.4: |
| 194 | - finaldata2[0]['value'] += 1 | 194 | + biedata2[0]['value'] += 1 |
| 195 | elif emotionValue < 0.2: | 195 | elif emotionValue < 0.2: |
| 196 | - finaldata2[2]['value'] += 1 | 196 | + biedata2[2]['value'] += 1 |
| 197 | else: | 197 | else: |
| 198 | - finaldata2[1]['value'] += 1 | ||
| 199 | - return finaldata1,finaldata2 | 198 | + biedata2[1]['value'] += 1 |
| 199 | + return biedata1,biedata2 | ||
| 200 | 200 | ||
| 201 | def getYuQingCharDataThree(): | 201 | def getYuQingCharDataThree(): |
| 202 | hotWordList = getAllHotWords() | 202 | hotWordList = getAllHotWords() |
| @@ -28,8 +28,8 @@ def home(): | @@ -28,8 +28,8 @@ def home(): | ||
| 28 | likeCountMaxAuthorName=likeCountMaxAuthorName, | 28 | likeCountMaxAuthorName=likeCountMaxAuthorName, |
| 29 | cityMax=cityMax, | 29 | cityMax=cityMax, |
| 30 | commentsLikeCountTopFore=commentsLikeCountTopFore, | 30 | commentsLikeCountTopFore=commentsLikeCountTopFore, |
| 31 | - X=X, | ||
| 32 | - Y=Y, | 31 | + xData=X, |
| 32 | + yData=Y, | ||
| 33 | typeChart=typeChart, | 33 | typeChart=typeChart, |
| 34 | createAtChart=createAtChart) | 34 | createAtChart=createAtChart) |
| 35 | 35 | ||
| @@ -59,8 +59,8 @@ def hotWord(): | @@ -59,8 +59,8 @@ def hotWord(): | ||
| 59 | defaultHotWord=defaultHotWord, | 59 | defaultHotWord=defaultHotWord, |
| 60 | hotWordLen=hotWordLen, | 60 | hotWordLen=hotWordLen, |
| 61 | sentences=sentences, | 61 | sentences=sentences, |
| 62 | - X=X, | ||
| 63 | - Y=Y, | 62 | + xData=X, |
| 63 | + yData=Y, | ||
| 64 | comments=comments) | 64 | comments=comments) |
| 65 | 65 | ||
| 66 | 66 | ||
| @@ -84,8 +84,8 @@ def hotTopic(): | @@ -84,8 +84,8 @@ def hotTopic(): | ||
| 84 | defaultTopic=defaultTopic, | 84 | defaultTopic=defaultTopic, |
| 85 | topicLen=topicLen, | 85 | topicLen=topicLen, |
| 86 | sentences=sentences, | 86 | sentences=sentences, |
| 87 | - X=X, | ||
| 88 | - Y=Y, | 87 | + xData=X, |
| 88 | + yData=Y, | ||
| 89 | comments=comments) | 89 | comments=comments) |
| 90 | 90 | ||
| 91 | 91 | ||
| @@ -114,8 +114,8 @@ def articleChar(): | @@ -114,8 +114,8 @@ def articleChar(): | ||
| 114 | username=username, | 114 | username=username, |
| 115 | typeList=typeList, | 115 | typeList=typeList, |
| 116 | defaultType=defaultType, | 116 | defaultType=defaultType, |
| 117 | - X=X, | ||
| 118 | - Y=Y, | 117 | + xData=X, |
| 118 | + yData=Y, | ||
| 119 | x1Data=x1Data, | 119 | x1Data=x1Data, |
| 120 | y1Data=y1Data, | 120 | y1Data=y1Data, |
| 121 | x2Data=x2Data, | 121 | x2Data=x2Data, |
| @@ -125,8 +125,8 @@ def articleChar(): | @@ -125,8 +125,8 @@ def articleChar(): | ||
| 125 | @pb.route('/ipChar') | 125 | @pb.route('/ipChar') |
| 126 | def ipChar(): | 126 | def ipChar(): |
| 127 | username = session.get('username') | 127 | username = session.get('username') |
| 128 | - articleRegionData = getIPCharByArticleRegion() | ||
| 129 | - commentRegionData = getIPCharByCommentsRegion() | 128 | + articleRegionData = getIPByArticleRegion() |
| 129 | + commentRegionData = getIPByCommentsRegion() | ||
| 130 | return render_template('ipChar.html', | 130 | return render_template('ipChar.html', |
| 131 | username=username, | 131 | username=username, |
| 132 | articleRegionData=articleRegionData, | 132 | articleRegionData=articleRegionData, |
| @@ -140,24 +140,24 @@ def commentChar(): | @@ -140,24 +140,24 @@ def commentChar(): | ||
| 140 | genderPieData = getCommentDataTwo() | 140 | genderPieData = getCommentDataTwo() |
| 141 | return render_template('commentChar.html', | 141 | return render_template('commentChar.html', |
| 142 | username=username, | 142 | username=username, |
| 143 | - X=X, | ||
| 144 | - Y=Y, | 143 | + xData=X, |
| 144 | + yData=Y, | ||
| 145 | genderPieData=genderPieData) | 145 | genderPieData=genderPieData) |
| 146 | 146 | ||
| 147 | 147 | ||
| 148 | @pb.route('/yuqingChar') | 148 | @pb.route('/yuqingChar') |
| 149 | def yuqingChar(): | 149 | def yuqingChar(): |
| 150 | username = session.get('username') | 150 | username = session.get('username') |
| 151 | - X, Y, finaldata = getYuQingCharDataOne() | ||
| 152 | - finaldata1, finaldata2 = getYuQingCharDataTwo() | 151 | + X, Y, biedata = getYuQingCharDataOne() |
| 152 | + biedata1, biedata2 = getYuQingCharDataTwo() | ||
| 153 | x1Data, y1Data = getYuQingCharDataThree() | 153 | x1Data, y1Data = getYuQingCharDataThree() |
| 154 | return render_template('yuqingChar.html', | 154 | return render_template('yuqingChar.html', |
| 155 | username=username, | 155 | username=username, |
| 156 | - X=X, | ||
| 157 | - Y=Y, | ||
| 158 | - finaldata=finaldata, | ||
| 159 | - finaldata1=finaldata1, | ||
| 160 | - finaldata2=finaldata2, | 156 | + xData=X, |
| 157 | + yData=Y, | ||
| 158 | + biedata=biedata, | ||
| 159 | + biedata1=biedata1, | ||
| 160 | + biedata2=biedata2, | ||
| 161 | x1Data=x1Data, | 161 | x1Data=x1Data, |
| 162 | y1Data=y1Data) | 162 | y1Data=y1Data) |
| 163 | 163 |
| @@ -234,7 +234,7 @@ | @@ -234,7 +234,7 @@ | ||
| 234 | series: [ | 234 | series: [ |
| 235 | { | 235 | { |
| 236 | type: 'treemap', | 236 | type: 'treemap', |
| 237 | - data: {{ finaldata | tojson }} | 237 | + data: {{ biedata | tojson }} |
| 238 | } | 238 | } |
| 239 | ] | 239 | ] |
| 240 | }; | 240 | }; |
| @@ -272,7 +272,7 @@ | @@ -272,7 +272,7 @@ | ||
| 272 | labelLine: { | 272 | labelLine: { |
| 273 | show: false | 273 | show: false |
| 274 | }, | 274 | }, |
| 275 | - data: {{ finaldata1 | tojson }} | 275 | + data: {{ biedata1 | tojson }} |
| 276 | }, | 276 | }, |
| 277 | { | 277 | { |
| 278 | name: '文章舆情结果', | 278 | name: '文章舆情结果', |
| @@ -313,7 +313,7 @@ | @@ -313,7 +313,7 @@ | ||
| 313 | } | 313 | } |
| 314 | } | 314 | } |
| 315 | }, | 315 | }, |
| 316 | - data: {{ finaldata2 | tojson }} | 316 | + data: {{ biedata2 | tojson }} |
| 317 | } | 317 | } |
| 318 | ] | 318 | ] |
| 319 | }; | 319 | }; |
-
Please register or login to post a comment