├── .gitattributes
├── .ipynb_checkpoints
└── 谣言检测-checkpoint.ipynb
├── LSTM_rumor_model_58.h5
├── README.md
├── weibo_Vue
├── LICENSE
├── babel.config.js
├── package.json
├── public
│ ├── .DS_Store
│ ├── background.jpg
│ ├── background.png
│ ├── css
│ │ ├── animate.min.css
│ │ ├── icon.css
│ │ └── shake.css
│ ├── favicon2.ico
│ ├── index.html
│ ├── js
│ │ ├── axios.min.js
│ │ ├── bootstrap.bundle.js
│ │ ├── bootstrap.bundle.js.map
│ │ ├── bootstrap.bundle.min.js
│ │ ├── bootstrap.bundle.min.js.map
│ │ ├── bootstrap.js
│ │ ├── bootstrap.js.map
│ │ ├── bootstrap.min.js
│ │ ├── bootstrap.min.js.map
│ │ ├── echarts.min.js
│ │ ├── jquery.min.js
│ │ ├── main.js
│ │ ├── marked.js
│ │ ├── star-rating.js
│ │ ├── star-rating.min.js
│ │ └── vue.js
│ ├── manifest.json
│ └── robots.txt
├── src
│ ├── App.vue
│ ├── Login.vue
│ ├── Register.vue
│ ├── api
│ │ ├── article.js
│ │ ├── auth.js
│ │ ├── category.js
│ │ └── comment.js
│ ├── assets
│ │ ├── css
│ │ │ ├── _variable.scss
│ │ │ └── emoji.css
│ │ └── img
│ │ │ ├── article_item_sprite.png
│ │ │ ├── desc.gif
│ │ │ ├── emoji_sprite.png
│ │ │ ├── exit.png
│ │ │ ├── face_logo.png
│ │ │ ├── github.png
│ │ │ ├── heading.jpg
│ │ │ ├── home.png
│ │ │ └── sprite.png
│ ├── components
│ │ ├── commons
│ │ │ ├── button
│ │ │ │ └── BlogButton.vue
│ │ │ ├── checkbox
│ │ │ │ ├── Checkbox.vue
│ │ │ │ └── CheckboxGroup.vue
│ │ │ ├── comment
│ │ │ │ ├── Comment.vue
│ │ │ │ ├── Emoji.vue
│ │ │ │ └── EmojiPanel.vue
│ │ │ ├── dialog
│ │ │ │ └── BlogDialog.vue
│ │ │ ├── divider
│ │ │ │ └── Divider.vue
│ │ │ ├── formItem
│ │ │ │ └── FormItem.vue
│ │ │ ├── input
│ │ │ │ └── BlogInput.vue
│ │ │ ├── message
│ │ │ │ ├── Message.vue
│ │ │ │ └── index.js
│ │ │ ├── pagination
│ │ │ │ └── Pagination.vue
│ │ │ ├── radio
│ │ │ │ ├── Radio.vue
│ │ │ │ └── RadioGroup.vue
│ │ │ ├── tag
│ │ │ │ └── Tag.vue
│ │ │ ├── tagInputer
│ │ │ │ └── TagInputer.vue
│ │ │ └── textUnderline
│ │ │ │ └── TextUnderline.vue
│ │ ├── header
│ │ │ ├── Header.vue
│ │ │ └── children
│ │ │ │ ├── Login.vue
│ │ │ │ └── MenuItem.vue
│ │ └── home
│ │ │ ├── articleItem
│ │ │ ├── ArticleItem.vue
│ │ │ └── SmallArticleItem.vue
│ │ │ └── indexMenu
│ │ │ ├── IndexMenu.vue
│ │ │ └── children
│ │ │ ├── BloggerInfo.vue
│ │ │ ├── MenuItem.vue
│ │ │ ├── ProfileHeading.vue
│ │ │ └── SearchBar.vue
│ ├── directives
│ │ └── vueClickOutSize.js
│ ├── main.js
│ ├── router.js
│ ├── utils
│ │ ├── bus.js
│ │ └── http.js
│ └── views
│ │ ├── ArticleBrowser.vue
│ │ ├── ArticleEdit.vue
│ │ ├── NotFound.vue
│ │ └── navigation
│ │ ├── Layout.vue
│ │ ├── about
│ │ └── About.vue
│ │ ├── comment
│ │ └── Comment.vue
│ │ └── home
│ │ ├── HomeLayout.vue
│ │ ├── Life.vue
│ │ └── Skill.vue
└── vue.config.js
├── weibo_flask
├── .idea
│ ├── .gitignore
│ ├── inspectionProfiles
│ │ ├── Project_Default.xml
│ │ └── profiles_settings.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── weibo_flask.iml
└── app.py
├── 谣言.sql
├── 谣言检测.ipynb
└── 谣言检测.py
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/LSTM_rumor_model_58.h5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/LSTM_rumor_model_58.h5
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WeiboRumorClassify_Vue_Flask
2 | 微博谣言检测, 前端Vue,后端Flask
3 |
4 | 常用停用词来源 https://github.com/goto456/stopwords
5 |
6 | 前端 https://github.com/pppercyWang/twitter-blog-vue
7 |
8 | 谣言数据 https://github.com/thunlp/Chinese_Rumor_Dataset
9 |
10 | 谣言检测 https://github.com/SophiaHanx/RumorDetection
11 |
12 | 词向量 https://github.com/Embedding/Chinese-Word-Vectors
--------------------------------------------------------------------------------
/weibo_Vue/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2018 TeanBlog.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/weibo_Vue/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/app'
4 | ],
5 | "plugins": [
6 | ["import", {
7 | "libraryName": "vant",
8 | "libraryDirectory": "es",
9 | "style": true
10 | }]
11 | ]
12 | }
--------------------------------------------------------------------------------
/weibo_Vue/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "twitter-blog-vue",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "serve": "vue-cli-service serve",
7 | "build": "vue-cli-service build",
8 | "lint": "vue-cli-service lint"
9 | },
10 | "dependencies": {
11 | "axios": "^0.19.2",
12 | "element-ui": "^2.13.2",
13 | "mavon-editor": "^2.7.5",
14 | "vue": "^2.5.17",
15 | "vue-router": "^3.0.7"
16 | },
17 | "devDependencies": {
18 | "@vue/cli-plugin-babel": "^3.9.2",
19 | "@vue/cli-plugin-pwa": "^3.9.0",
20 | "@vue/cli-service": "^3.9.2",
21 | "babel-plugin-import": "^1.12.0",
22 | "bootstrap": "^4.5.0",
23 | "compression-webpack-plugin": "^3.0.1",
24 | "image-webpack-loader": "^6.0.0",
25 | "jquery": "^3.5.1",
26 | "node-sass": "^4.12.0",
27 | "popper.js": "^1.16.1",
28 | "sass-loader": "^7.1.0",
29 | "uglifyjs-webpack-plugin": "^2.2.0",
30 | "vue-template-compiler": "^2.6.10"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/weibo_Vue/public/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/public/.DS_Store
--------------------------------------------------------------------------------
/weibo_Vue/public/background.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/public/background.jpg
--------------------------------------------------------------------------------
/weibo_Vue/public/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/public/background.png
--------------------------------------------------------------------------------
/weibo_Vue/public/css/icon.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'iconfont'; /* project id 1330295 */
3 | src: url('//at.alicdn.com/t/font_1330295_t4p1ey317p.eot');
4 | src: url('//at.alicdn.com/t/font_1330295_t4p1ey317p.eot?#iefix') format('embedded-opentype'),
5 | url('//at.alicdn.com/t/font_1330295_t4p1ey317p.woff2') format('woff2'),
6 | url('//at.alicdn.com/t/font_1330295_t4p1ey317p.woff') format('woff'),
7 | url('//at.alicdn.com/t/font_1330295_t4p1ey317p.ttf') format('truetype'),
8 | url('//at.alicdn.com/t/font_1330295_t4p1ey317p.svg#iconfont') format('svg');
9 | }
10 | .iconfont {
11 | font-family: "iconfont" !important;
12 | font-size: 16px;
13 | font-style: normal;
14 | -webkit-font-smoothing: antialiased;
15 | -moz-osx-font-smoothing: grayscale;
16 | }
17 |
18 | .percy-icon-fangdajing:before {
19 | content: "\e63d";
20 | }
21 |
22 | .percy-icon-guidangxiangmu:before {
23 | content: "\e660";
24 | }
25 |
26 | .percy-icon-Exit:before {
27 | content: "\e6bd";
28 | }
29 |
30 | .percy-icon-fanhui:before {
31 | content: "\e641";
32 | }
33 |
34 | .percy-icon-logout:before {
35 | content: "\e651";
36 | }
37 |
38 | .percy-icon-Positioning:before {
39 | content: "\e736";
40 | }
41 |
42 | .percy-icon-cross-fill:before {
43 | content: "\e619";
44 | }
45 |
--------------------------------------------------------------------------------
/weibo_Vue/public/css/shake.css:
--------------------------------------------------------------------------------
1 | @-webkit-keyframes shaky-slow {
2 | 0% {
3 | -webkit-transform: translate(0px, 0px) rotate(0deg);
4 | }
5 | 2% {
6 | -webkit-transform: translate(-1px, 1.5px) rotate(1.5deg);
7 | }
8 | 4% {
9 | -webkit-transform: translate(1.3px, 0px) rotate(-0.5deg);
10 | }
11 | 6% {
12 | -webkit-transform: translate(1.4px, 1.4px) rotate(-2deg);
13 | }
14 | 8% {
15 | -webkit-transform: translate(-1.3px, -1px) rotate(-1.5deg);
16 | }
17 | 10% {
18 | -webkit-transform: translate(1.4px, 0px) rotate(-2deg);
19 | }
20 | 12% {
21 | -webkit-transform: translate(-1.3px, -1px) rotate(-2deg);
22 | }
23 | 14% {
24 | -webkit-transform: translate(1.5px, 1.3px) rotate(1.5deg);
25 | }
26 | 16% {
27 | -webkit-transform: translate(1.5px, -1.5px) rotate(-1.5deg);
28 | }
29 | 18% {
30 | -webkit-transform: translate(1.3px, -1.3px) rotate(-2deg);
31 | }
32 | 20% {
33 | -webkit-transform: translate(1px, 1px) rotate(-0.5deg);
34 | }
35 | 22% {
36 | -webkit-transform: translate(1.3px, 1.5px) rotate(-2deg);
37 | }
38 | 24% {
39 | -webkit-transform: translate(-1.4px, -1px) rotate(2deg);
40 | }
41 | 26% {
42 | -webkit-transform: translate(1.3px, -1.3px) rotate(0.5deg);
43 | }
44 | 28% {
45 | -webkit-transform: translate(1.6px, -1.6px) rotate(-2deg);
46 | }
47 | 30% {
48 | -webkit-transform: translate(-1.3px, -1.3px) rotate(-1.5deg);
49 | }
50 | 32% {
51 | -webkit-transform: translate(-1px, 0px) rotate(2deg);
52 | }
53 | 34% {
54 | -webkit-transform: translate(1.3px, 1.3px) rotate(-0.5deg);
55 | }
56 | 36% {
57 | -webkit-transform: translate(1.3px, 1.6px) rotate(1.5deg);
58 | }
59 | 38% {
60 | -webkit-transform: translate(1.3px, -1.6px) rotate(1.5deg);
61 | }
62 | 40% {
63 | -webkit-transform: translate(-1.4px, -1px) rotate(-0.5deg);
64 | }
65 | 42% {
66 | -webkit-transform: translate(-1.4px, 1.3px) rotate(-0.5deg);
67 | }
68 | 44% {
69 | -webkit-transform: translate(-1.6px, 1.4px) rotate(0.5deg);
70 | }
71 | 46% {
72 | -webkit-transform: translate(-2.1px, -1.3px) rotate(-0.5deg);
73 | }
74 | 48% {
75 | -webkit-transform: translate(1px, 1.6px) rotate(1.5deg);
76 | }
77 | 50% {
78 | -webkit-transform: translate(1.6px, 1.6px) rotate(1.5deg);
79 | }
80 | 52% {
81 | -webkit-transform: translate(-1.4px, 1.6px) rotate(0.5deg);
82 | }
83 | 54% {
84 | -webkit-transform: translate(1.6px, -1px) rotate(-2deg);
85 | }
86 | 56% {
87 | -webkit-transform: translate(1.3px, -1.6px) rotate(-2deg);
88 | }
89 | 58% {
90 | -webkit-transform: translate(-1.3px, -1.6px) rotate(0.5deg);
91 | }
92 | 60% {
93 | -webkit-transform: translate(1.3px, 1.6px) rotate(-0.5deg);
94 | }
95 | 62% {
96 | -webkit-transform: translate(0px, 0px) rotate(-1.5deg);
97 | }
98 | 64% {
99 | -webkit-transform: translate(-1.6px, -1.6px) rotate(-2deg);
100 | }
101 | 66% {
102 | -webkit-transform: translate(1.6px, -1.6px) rotate(0.5deg);
103 | }
104 | 68% {
105 | -webkit-transform: translate(0px, -1.6px) rotate(-2deg);
106 | }
107 | 70% {
108 | -webkit-transform: translate(-1.6px, 1px) rotate(1.5deg);
109 | }
110 | 72% {
111 | -webkit-transform: translate(-1.6px, 1.6px) rotate(2deg);
112 | }
113 | 74% {
114 | -webkit-transform: translate(1.3px, -1.6px) rotate(-0.5deg);
115 | }
116 | 76% {
117 | -webkit-transform: translate(1.4px, 1px) rotate(-0.5deg);
118 | }
119 | 78% {
120 | -webkit-transform: translate(-1px, 1.4px) rotate(2deg);
121 | }
122 | 80% {
123 | -webkit-transform: translate(1.4px, 1.6px) rotate(2deg);
124 | }
125 | 82% {
126 | -webkit-transform: translate(-1.6px, -1.6px) rotate(-0.5deg);
127 | }
128 | 84% {
129 | -webkit-transform: translate(-1.4px, 1.4px) rotate(-2deg);
130 | }
131 | 86% {
132 | -webkit-transform: translate(1px, 1.4px) rotate(-2deg);
133 | }
134 | 88% {
135 | -webkit-transform: translate(-1.4px, 1.4px) rotate(-1.5deg);
136 | }
137 | 90% {
138 | -webkit-transform: translate(-1.6px, -1.6px) rotate(-2deg);
139 | }
140 | 92% {
141 | -webkit-transform: translate(-1.6px, 1.6px) rotate(2deg);
142 | }
143 | 94% {
144 | -webkit-transform: translate(-1.6px, -1.6px) rotate(-2deg);
145 | }
146 | 96% {
147 | -webkit-transform: translate(-1.4px, 1.3px) rotate(-2deg);
148 | }
149 | 98% {
150 | -webkit-transform: translate(1.3px, 1px) rotate(-0.5deg);
151 | }
152 | }
153 | @keyframes shaky-slow {
154 | 0% {
155 | transform: translate(0px, 0px) rotate(0deg);
156 | }
157 | 2% {
158 | transform: translate(-1px, 1.5px) rotate(1.5deg);
159 | }
160 | 4% {
161 | transform: translate(1.3px, 0px) rotate(-0.5deg);
162 | }
163 | 6% {
164 | transform: translate(1.4px, 1.4px) rotate(-2deg);
165 | }
166 | 8% {
167 | transform: translate(-1.3px, -1px) rotate(-1.5deg);
168 | }
169 | 10% {
170 | transform: translate(1.4px, 0px) rotate(-2deg);
171 | }
172 | 12% {
173 | transform: translate(-1.3px, -1px) rotate(-2deg);
174 | }
175 | 14% {
176 | transform: translate(1.5px, 1.3px) rotate(1.5deg);
177 | }
178 | 16% {
179 | transform: translate(1.5px, -1.5px) rotate(-1.5deg);
180 | }
181 | 18% {
182 | transform: translate(1.3px, -1.3px) rotate(-2deg);
183 | }
184 | 20% {
185 | transform: translate(1px, 1px) rotate(-0.5deg);
186 | }
187 | 22% {
188 | transform: translate(1.3px, 1.5px) rotate(-2deg);
189 | }
190 | 24% {
191 | transform: translate(-1.4px, -1px) rotate(2deg);
192 | }
193 | 26% {
194 | transform: translate(1.3px, -1.3px) rotate(0.5deg);
195 | }
196 | 28% {
197 | transform: translate(1.6px, -1.6px) rotate(-1.5deg);
198 | }
199 | 30% {
200 | transform: translate(-1.3px, -1.3px) rotate(-1.5deg);
201 | }
202 | 32% {
203 | transform: translate(-1px, 0px) rotate(2deg);
204 | }
205 | 34% {
206 | transform: translate(1.3px, 1.3px) rotate(-0.5deg);
207 | }
208 | 36% {
209 | transform: translate(1.3px, 1.6px) rotate(1.5deg);
210 | }
211 | 38% {
212 | transform: translate(1.3px, -1.6px) rotate(1.5deg);
213 | }
214 | 40% {
215 | transform: translate(-1.4px, -1px) rotate(-0.5deg);
216 | }
217 | 42% {
218 | transform: translate(-1.4px, 1.3px) rotate(-0.5deg);
219 | }
220 | 44% {
221 | transform: translate(-1.6px, 1.4px) rotate(0.5deg);
222 | }
223 | 46% {
224 | transform: translate(-2.1px, -1.3px) rotate(-0.5deg);
225 | }
226 | 48% {
227 | transform: translate(1px, 1.6px) rotate(1.5deg);
228 | }
229 | 50% {
230 | transform: translate(1.6px, 1.6px) rotate(1.5deg);
231 | }
232 | 52% {
233 | transform: translate(-1.4px, 1.6px) rotate(0.5deg);
234 | }
235 | 54% {
236 | transform: translate(1.6px, -1px) rotate(-2deg);
237 | }
238 | 56% {
239 | transform: translate(1.3px, -1.6px) rotate(-2deg);
240 | }
241 | 58% {
242 | transform: translate(-1.3px, -1.6px) rotate(0.5deg);
243 | }
244 | 60% {
245 | transform: translate(1.3px, 1.6px) rotate(-0.5deg);
246 | }
247 | 62% {
248 | transform: translate(0px, 0px) rotate(-1.5deg);
249 | }
250 | 64% {
251 | transform: translate(-1.6px, -1.6px) rotate(-2deg);
252 | }
253 | 66% {
254 | transform: translate(1.6px, -1.6px) rotate(0.5deg);
255 | }
256 | 68% {
257 | transform: translate(0px, -1.6px) rotate(-2deg);
258 | }
259 | 70% {
260 | transform: translate(-1.6px, 1px) rotate(1.5deg);
261 | }
262 | 72% {
263 | transform: translate(-1.6px, 1.6px) rotate(2deg);
264 | }
265 | 74% {
266 | transform: translate(1.3px, -1.6px) rotate(-0.5deg);
267 | }
268 | 76% {
269 | transform: translate(1.4px, 1px) rotate(-0.5deg);
270 | }
271 | 78% {
272 | transform: translate(-1px, 1.4px) rotate(2deg);
273 | }
274 | 80% {
275 | transform: translate(1.4px, 1.6px) rotate(2deg);
276 | }
277 | 82% {
278 | transform: translate(-1.6px, -1.6px) rotate(-0.5deg);
279 | }
280 | 84% {
281 | transform: translate(-1.4px, 1.4px) rotate(-2deg);
282 | }
283 | 86% {
284 | transform: translate(1px, 1.4px) rotate(-2deg);
285 | }
286 | 88% {
287 | transform: translate(-1.4px, 1.4px) rotate(-1.5deg);
288 | }
289 | 90% {
290 | transform: translate(-1.6px, -1.6px) rotate(-2deg);
291 | }
292 | 92% {
293 | transform: translate(-1.4px, 1.6px) rotate(2deg);
294 | }
295 | 94% {
296 | transform: translate(-1.6px, -1.6px) rotate(-2deg);
297 | }
298 | 96% {
299 | transform: translate(-1.4px, 1.3px) rotate(-2deg);
300 | }
301 | 98% {
302 | transform: translate(1.3px, 1px) rotate(-0.5deg);
303 | }
304 | }
--------------------------------------------------------------------------------
/weibo_Vue/public/favicon2.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/public/favicon2.ico
--------------------------------------------------------------------------------
/weibo_Vue/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | zuCc Space
12 |
13 |
14 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/weibo_Vue/public/js/axios.min.js:
--------------------------------------------------------------------------------
1 | /* axios v0.19.0 | (c) 2019 by Matt Zabriskie */
2 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new i(e),n=s(i.prototype.request,t);return o.extend(n,i.prototype,t),o.extend(n,t),n}var o=n(2),s=n(3),i=n(5),a=n(22),u=n(11),c=r(u);c.Axios=i,c.create=function(e){return r(a(c.defaults,e))},c.Cancel=n(23),c.CancelToken=n(24),c.isCancel=n(10),c.all=function(e){return Promise.all(e)},c.spread=n(25),e.exports=c,e.exports.default=c},function(e,t,n){"use strict";function r(e){return"[object Array]"===j.call(e)}function o(e){return"[object ArrayBuffer]"===j.call(e)}function s(e){return"undefined"!=typeof FormData&&e instanceof FormData}function i(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function a(e){return"string"==typeof e}function u(e){return"number"==typeof e}function c(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function p(e){return"[object Date]"===j.call(e)}function d(e){return"[object File]"===j.call(e)}function l(e){return"[object Blob]"===j.call(e)}function h(e){return"[object Function]"===j.call(e)}function m(e){return f(e)&&h(e.pipe)}function y(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function g(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function x(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function v(e,t){if(null!==e&&"undefined"!=typeof e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n
6 | * @license MIT
7 | */
8 | e.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},function(e,t,n){"use strict";function r(e){this.defaults=e,this.interceptors={request:new i,response:new i}}var o=n(2),s=n(6),i=n(7),a=n(8),u=n(22);r.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=u(this.defaults,e),e.method=e.method?e.method.toLowerCase():"get";var t=[a,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},r.prototype.getUri=function(e){return e=u(this.defaults,e),s(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},o.forEach(["delete","get","head","options"],function(e){r.prototype[e]=function(t,n){return this.request(o.merge(n||{},{method:e,url:t}))}}),o.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(o.merge(r||{},{method:e,url:t,data:n}))}}),e.exports=r},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(2);e.exports=function(e,t,n){if(!t)return e;var s;if(n)s=n(t);else if(o.isURLSearchParams(t))s=t.toString();else{var i=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)?t+="[]":e=[e],o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),i.push(r(t)+"="+r(e))}))}),s=i.join("&")}if(s){var a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}},function(e,t,n){"use strict";function r(){this.handlers=[]}var o=n(2);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t,n){"use strict";function r(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var o=n(2),s=n(9),i=n(10),a=n(11),u=n(20),c=n(21);e.exports=function(e){r(e),e.baseURL&&!u(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=s(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=e.adapter||a.adapter;return t(e).then(function(t){return r(e),t.data=s(t.data,t.headers,e.transformResponse),t},function(t){return i(t)||(r(e),t&&t.response&&(t.response.data=s(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function r(e,t){!s.isUndefined(e)&&s.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}function o(){var e;return"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)?e=n(13):"undefined"!=typeof XMLHttpRequest&&(e=n(13)),e}var s=n(2),i=n(12),a={"Content-Type":"application/x-www-form-urlencoded"},u={adapter:o(),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),s.isFormData(e)||s.isArrayBuffer(e)||s.isBuffer(e)||s.isStream(e)||s.isFile(e)||s.isBlob(e)?e:s.isArrayBufferView(e)?e.buffer:s.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):s.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},s.forEach(["delete","get","head"],function(e){u.headers[e]={}}),s.forEach(["post","put","patch"],function(e){u.headers[e]=s.merge(a)}),e.exports=u},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(14),s=n(6),i=n(17),a=n(18),u=n(15);e.exports=function(e){return new Promise(function(t,c){var f=e.data,p=e.headers;r.isFormData(f)&&delete p["Content-Type"];var d=new XMLHttpRequest;if(e.auth){var l=e.auth.username||"",h=e.auth.password||"";p.Authorization="Basic "+btoa(l+":"+h)}if(d.open(e.method.toUpperCase(),s(e.url,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,d.onreadystatechange=function(){if(d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in d?i(d.getAllResponseHeaders()):null,r=e.responseType&&"text"!==e.responseType?d.response:d.responseText,s={data:r,status:d.status,statusText:d.statusText,headers:n,config:e,request:d};o(t,c,s),d=null}},d.onabort=function(){d&&(c(u("Request aborted",e,"ECONNABORTED",d)),d=null)},d.onerror=function(){c(u("Network Error",e,null,d)),d=null},d.ontimeout=function(){c(u("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",d)),d=null},r.isStandardBrowserEnv()){var m=n(19),y=(e.withCredentials||a(e.url))&&e.xsrfCookieName?m.read(e.xsrfCookieName):void 0;y&&(p[e.xsrfHeaderName]=y)}if("setRequestHeader"in d&&r.forEach(p,function(e,t){"undefined"==typeof f&&"content-type"===t.toLowerCase()?delete p[t]:d.setRequestHeader(t,e)}),e.withCredentials&&(d.withCredentials=!0),e.responseType)try{d.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&d.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){d&&(d.abort(),c(e),d=null)}),void 0===f&&(f=null),d.send(f)})}},function(e,t,n){"use strict";var r=n(15);e.exports=function(e,t,n){var o=n.config.validateStatus;!o||o(n.status)?e(n):t(r("Request failed with status code "+n.status,n.config,null,n.request,n))}},function(e,t,n){"use strict";var r=n(16);e.exports=function(e,t,n,o,s){var i=new Error(e);return r(i,t,n,o,s)}},function(e,t){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,n){"use strict";var r=n(2),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,s,i={};return e?(r.forEach(e.split("\n"),function(e){if(s=e.indexOf(":"),t=r.trim(e.substr(0,s)).toLowerCase(),n=r.trim(e.substr(s+1)),t){if(i[t]&&o.indexOf(t)>=0)return;"set-cookie"===t?i[t]=(i[t]?i[t]:[]).concat([n]):i[t]=i[t]?i[t]+", "+n:n}}),i):i}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,s,i){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(s)&&a.push("domain="+s),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){t=t||{};var n={};return r.forEach(["url","method","params","data"],function(e){"undefined"!=typeof t[e]&&(n[e]=t[e])}),r.forEach(["headers","auth","proxy"],function(o){r.isObject(t[o])?n[o]=r.deepMerge(e[o],t[o]):"undefined"!=typeof t[o]?n[o]=t[o]:r.isObject(e[o])?n[o]=r.deepMerge(e[o]):"undefined"!=typeof e[o]&&(n[o]=e[o])}),r.forEach(["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"],function(r){"undefined"!=typeof t[r]?n[r]=t[r]:"undefined"!=typeof e[r]&&(n[r]=e[r])}),n}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(23);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])});
9 | //# sourceMappingURL=axios.min.map
--------------------------------------------------------------------------------
/weibo_Vue/public/js/main.js:
--------------------------------------------------------------------------------
1 |
2 | $('#container').on('click','.bar6 form>button',function () {
3 | // $('#container .bar6 form>button').click(function () {
4 | var $key=$('#container .bar6 form input').val();
5 | var datas = {
6 | content:$key
7 | };
8 | console.log(datas);
9 | $.ajax({
10 | // url: 'http://192.168.31.158:5000/predict',
11 | url: 'http://127.0.0.1:5000/classify',
12 | type: 'post',
13 | dataType: 'json',
14 | data: datas,
15 | success: function (data) {
16 | // console.log(data);
17 | // var str='分类结果出错啦'
18 | // if(data.prediction=='2')
19 | // str='这是一条正向的评论';
20 | // else if(data.prediction=='1')
21 | // str='这是一条中肯的评论';
22 | // else if(data.prediction=='0')
23 | // str='这是一条负向的评论';
24 | $('#result2').html(data.prediction);
25 | }
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/weibo_Vue/public/js/star-rating.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * bootstrap-star-rating v4.0.6
3 | * http://plugins.krajee.com/star-rating
4 | *
5 | * Author: Kartik Visweswaran
6 | * Copyright: 2013 - 2019, Kartik Visweswaran, Krajee.com
7 | *
8 | * Licensed under the BSD 3-Clause
9 | * https://github.com/kartik-v/bootstrap-star-rating/blob/master/LICENSE.md
10 | */
11 | !function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):e(window.jQuery)}(function(e){"use strict";e.fn.ratingLocales={},e.fn.ratingThemes={};var t,a;t={NAMESPACE:".rating",DEFAULT_MIN:0,DEFAULT_MAX:5,DEFAULT_STEP:.5,isEmpty:function(t,a){return null===t||void 0===t||0===t.length||a&&""===e.trim(t)},getCss:function(e,t){return e?" "+t:""},addCss:function(e,t){e.removeClass(t).addClass(t)},getDecimalPlaces:function(e){var t=(""+e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0},applyPrecision:function(e,t){return parseFloat(e.toFixed(t))},handler:function(e,a,n,i,r){var l=r?a:a.split(" ").join(t.NAMESPACE+" ")+t.NAMESPACE;i||e.off(l),e.on(l,n)}},a=function(t,a){var n=this;n.$element=e(t),n._init(a)},a.prototype={constructor:a,_parseAttr:function(e,a){var n,i,r,l,s=this,o=s.$element,c=o.attr("type");if("range"===c||"number"===c){switch(i=a[e]||o.data(e)||o.attr(e),e){case"min":r=t.DEFAULT_MIN;break;case"max":r=t.DEFAULT_MAX;break;default:r=t.DEFAULT_STEP}n=t.isEmpty(i)?r:i,l=parseFloat(n)}else l=parseFloat(a[e]);return isNaN(l)?r:l},_parseValue:function(e){var t=this,a=parseFloat(e);return isNaN(a)&&(a=t.clearValue),!t.zeroAsNull||0!==a&&"0"!==a?a:null},_setDefault:function(e,a){var n=this;t.isEmpty(n[e])&&(n[e]=a)},_initSlider:function(e){var a=this,n=a.$element.val();a.initialValue=t.isEmpty(n)?0:n,a._setDefault("min",a._parseAttr("min",e)),a._setDefault("max",a._parseAttr("max",e)),a._setDefault("step",a._parseAttr("step",e)),(isNaN(a.min)||t.isEmpty(a.min))&&(a.min=t.DEFAULT_MIN),(isNaN(a.max)||t.isEmpty(a.max))&&(a.max=t.DEFAULT_MAX),(isNaN(a.step)||t.isEmpty(a.step)||0===a.step)&&(a.step=t.DEFAULT_STEP),a.diff=a.max-a.min},_initHighlight:function(e){var t,a=this,n=a._getCaption();e||(e=a.$element.val()),t=a.getWidthFromValue(e)+"%",a.$filledStars.width(t),a.cache={caption:n,width:t,val:e}},_getContainerCss:function(){var e=this;return"rating-container"+t.getCss(e.theme,"theme-"+e.theme)+t.getCss(e.rtl,"rating-rtl")+t.getCss(e.size,"rating-"+e.size)+t.getCss(e.animate,"rating-animate")+t.getCss(e.disabled||e.readonly,"rating-disabled")+t.getCss(e.containerClass,e.containerClass)+(e.displayOnly?" is-display-only":"")},_checkDisabled:function(){var e=this,t=e.$element,a=e.options;e.disabled=void 0===a.disabled?t.attr("disabled")||!1:a.disabled,e.readonly=void 0===a.readonly?t.attr("readonly")||!1:a.readonly,e.inactive=e.disabled||e.readonly,t.attr({disabled:e.disabled,readonly:e.readonly})},_addContent:function(e,t){var a=this,n=a.$container,i="clear"===e;return a.rtl?i?n.append(t):n.prepend(t):i?n.prepend(t):n.append(t)},_generateRating:function(){var a,n,i,r=this,l=r.$element;n=r.$container=e(document.createElement("div")).insertBefore(l),t.addCss(n,r._getContainerCss()),r.$rating=a=e(document.createElement("div")).attr("class","rating-stars").appendTo(n).append(r._getStars("empty")).append(r._getStars("filled")),r.$emptyStars=a.find(".empty-stars"),r.$filledStars=a.find(".filled-stars"),r._renderCaption(),r._renderClear(),r._initHighlight(),r._initCaptionTitle(),n.append(l),r.rtl&&(i=Math.max(r.$emptyStars.outerWidth(),r.$filledStars.outerWidth()),r.$emptyStars.width(i)),l.appendTo(a)},_getCaption:function(){var e=this;return e.$caption&&e.$caption.length?e.$caption.html():e.defaultCaption},_setCaption:function(e){var t=this;t.$caption&&t.$caption.length&&t.$caption.html(e)},_renderCaption:function(){var a,n=this,i=n.$element.val(),r=n.captionElement?e(n.captionElement):"";if(n.showCaption){if(a=n.fetchCaption(i),r&&r.length)return t.addCss(r,"caption"),r.html(a),void(n.$caption=r);n._addContent("caption",''+a+"
"),n.$caption=n.$container.find(".caption")}},_renderClear:function(){var a,n=this,i=n.clearElement?e(n.clearElement):"";if(n.showClear){if(a=n._getClearClass(),i.length)return t.addCss(i,a),i.attr({title:n.clearButtonTitle}).html(n.clearButton),void(n.$clear=i);n._addContent("clear",''+n.clearButton+"
"),n.$clear=n.$container.find("."+n.clearButtonBaseClass)}},_getClearClass:function(){var e=this;return e.clearButtonBaseClass+" "+(e.inactive?"":e.clearButtonActiveClass)},_toggleHover:function(e){var t,a,n,i=this;e&&(i.hoverChangeStars&&(t=i.getWidthFromValue(i.clearValue),a=e.val<=i.clearValue?t+"%":e.width,i.$filledStars.css("width",a)),i.hoverChangeCaption&&(n=e.val<=i.clearValue?i.fetchCaption(i.clearValue):e.caption,n&&i._setCaption(n+"")))},_init:function(t){var a,n=this,i=n.$element.addClass("rating-input");return n.options=t,e.each(t,function(e,t){n[e]=t}),(n.rtl||"rtl"===i.attr("dir"))&&(n.rtl=!0,i.attr("dir","rtl")),n.starClicked=!1,n.clearClicked=!1,n._initSlider(t),n._checkDisabled(),n.displayOnly&&(n.inactive=!0,n.showClear=!1,n.hoverEnabled=!1,n.hoverChangeCaption=!1,n.hoverChangeStars=!1),n._generateRating(),n._initEvents(),n._listen(),a=n._parseValue(i.val()),i.val(a),i.removeClass("rating-loading")},_initCaptionTitle:function(){var t,a=this;a.showCaptionAsTitle&&(t=a.fetchCaption(a.$element.val()),a.$rating.attr("title",e(t).text()))},_trigChange:function(e){var t=this;t._initCaptionTitle(),t.$element.trigger("change").trigger("rating:change",e)},_initEvents:function(){var e=this;e.events={_getTouchPosition:function(a){var n=t.isEmpty(a.pageX)?a.originalEvent.touches[0].pageX:a.pageX;return n-e.$rating.offset().left},_listenClick:function(e,t){return e.stopPropagation(),e.preventDefault(),e.handled===!0?!1:(t(e),void(e.handled=!0))},_noMouseAction:function(t){return!e.hoverEnabled||e.inactive||t&&t.isDefaultPrevented()},initTouch:function(a){var n,i,r,l,s,o,c,u,d=e.clearValue||0,p="ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch;p&&!e.inactive&&(n=a.originalEvent,i=t.isEmpty(n.touches)?n.changedTouches:n.touches,r=e.events._getTouchPosition(i[0]),"touchend"===a.type?(e._setStars(r),u=[e.$element.val(),e._getCaption()],e._trigChange(u),e.starClicked=!0):(l=e.calculate(r),s=l.val<=d?e.fetchCaption(d):l.caption,o=e.getWidthFromValue(d),c=l.val<=d?o+"%":l.width,e._setCaption(s),e.$filledStars.css("width",c)))},starClick:function(t){var a,n;e.events._listenClick(t,function(t){return e.inactive?!1:(a=e.events._getTouchPosition(t),e._setStars(a),n=[e.$element.val(),e._getCaption()],e._trigChange(n),void(e.starClicked=!0))})},clearClick:function(t){e.events._listenClick(t,function(){e.inactive||(e.clear(),e.clearClicked=!0)})},starMouseMove:function(t){var a,n;e.events._noMouseAction(t)||(e.starClicked=!1,a=e.events._getTouchPosition(t),n=e.calculate(a),e._toggleHover(n),e.$element.trigger("rating:hover",[n.val,n.caption,"stars"]))},starMouseLeave:function(t){var a;e.events._noMouseAction(t)||e.starClicked||(a=e.cache,e._toggleHover(a),e.$element.trigger("rating:hoverleave",["stars"]))},clearMouseMove:function(t){var a,n,i,r;!e.events._noMouseAction(t)&&e.hoverOnClear&&(e.clearClicked=!1,a=''+e.clearCaption+"",n=e.clearValue,i=e.getWidthFromValue(n)||0,r={caption:a,width:i,val:n},e._toggleHover(r),e.$element.trigger("rating:hover",[n,a,"clear"]))},clearMouseLeave:function(t){var a;e.events._noMouseAction(t)||e.clearClicked||!e.hoverOnClear||(a=e.cache,e._toggleHover(a),e.$element.trigger("rating:hoverleave",["clear"]))},resetForm:function(t){t&&t.isDefaultPrevented()||e.inactive||e.reset()}}},_listen:function(){var a=this,n=a.$element,i=n.closest("form"),r=a.$rating,l=a.$clear,s=a.events;return t.handler(r,"touchstart touchmove touchend",e.proxy(s.initTouch,a)),t.handler(r,"click touchstart",e.proxy(s.starClick,a)),t.handler(r,"mousemove",e.proxy(s.starMouseMove,a)),t.handler(r,"mouseleave",e.proxy(s.starMouseLeave,a)),a.showClear&&l.length&&(t.handler(l,"click touchstart",e.proxy(s.clearClick,a)),t.handler(l,"mousemove",e.proxy(s.clearMouseMove,a)),t.handler(l,"mouseleave",e.proxy(s.clearMouseLeave,a))),i.length&&t.handler(i,"reset",e.proxy(s.resetForm,a),!0),n},_getStars:function(e){var t,a=this,n='';for(t=1;t<=a.stars;t++)n+=''+a[e+"Star"]+"";return n+""},_setStars:function(e){var t=this,a=arguments.length?t.calculate(e):t.calculate(),n=t.$element,i=t._parseValue(a.val);return n.val(i),t.$filledStars.css("width",a.width),t._setCaption(a.caption),t.cache=a,n},showStars:function(e){var t=this,a=t._parseValue(e);return t.$element.val(a),t._initCaptionTitle(),t._setStars()},calculate:function(e){var a=this,n=t.isEmpty(a.$element.val())?0:a.$element.val(),i=arguments.length?a.getValueFromPosition(e):n,r=a.fetchCaption(i),l=a.getWidthFromValue(i);return l+="%",{caption:r,width:l,val:i}},getValueFromPosition:function(e){var a,n,i=this,r=t.getDecimalPlaces(i.step),l=i.$rating.width();return n=i.diff*e/(l*i.step),n=i.rtl?Math.floor(n):Math.ceil(n),a=t.applyPrecision(parseFloat(i.min+n*i.step),r),a=Math.max(Math.min(a,i.max),i.min),i.rtl?i.max-a:a},getWidthFromValue:function(e){var t,a,n=this,i=n.min,r=n.max,l=n.$emptyStars;return!e||i>=e||i===r?0:(a=l.outerWidth(),t=a?l.width()/a:1,e>=r?100:(e-i)*t*100/(r-i))},fetchCaption:function(e){var a,n,i,r,l,s=this,o=parseFloat(e)||s.clearValue,c=s.starCaptions,u=s.starCaptionClasses,d=s.getWidthFromValue(o);return o&&o!==s.clearValue&&(o=t.applyPrecision(o,t.getDecimalPlaces(s.step))),r="function"==typeof u?u(o,d):u[o],i="function"==typeof c?c(o,d):c[o],n=t.isEmpty(i)?s.defaultCaption.replace(/\{rating}/g,o):i,a=t.isEmpty(r)?s.clearCaptionClass:r,l=o===s.clearValue?s.clearCaption:n,''+l+""},destroy:function(){var a=this,n=a.$element;return t.isEmpty(a.$container)||a.$container.before(n).remove(),e.removeData(n.get(0)),n.off("rating").removeClass("rating rating-input")},create:function(e){var t=this,a=e||t.options||{};return t.destroy().rating(a)},clear:function(){var e=this,t=''+e.clearCaption+"";return e.inactive||e._setCaption(t),e.showStars(e.clearValue).trigger("change").trigger("rating:clear")},reset:function(){var e=this;return e.showStars(e.initialValue).trigger("rating:reset")},update:function(e){var t=this;return arguments.length?t.showStars(e):t.$element},refresh:function(t){var a=this,n=a.$element;return t?a.destroy().rating(e.extend(!0,a.options,t)).trigger("rating:refresh"):n}},e.fn.rating=function(n){var i=Array.apply(null,arguments),r=[];switch(i.shift(),this.each(function(){var l,s=e(this),o=s.data("rating"),c="object"==typeof n&&n,u=c.theme||s.data("theme"),d=c.language||s.data("language")||"en",p={},h={};o||(u&&(p=e.fn.ratingThemes[u]||{}),"en"===d||t.isEmpty(e.fn.ratingLocales[d])||(h=e.fn.ratingLocales[d]),l=e.extend(!0,{},e.fn.rating.defaults,p,e.fn.ratingLocales.en,h,c,s.data()),o=new a(this,l),s.data("rating",o)),"string"==typeof n&&r.push(o[n].apply(o,i))}),r.length){case 0:return this;case 1:return void 0===r[0]?this:r[0];default:return r}},e.fn.rating.defaults={theme:"",language:"en",stars:5,filledStar:'',emptyStar:'',containerClass:"",size:"md",animate:!0,displayOnly:!1,rtl:!1,showClear:!0,showCaption:!0,starCaptionClasses:{.5:"label label-danger badge-danger",1:"label label-danger badge-danger",1.5:"label label-warning badge-warning",2:"label label-warning badge-warning",2.5:"label label-info badge-info",3:"label label-info badge-info",3.5:"label label-primary badge-primary",4:"label label-primary badge-primary",4.5:"label label-success badge-success",5:"label label-success badge-success"},clearButton:'',clearButtonBaseClass:"clear-rating",clearButtonActiveClass:"clear-rating-active",clearCaptionClass:"label label-default badge-secondary",clearValue:null,captionElement:null,clearElement:null,showCaptionAsTitle:!0,hoverEnabled:!0,hoverChangeCaption:!0,hoverChangeStars:!0,hoverOnClear:!0,zeroAsNull:!0},e.fn.ratingLocales.en={defaultCaption:"{rating} Stars",starCaptions:{.5:"Half Star",1:"One Star",1.5:"One & Half Star",2:"Two Stars",2.5:"Two & Half Stars",3:"Three Stars",3.5:"Three & Half Stars",4:"Four Stars",4.5:"Four & Half Stars",5:"Five Stars"},clearButtonTitle:"Clear",clearCaption:"Not Rated"},e.fn.rating.Constructor=a,e(document).ready(function(){var t=e("input.rating");t.length&&t.removeClass("rating-loading").addClass("rating-loading").rating()})});
--------------------------------------------------------------------------------
/weibo_Vue/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "twitter-blog-vue",
3 | "short_name": "twitter-blog-vue",
4 | "icons": [
5 | {
6 | "src": "/img/icons/android-chrome-192x192.png",
7 | "sizes": "192x192",
8 | "type": "image/png"
9 | },
10 | {
11 | "src": "/img/icons/android-chrome-512x512.png",
12 | "sizes": "512x512",
13 | "type": "image/png"
14 | }
15 | ],
16 | "start_url": "/index.html",
17 | "display": "standalone",
18 | "background_color": "#000000",
19 | "theme_color": "#4DBA87"
20 | }
21 |
--------------------------------------------------------------------------------
/weibo_Vue/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/weibo_Vue/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
22 |
38 |
--------------------------------------------------------------------------------
/weibo_Vue/src/Login.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 用户登录
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | 登录
19 |
20 |
21 | 注册
26 |
27 |
28 |
29 |
30 |
31 |
87 |
88 |
116 |
--------------------------------------------------------------------------------
/weibo_Vue/src/Register.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 用户注册
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | 注册
24 |
25 |
26 | 返回
31 |
32 |
33 |
34 |
35 |
36 |
91 |
92 |
120 |
--------------------------------------------------------------------------------
/weibo_Vue/src/api/article.js:
--------------------------------------------------------------------------------
1 | import http from '@/utils/http';
2 |
3 | export const apiArticleSave = (data, config) => {
4 | return http.post('article/save', data, config);
5 | };
6 | export const apiArticleList = (data, config) => {
7 | return http.post('article/list', data, config);
8 | };
9 | export const apiAllArticle = (data, config) => {
10 | return http.post('article/allarticle', data, config);
11 | };
12 | export const apiUserCommentList = (data, config) => {
13 | return http.post('article/comment', data, config);
14 | };
15 | export const apiArticleGet = (data, config) => {
16 | return http.post('article/fetch', data, config);
17 | };
18 |
19 | export const apiArticleCount = (data, config) => {
20 | return http.post('article/count', data, config);
21 | };
22 |
23 |
24 |
--------------------------------------------------------------------------------
/weibo_Vue/src/api/auth.js:
--------------------------------------------------------------------------------
1 | import http from '@/utils/http';
2 | export const apiGetUserInfo = (data, config) => {
3 | return http.post('auth/user/info', data, config);
4 | };
5 |
--------------------------------------------------------------------------------
/weibo_Vue/src/api/category.js:
--------------------------------------------------------------------------------
1 | import http from '@/utils/http';
2 | export const apiGetCategoryList = (data, config) => {
3 | return http.post('category/list', data, config);
4 | };
5 | export const apiSaveCategory = (data, config) => {
6 | return http.post('category/save', data, config);
7 | };
8 |
9 |
--------------------------------------------------------------------------------
/weibo_Vue/src/api/comment.js:
--------------------------------------------------------------------------------
1 | import http from '@/utils/http';
2 | export const apiCommentSave = (data, config) => {
3 | return http.post('comment/save', data, config);
4 | };
5 | export const apiCommentList = (data, config) => {
6 | return http.post('comment/list', data, config);
7 | };
8 |
9 |
--------------------------------------------------------------------------------
/weibo_Vue/src/assets/css/_variable.scss:
--------------------------------------------------------------------------------
1 | $twitter-blue: #1da1f2;
2 | $twitter-font: #66757f;
3 | $boder-color: #a4d9f9;
4 | $twitter-font-shallow: #657786;
5 | $button-hover: #e8f5fd;
6 | $backgroud-main: #e6ecf0;
7 | $height-header: 47px;
8 | $height-welcome:300px;
9 | $height-fake-area:30px;
10 | $height-profile-nav-wrap:60px;
11 |
--------------------------------------------------------------------------------
/weibo_Vue/src/assets/css/emoji.css:
--------------------------------------------------------------------------------
1 | .emoji-yum {
2 | width: 64px;
3 | height: 64px;
4 | background-position: -0px -0px !important;
5 | }
6 |
7 | .emoji-angry {
8 | width: 64px;
9 | height: 64px;
10 | background-position: -64px -0px !important;
11 | }
12 |
13 | .emoji-anguished {
14 | width: 64px;
15 | height: 64px;
16 | background-position: -128px -0px !important;
17 | }
18 |
19 | .emoji-astonished {
20 | width: 64px;
21 | height: 64px;
22 | background-position: -192px -0px !important;
23 | }
24 |
25 | .emoji-cold_sweat {
26 | width: 64px;
27 | height: 64px;
28 | background-position: -256px -0px !important;
29 | }
30 |
31 | .emoji-cry {
32 | width: 64px;
33 | height: 64px;
34 | background-position: -320px -0px !important;
35 | }
36 |
37 | .emoji-blush {
38 | width: 64px;
39 | height: 64px;
40 | background-position: -384px -0px !important;
41 | }
42 |
43 | .emoji-confounded {
44 | width: 64px;
45 | height: 64px;
46 | background-position: -448px -0px !important;
47 | }
48 |
49 | .emoji-dizzy_face {
50 | width: 64px;
51 | height: 64px;
52 | background-position: -512px -0px !important;
53 | }
54 |
55 | .emoji-flushed {
56 | width: 64px;
57 | height: 64px;
58 | background-position: -0px -64px !important;
59 | }
60 |
61 | .emoji-fearful {
62 | width: 64px;
63 | height: 64px;
64 | background-position: -64px -64px !important;
65 | }
66 |
67 | .emoji-grimacing {
68 | width: 64px;
69 | height: 64px;
70 | background-position: -128px -64px !important;
71 | }
72 |
73 | .emoji-disappointed_relieved {
74 | width: 64px;
75 | height: 64px;
76 | background-position: -192px -64px !important;
77 | }
78 |
79 | .emoji-disappointed {
80 | width: 64px;
81 | height: 64px;
82 | background-position: -256px -64px !important;
83 | }
84 |
85 | .emoji-expressionless {
86 | width: 64px;
87 | height: 64px;
88 | background-position: -320px -64px !important;
89 | }
90 |
91 | .emoji-innocent {
92 | width: 64px;
93 | height: 64px;
94 | background-position: -384px -64px !important;
95 | }
96 |
97 | .emoji-grin {
98 | width: 64px;
99 | height: 64px;
100 | background-position: -448px -64px !important;
101 | }
102 |
103 | .emoji-frowning {
104 | width: 64px;
105 | height: 64px;
106 | background-position: -512px -64px !important;
107 | }
108 |
109 | .emoji-hushed {
110 | width: 64px;
111 | height: 64px;
112 | background-position: -0px -128px !important;
113 | }
114 |
115 | .emoji-open_mouth {
116 | width: 64px;
117 | height: 64px;
118 | background-position: -64px -128px !important;
119 | }
120 |
121 | .emoji-pensive {
122 | width: 64px;
123 | height: 64px;
124 | background-position: -128px -128px !important;
125 | }
126 |
127 | .emoji-sleepy {
128 | width: 64px;
129 | height: 64px;
130 | background-position: -192px -128px !important;
131 | }
132 |
133 | .emoji-confused {
134 | width: 64px;
135 | height: 64px;
136 | background-position: -256px -128px !important;
137 | }
138 |
139 | .emoji-persevere {
140 | width: 64px;
141 | height: 64px;
142 | background-position: -320px -128px !important;
143 | }
144 |
145 | .emoji-relieved {
146 | width: 64px;
147 | height: 64px;
148 | background-position: -384px -128px !important;
149 | }
150 |
151 | .emoji-scream {
152 | width: 64px;
153 | height: 64px;
154 | background-position: -448px -128px !important;
155 | }
156 |
157 | .emoji-stuck_out_tongue_winking_eye {
158 | width: 64px;
159 | height: 64px;
160 | background-position: -512px -128px !important;
161 | }
162 |
163 | .emoji-stuck_out_tongue {
164 | width: 64px;
165 | height: 64px;
166 | background-position: -0px -192px !important;
167 | }
168 |
169 | .emoji-satisfied {
170 | width: 64px;
171 | height: 64px;
172 | background-position: -64px -192px !important;
173 | }
174 |
175 | .emoji-no_mouth {
176 | width: 64px;
177 | height: 64px;
178 | background-position: -128px -192px !important;
179 | }
180 |
181 | .emoji-smiley {
182 | width: 64px;
183 | height: 64px;
184 | background-position: -192px -192px !important;
185 | }
186 |
187 | .emoji-smile {
188 | width: 64px;
189 | height: 64px;
190 | background-position: -256px -192px !important;
191 | }
192 |
193 | .emoji-stuck_out_tongue_closed_eyes {
194 | width: 64px;
195 | height: 64px;
196 | background-position: -320px -192px !important;
197 | }
198 |
199 | .emoji-sweat {
200 | width: 64px;
201 | height: 64px;
202 | background-position: -384px -192px !important;
203 | }
204 |
205 | .emoji-joy {
206 | width: 64px;
207 | height: 64px;
208 | background-position: -448px -192px !important;
209 | }
210 |
211 | .emoji-heart_eyes {
212 | width: 64px;
213 | height: 64px;
214 | background-position: -512px -192px !important;
215 | }
216 |
217 | .emoji-grinning {
218 | width: 64px;
219 | height: 64px;
220 | background-position: -0px -256px !important;
221 | }
222 |
223 | .emoji-smirk {
224 | width: 64px;
225 | height: 64px;
226 | background-position: -64px -256px !important;
227 | }
228 |
229 | .emoji-relaxed {
230 | width: 64px;
231 | height: 64px;
232 | background-position: -128px -256px !important;
233 | }
234 |
235 | .emoji-kissing_closed_eyes {
236 | width: 64px;
237 | height: 64px;
238 | background-position: -192px -256px !important;
239 | }
240 |
241 | .emoji-sunglasses {
242 | width: 64px;
243 | height: 64px;
244 | background-position: -256px -256px !important;
245 | }
246 |
247 | .emoji-sweat_smile {
248 | width: 64px;
249 | height: 64px;
250 | background-position: -320px -256px !important;
251 | }
252 |
253 | .emoji-sob {
254 | width: 64px;
255 | height: 64px;
256 | background-position: -384px -256px !important;
257 | }
258 |
259 | .emoji-wink {
260 | width: 64px;
261 | height: 64px;
262 | background-position: -448px -256px !important;
263 | }
264 |
265 | .emoji-worried {
266 | width: 64px;
267 | height: 64px;
268 | background-position: -512px -256px !important;
269 | }
270 |
271 | .emoji-neutral_face {
272 | width: 64px;
273 | height: 64px;
274 | background-position: -0px -320px !important;
275 | }
276 |
277 | .emoji-unamused {
278 | width: 64px;
279 | height: 64px;
280 | background-position: -64px -320px !important;
281 | }
282 |
283 | .emoji-weary {
284 | width: 64px;
285 | height: 64px;
286 | background-position: -128px -320px !important;
287 | }
288 |
289 | .emoji-tired_face {
290 | width: 64px;
291 | height: 64px;
292 | background-position: -192px -320px !important;
293 | }
294 |
295 | .emoji-triumph {
296 | width: 64px;
297 | height: 64px;
298 | background-position: -256px -320px !important;
299 | }
300 |
301 | .emoji-laughing {
302 | width: 64px;
303 | height: 64px;
304 | background-position: -320px -320px !important;
305 | }
306 |
307 | .emoji-kissing_heart {
308 | width: 64px;
309 | height: 64px;
310 | background-position: -384px -320px !important;
311 | }
312 |
--------------------------------------------------------------------------------
/weibo_Vue/src/assets/img/article_item_sprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/src/assets/img/article_item_sprite.png
--------------------------------------------------------------------------------
/weibo_Vue/src/assets/img/desc.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/src/assets/img/desc.gif
--------------------------------------------------------------------------------
/weibo_Vue/src/assets/img/emoji_sprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/src/assets/img/emoji_sprite.png
--------------------------------------------------------------------------------
/weibo_Vue/src/assets/img/exit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/src/assets/img/exit.png
--------------------------------------------------------------------------------
/weibo_Vue/src/assets/img/face_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/src/assets/img/face_logo.png
--------------------------------------------------------------------------------
/weibo_Vue/src/assets/img/github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/src/assets/img/github.png
--------------------------------------------------------------------------------
/weibo_Vue/src/assets/img/heading.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/src/assets/img/heading.jpg
--------------------------------------------------------------------------------
/weibo_Vue/src/assets/img/home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/src/assets/img/home.png
--------------------------------------------------------------------------------
/weibo_Vue/src/assets/img/sprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yonginggg/WeiboRumorClassify_Vue_Flask/81e739c7d679e6c51ac2f78b3d95f73f2860d71f/weibo_Vue/src/assets/img/sprite.png
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/button/BlogButton.vue:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
41 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/checkbox/Checkbox.vue:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
43 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/checkbox/CheckboxGroup.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/comment/Comment.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
30 |
31 |
32 |
33 |
34 |

35 |
36 |
37 |
38 |
39 |
留个言儿
40 |
46 |
47 |
48 |
49 |
50 |
196 |
312 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/comment/Emoji.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/comment/EmojiPanel.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
11 |
92 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/dialog/BlogDialog.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
18 |
19 |
20 |
21 |
26 |
27 |
28 |
29 |
30 |
31 |
60 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/divider/Divider.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/formItem/FormItem.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
22 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/input/BlogInput.vue:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
39 |
40 |
63 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/message/Message.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
30 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/message/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import MessageTmp from './Message.vue'
3 | const MessageConstruct = Vue.extend(MessageTmp) // 创建的是一个组件构造器,不是实例
4 | const Message = {
5 | install: (options, type) => {
6 | if (typeof (options) === 'function') {
7 | return;
8 | }
9 | if (options === undefined || options === null) {
10 | options = {
11 | content: ''
12 | }
13 | } else if (typeof options === 'string' || typeof options === 'number') {
14 | options = {
15 | content: options
16 | }
17 | if (type != undefined && options != null) {
18 | options.type = type;
19 | }
20 | }
21 | let instance = new MessageConstruct({
22 | data: options
23 | }).$mount()
24 | document.body.appendChild(instance.$el) // 添加dom元素
25 | Vue.nextTick(() => { // dom元素渲染完成后执行回调
26 | instance.visible = true
27 | })
28 | }
29 | }
30 | Vue.prototype.$message = Message.install;
31 | ['success', 'error'].forEach(type => {
32 | Vue.prototype.$message[type] = (content) => {
33 | return Vue.prototype.$message(content, type)
34 | }
35 | })
36 | export default Message
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/pagination/Pagination.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - prev
7 |
8 |
9 | - first
12 |
13 | - ...
16 |
17 | - {{ pager }}
22 |
23 | - ...
26 |
27 |
28 | - last
31 |
32 |
33 | - next
36 |
37 |
38 |
91 |
214 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/radio/Radio.vue:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
43 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/radio/RadioGroup.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
39 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/tag/Tag.vue:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
33 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/tagInputer/TagInputer.vue:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
50 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/commons/textUnderline/TextUnderline.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{text}}
6 |
7 |
8 |
35 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/header/Header.vue:
--------------------------------------------------------------------------------
1 |
2 |
33 |
34 |
129 |
195 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/header/children/Login.vue:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
43 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/header/children/MenuItem.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
73 |
114 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/home/articleItem/ArticleItem.vue:
--------------------------------------------------------------------------------
1 |
2 |
40 |
41 |
128 |
187 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/home/articleItem/SmallArticleItem.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
{{content.length>18?(content.substring(0,18)+"..."):content}}
9 |
10 |
11 |
15 |
24 |
25 |
26 |
70 |
131 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/home/indexMenu/IndexMenu.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
16 |
17 |
18 |
19 |
20 |
21 |
26 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
241 |
291 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/home/indexMenu/children/BloggerInfo.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | @
7 |
8 |
9 |
10 |
路还尚远 不负年少
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
55 |
72 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/home/indexMenu/children/MenuItem.vue:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
46 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/home/indexMenu/children/ProfileHeading.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |

13 |
14 |
15 |
{{userName}}
16 |
@XiaoXiao_ShaoNian
17 |
18 |
19 |
20 |
21 |
22 |
23 |
43 |
122 |
--------------------------------------------------------------------------------
/weibo_Vue/src/components/home/indexMenu/children/SearchBar.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
22 |
120 |
186 |
--------------------------------------------------------------------------------
/weibo_Vue/src/directives/vueClickOutSize.js:
--------------------------------------------------------------------------------
1 | const clickOutside = {
2 | // 初始化指令
3 | bind(el, binding, vnode) {
4 | function clickHandler(e) {
5 | // 这里判断点击的元素是否是本身,是本身,则返回
6 | if (el.contains(e.target)) {
7 | return false;
8 | }
9 | // 判断指令中是否绑定了函数
10 | if (binding.expression) {
11 | // 如果绑定了函数 则调用那个函数,此处binding.value就是handleClose方法
12 | binding.value(e);
13 | }
14 | }
15 | // 给当前元素绑定个私有变量,方便在unbind中可以解除事件监听
16 | el.__vueClickOutside__ = clickHandler;
17 | document.addEventListener("click", clickHandler);
18 | },
19 | unbind(el, binding) {
20 | // 解除事件监听
21 | document.removeEventListener("click", el.__vueClickOutside__);
22 | delete el.__vueClickOutside__; // 删除属性
23 | }
24 | };
25 | export default clickOutside
--------------------------------------------------------------------------------
/weibo_Vue/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import App from '@/App.vue';
3 | import router from './router.js';
4 | import $ from 'jquery'
5 | import axios from 'axios'
6 | Vue.prototype.$axios = axios
7 | import 'bootstrap'
8 | import mavonEditor from 'mavon-editor';
9 | import 'mavon-editor/dist/css/index.css';
10 | import Message from '@/components/commons/message';
11 | import ElementUI from 'element-ui';
12 | import 'element-ui/lib/theme-chalk/index.css';
13 | Vue.use(Message);
14 | Vue.use(mavonEditor);
15 | Vue.use(ElementUI);
16 | Vue.config.productionTip = false;
17 | new Vue({
18 | router,
19 | render: (h) => h(App),
20 | }).$mount('#app');
21 | router.beforeEach((to, from, next) => {
22 | next();
23 | });
24 |
25 |
--------------------------------------------------------------------------------
/weibo_Vue/src/router.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Router from 'vue-router';
3 | Vue.use(Router);
4 | export default new Router({
5 | routes: [{
6 | path: '/404',
7 | name: '找不到页面',
8 | component: () => import('@/views/NotFound.vue'),
9 | },
10 | {
11 | path: '/login',
12 | name: 'login',
13 | component: () => import('@/Login.vue'),
14 | },
15 | {
16 | path: '/register',
17 | name: 'register',
18 | component: () => import('@/Register.vue'),
19 | },
20 | {
21 | path: '/',
22 | component: () => import('@/views/navigation/Layout.vue'),
23 | redirect: {
24 | path: "/login"
25 | },
26 | children: [{
27 | path: '/home',
28 | name: '首页',
29 | component: () => import('@/views/navigation/home/HomeLayout.vue'),
30 | children: [{
31 | path: '/welcome/:id',
32 | name: '文章',
33 | component: () => import('@/views/navigation/home/Skill.vue'),
34 | },
35 | {
36 | path: '/life',
37 | name: '生活',
38 | component: () => import('@/views/navigation/home/Life.vue'),
39 | },
40 | ]
41 | },
42 | {
43 | path: '/about',
44 | name: '关于',
45 | component: () => import('@/views/navigation/about/About.vue'),
46 | },
47 | {
48 | path: '/comment',
49 | name: '留言',
50 | component: () => import('@/views/navigation/comment/Comment.vue'),
51 | },
52 | {
53 | path: '/article/:id',
54 | name: '文章浏览',
55 | component: () => import('@/views/ArticleBrowser.vue'),
56 | },
57 | ]
58 | },
59 | {
60 | path: '/article/edit/:articleID',
61 | component: () => import('@/views/ArticleEdit.vue'),
62 | },
63 | {
64 | path: '/*',
65 | redirect: {
66 | path: '/404'
67 | }
68 | }
69 | ],
70 | scrollBehavior(to, from, savedPosition) {
71 | if (from.name === '关于' && to.name == '文章') {
72 | return {
73 | x: 0,
74 | y: 0
75 | }
76 | }
77 | if (to.name === '关于') {
78 | return {
79 | x: 0,
80 | y: 0
81 | }
82 | }
83 | }
84 | });
85 |
--------------------------------------------------------------------------------
/weibo_Vue/src/utils/bus.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 |
3 | export default new Vue()
4 |
--------------------------------------------------------------------------------
/weibo_Vue/src/utils/http.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios';
2 | class Http {
3 | service = null;
4 | constructor() {
5 | axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
6 | this.service = axios.create({
7 | baseURL: '/api/',
8 | timeout: 5000000
9 | });
10 | this.service.interceptors.request.use((config) => {
11 | if (sessionStorage.getItem('token')) {
12 | config.headers.Authorization = 'BEARER ' + sessionStorage.getItem('token');
13 | }
14 | return config;
15 | }, (error) => Promise.reject(error));
16 | this.service.interceptors.response.use((response) => {
17 | if (response.status === 200) {
18 | if (response.data) {
19 | if (response.data.Code === 0) {
20 | return Promise.resolve(response.data || true);
21 | }
22 | return Promise.reject(response.data || true);
23 | }
24 | return Promise.resolve(response || false);
25 | }
26 | return Promise.reject(response || false);
27 | }, (error) => {
28 | return Promise.reject(error);
29 | });
30 | }
31 | get(url, params = {}) {
32 | return this.service.get(`${url}`, {
33 | params
34 | });
35 | }
36 | post(url, data = {}, config = {}) {
37 | return this.service.post(`${url}`, data, config);
38 | }
39 | }
40 | export default new Http();
--------------------------------------------------------------------------------
/weibo_Vue/src/views/ArticleBrowser.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
14 |
15 |
16 |
17 |
53 |
66 |
--------------------------------------------------------------------------------
/weibo_Vue/src/views/ArticleEdit.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
13 |
14 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
176 |
230 |
--------------------------------------------------------------------------------
/weibo_Vue/src/views/NotFound.vue:
--------------------------------------------------------------------------------
1 |
2 | 404 page not found
3 |
4 |
12 |
--------------------------------------------------------------------------------
/weibo_Vue/src/views/navigation/Layout.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
15 |
16 |
28 |
--------------------------------------------------------------------------------
/weibo_Vue/src/views/navigation/about/About.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 |
12 |
13 | 95后小青年 爱好摩托车 吉他 篮球 旅行 美剧 狼人杀
14 |
工作主要是使用 vue.js 和 react
15 |
究极无敌爱折腾 nodejs golang咱也搞过
16 |
嗜好太多 能力太小
17 |
路还很长 好好学习 好好生活
18 |
未完待续......
19 |
20 |
21 |
22 |
23 |
46 |
47 |
48 |
49 |
67 |
152 |
--------------------------------------------------------------------------------
/weibo_Vue/src/views/navigation/comment/Comment.vue:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
35 |
54 |
--------------------------------------------------------------------------------
/weibo_Vue/src/views/navigation/home/HomeLayout.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Welcome To
6 | {{userName}}'s Space
7 |
8 |
9 |
10 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
101 |
102 |
169 |
--------------------------------------------------------------------------------
/weibo_Vue/src/views/navigation/home/Life.vue:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
103 |
104 |
124 |
--------------------------------------------------------------------------------
/weibo_Vue/src/views/navigation/home/Skill.vue:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
107 |
108 |
131 |
--------------------------------------------------------------------------------
/weibo_Vue/vue.config.js:
--------------------------------------------------------------------------------
1 | const CompressionWebpackPlugin = require('compression-webpack-plugin') //gzip压缩
2 | const productionGzipExtensions = ['js', 'css']
3 | const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
4 | module.exports = {
5 | css: {
6 | loaderOptions: {
7 | sass: {
8 | data: `
9 | @import "@/assets/css/_variable.scss";
10 | `
11 | },
12 | }
13 | },
14 | configureWebpack: {
15 | plugins: [
16 | new UglifyJsPlugin({
17 | uglifyOptions: {
18 | compress: {
19 | drop_debugger: true,
20 | drop_console: true, //生产环境自动删除console
21 | },
22 | warnings: false,
23 | },
24 | sourceMap: false,
25 | parallel: true, //使用多进程并行运行来提高构建速度。默认并发运行数:os.cpus().length - 1。
26 | }),
27 | new CompressionWebpackPlugin({
28 | filename: '[path].gz[query]',
29 | algorithm: 'gzip',
30 | test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
31 | threshold: 10240,
32 | minRatio: 0.8
33 | }),
34 | ]
35 | },
36 | chainWebpack: config => {
37 | config.module
38 | .rule('images')
39 | .use('image-webpack-loader')
40 | .loader('image-webpack-loader')
41 | .options({
42 | bypassOnDebug: true
43 | })
44 | .end()
45 | },
46 | productionSourceMap: false,
47 | devServer: {
48 | // 配置代理
49 | proxy: {
50 | '/api': {
51 | ws: false, //禁用websocket
52 | target: 'http://localhost:8848/',
53 | changeOrigin: true,
54 | }
55 | },
56 | port: 12322,
57 | disableHostCheck: true,
58 | },
59 | }// 但是一直也不清楚自己的blog应该长啥样。
--------------------------------------------------------------------------------
/weibo_flask/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Datasource local storage ignored files
5 | /dataSources/
6 | /dataSources.local.xml
7 | # Editor-based HTTP Client requests
8 | /httpRequests/
9 |
--------------------------------------------------------------------------------
/weibo_flask/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/weibo_flask/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/weibo_flask/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/weibo_flask/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/weibo_flask/.idea/weibo_flask.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/weibo_flask/app.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, render_template, request, jsonify,Response
2 | import pymysql
3 | import threading
4 | import datetime
5 | import tensorflow as tf
6 | from tensorflow.python.keras.models import Sequential
7 | from tensorflow.python.keras.layers import Dense, GRU, Embedding, LSTM, Bidirectional
8 | from tensorflow.python.keras.optimizers import RMSprop
9 | from tensorflow.python.keras.optimizers import Adam
10 | from tensorflow.python.keras.callbacks import EarlyStopping, ModelCheckpoint, TensorBoard, ReduceLROnPlateau
11 | from tensorflow.python.keras.preprocessing.text import Tokenizer
12 | from tensorflow.python.keras.preprocessing.sequence import pad_sequences
13 | import re
14 | import pkuseg
15 | import pandas as pd
16 | from gensim.models import KeyedVectors# gensim用来加载预训练词向量
17 |
18 | max_tokens = 58
19 | seg = pkuseg.pkuseg(model_name='web') # 程序会自动下载所对应的细领域模型
20 | #导入停用词
21 | stopwords=pd.read_csv("D:/Work/大三下/大三暑假短学期/数据处理/stopwords/stopwords.txt",index_col=False,sep="\t",quoting=3,names=['stopword'], encoding='utf-8')
22 | stopwords = stopwords.stopword.values.tolist()#转为list形式
23 | cn_model = KeyedVectors.load_word2vec_format('D:/Work/大三下/大三暑假短学期/数据处理/embeddings/sgns.weibo.bigram',
24 | binary=False,
25 | unicode_errors="ignore")
26 | model = tf.keras.models.load_model('D:/Work/大三下/大三暑假短学期/数据处理/LSTM_rumor_model_58.h5')
27 |
28 | from flask_cors import *
29 | app = Flask(__name__)
30 | CORS(app, supports_credentials=True)
31 | def predict_rumor_LSTM(text):
32 | print(text)
33 | # 去标点
34 | text = re.sub("[\s+\.\!\/_,$%^*(+\"\']+|[+——!,。?、~@#¥%……&*()]+", "",text)
35 | # 分词
36 | cut = seg.cut(text)
37 | #去除停用词
38 | cut_clean=[]
39 | for word in cut:
40 | if word in stopwords:
41 | continue
42 | cut_clean.append(word)
43 | # tokenize
44 | for i, word in enumerate(cut_clean):
45 | try:
46 | cut_clean[i] = cn_model.vocab[word].index
47 | if cut_clean[i] >= 50000:
48 | cut_clean[i] = 0
49 | except KeyError:
50 | cut_clean[i] = 0
51 | # padding
52 | tokens_pad = pad_sequences([cut_clean], maxlen=max_tokens,
53 | padding='pre', truncating='pre')
54 | # 预测
55 | dic={0:'谣言',1:'真言'}
56 | result = model.predict(x=tokens_pad)
57 | coef = result[0][0]
58 | if coef >= 0.5:
59 | return dic[1]
60 | else:
61 | return dic[0]
62 |
63 | # 显示用户言论列表
64 | @app.route('/api/article/list', methods=['POST', 'GET'])
65 | def getlist():
66 | data = eval(request.data.decode())
67 | Page = data['Page']
68 | Personal = data['Personal']
69 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
70 | cursor = cur = db.cursor() # 获取数据库的游标
71 | count = cursor.execute('select * from article where personal_id = %s order by id DESC',Personal) # 获取操作数据库的游标
72 | results = cursor.fetchall()
73 | alllist = []
74 | for i in range(len(results)):
75 | if(i=Page*10-10):
76 | datalist = {"ID":results[i][0],"CreatedAt":results[i][1],"content":results[i][2],"Tags":results[i][3],"Pensonal":results[i][4],"Pensonalname":results[i][5],"Categories":results[i][6]}
77 | alllist.append(datalist)
78 | midlist = {"List":alllist,"Total":len(results)}
79 | finallist = {"Code":0, "Msg":"","Data":midlist,}
80 |
81 | # 提交,不然无法保存新建或者修改的数据
82 | db.commit()
83 | # 关闭游标
84 | cursor.close()
85 | # 关闭连接
86 | db.close()
87 | return jsonify(finallist)
88 |
89 | # 显示所有言论列表
90 | @app.route('/api/article/allarticle', methods=['POST', 'GET'])
91 | def getallarticle():
92 | data = eval(request.data.decode())
93 | Page = data['Page']
94 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
95 | cursor = cur = db.cursor() # 获取数据库的游标
96 | count = cursor.execute('select * from article order by id DESC') # 获取操作数据库的游标
97 | results = cursor.fetchall()
98 | alllist = []
99 | for i in range(len(results)):
100 | if(i=Page*10-10):
101 | datalist = {"ID":results[i][0],"CreatedAt":results[i][1],"content":results[i][2],"Tags":results[i][3],"Pensonal":results[i][4],"Pensonalname":results[i][5],"Categories":results[i][6]}
102 | alllist.append(datalist)
103 | midlist = {"List":alllist,"Total":len(results)}
104 | finallist = {"Code":0, "Msg":"","Data":midlist,}
105 |
106 | # 提交,不然无法保存新建或者修改的数据
107 | db.commit()
108 | # 关闭游标
109 | cursor.close()
110 | # 关闭连接
111 | db.close()
112 | return jsonify(finallist)
113 |
114 | # 显示言论详情
115 | @app.route('/api/article/fetch', methods=['POST', 'GET'])
116 | def articleFetch():
117 | data = eval(request.data.decode())
118 | ID = data['ID']
119 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
120 | cursor = cur = db.cursor() # 获取数据库的游标
121 | count = cursor.execute('select * from article where id = %s',ID) # 获取操作数据库的游标
122 | results = cursor.fetchall()
123 | datalist = {}
124 | for i in range(len(results)):
125 | datalist = {"ID":results[i][0],"CreatedAt":results[i][1],"Content":results[i][2],"Tags":results[i][3],"Pensonal":results[i][4],"Title":results[i][5],"Categories":results[i][6],"GithubUrl": "http://localhost:12322/#/welcome/"+str(results[i][4])}
126 | finallist = {"Code":0, "Msg":"","Data":datalist,}
127 |
128 | # 提交,不然无法保存新建或者修改的数据
129 | db.commit()
130 | # 关闭游标
131 | cursor.close()
132 | # 关闭连接
133 | db.close()
134 | return jsonify(finallist)
135 |
136 | # 显示用户留言列表
137 | @app.route('/api/article/comment', methods=['POST', 'GET'])
138 | def getUserComment():
139 | data = eval(request.data.decode())
140 | Page = data['Page']
141 | Personal = data['Personal']
142 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
143 | cursor = cur = db.cursor() # 获取数据库的游标
144 | count = cursor.execute('select * from user_comment where commented_id = %s',Personal) # 获取操作数据库的游标
145 | results = cursor.fetchall()
146 | alllist = []
147 | for i in range(len(results)):
148 | if(i=Page*10-10):
149 | datalist = {"ID":results[i][0],"CreatedAt":results[i][1],"content":results[i][2],"commented_id":results[i][3],"Pensonal":results[i][4],"Pensonalname":results[i][5]}
150 | alllist.append(datalist)
151 | midlist = {"List":alllist,"Total":len(results)}
152 | finallist = {"Code":0, "Msg":"","Data":midlist,}
153 |
154 | # 提交,不然无法保存新建或者修改的数据
155 | db.commit()
156 | # 关闭游标
157 | cursor.close()
158 | # 关闭连接
159 | db.close()
160 | return jsonify(finallist)
161 |
162 | # 显示言论的评论列表
163 | @app.route('/api/comment/list', methods=['POST', 'GET'])
164 | def getAtricleComment():
165 | data = eval(request.data.decode())
166 | articleId = data['ArticleID']
167 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
168 | cursor = cur = db.cursor() # 获取数据库的游标
169 | count = cursor.execute('select * from article_comment where article_id = %s',articleId) # 获取操作数据库的游标
170 | results = cursor.fetchall()
171 | alllist = []
172 | picture = ["http://pic2.zhimg.com/50/v2-d0e0847a32fbe01eb19e8a4834d60ecd_hd.jpg","https://pic4.zhimg.com/80/v2-8b03829610d7f875a931fe8c7ada4926_1440w.jpg?source=1940ef5c",
173 | "https://pic2.zhimg.com/80/v2-7cea67f01f6a3bfb14f0266ca875c77e_1440w.jpg?source=1940ef5c","https://pic2.zhimg.com/80/v2-c4a5d55093898b3bfe205447613f2055_1440w.jpg?source=1940ef5c",
174 | "https://pic2.zhimg.com/80/v2-9e082ad6373b8c1499a474230533ce7a_1440w.jpg?source=1940ef5c","https://pic2.zhimg.com/80/v2-3acf294099fb0b052b1a1ffd5c523dc9_1440w.jpg?source=1940ef5c",
175 | "https://pic1.zhimg.com/80/v2-78438adb9dd16cda8a8384e1662cbd74_1440w.jpg?source=1940ef5c","https://pic1.zhimg.com/80/v2-defdc3aee4c844bb0db09cd86e855cb0_1440w.jpg?source=1940ef5c"]
176 | for i in range(len(results)):
177 | datalist = {"ID":results[i][0],"CreatedAt":results[i][1],"Content":results[i][2],"ArticleID":results[i][3],"Pensonal":results[i][4],"Username":results[i][5],
178 | "AvatarUrl": picture[i%8],"GithubUrl": "http://localhost:12322/#/welcome/"+str(results[i][4]),"GitUserID": 55419701}
179 | alllist.append(datalist)
180 | midlist = {"List":alllist,"Total":len(results)}
181 | finallist = {"Code":0, "Msg":"","Data":midlist}
182 |
183 | # 提交,不然无法保存新建或者修改的数据
184 | db.commit()
185 | # 关闭游标
186 | cursor.close()
187 | # 关闭连接
188 | db.close()
189 | return jsonify(finallist)
190 |
191 | # 显示标签列表
192 | @app.route('/api/category/list', methods=['POST', 'GET'])
193 | def getCategory():
194 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
195 | cursor = cur = db.cursor() # 获取数据库的游标
196 | count = cursor.execute('select * from category') # 获取操作数据库的游标
197 | results = cursor.fetchall()
198 | alllist = []
199 | for i in range(len(results)):
200 | datalist = {"ID":results[i][0],"Name":results[i][1]}
201 | alllist.append(datalist)
202 | midlist = {"List":alllist,"Total":len(results)}
203 | finallist = {"Code":0, "Msg":"","Data":midlist,}
204 |
205 | # 提交,不然无法保存新建或者修改的数据
206 | db.commit()
207 | # 关闭游标
208 | cursor.close()
209 | # 关闭连接
210 | db.close()
211 | return jsonify(finallist)
212 |
213 | # 动态、留言板数量
214 | @app.route('/api/article/count', methods=['POST', 'GET'])
215 | def getcomments():
216 | data = eval(request.data.decode())
217 | Personal = data['Personal']
218 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
219 |
220 | cursor = cur = db.cursor() # 获取数据库的游标
221 | count = cursor.execute('select * from article') # 获取操作数据库的游标
222 | results = cursor.fetchall()
223 | Sum = len(results) # 总数量
224 |
225 | count = cursor.execute('select * from article where personal_id = %s',Personal) # 获取操作数据库的游标
226 | results = cursor.fetchall()
227 | articleSum = len(results) # 动态数量
228 |
229 | count = cursor.execute('select * from user where userid = %s',Personal) # 获取操作数据库的游标
230 | results = cursor.fetchall()
231 | Name = results[0][2] # 姓名
232 |
233 | trueSum = 0
234 | for i in range(len(results)):
235 | if(results[i][3] == "真言"):
236 | trueSum = trueSum+1
237 | data = {"articleSum": articleSum,"commentSum": Sum,"true": trueSum,"false": len(results)-trueSum,"userName": Name}
238 | datalist = {"Code":0,"Msg":"","Data":data}
239 |
240 | # 提交,不然无法保存新建或者修改的数据
241 | db.commit()
242 | # 关闭游标
243 | cursor.close()
244 | # 关闭连接
245 | db.close()
246 | return jsonify(datalist)
247 |
248 | # 登陆
249 | @app.route('/login', methods=['POST', 'GET'])
250 | def login():
251 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
252 | userId = request.form.get('userId')
253 | password = request.form.get('password')
254 | # print(userId,password)
255 | # 获取数据库的游标
256 | cursor = cur = db.cursor()
257 | # 获取操作数据库的游标
258 | count = cursor.execute('select * from user where userId = %s and password = %s',(userId,password))
259 | results = cursor.fetchall()
260 |
261 | if(count == 0):
262 | datalist = {"port":401, "message":"账号或密码错误!"}
263 | else:
264 | for i in range(len(results)):
265 | datalist = {"port":200,"userId":results[i][1],"password":results[i][3],"userName":results[i][2]}
266 |
267 | # 提交,不然无法保存新建或者修改的数据
268 | db.commit()
269 | # 关闭游标
270 | cursor.close()
271 | # 关闭连接
272 | db.close()
273 | return jsonify(datalist)
274 |
275 | # 注册
276 | @app.route('/register', methods=['POST', 'GET'])
277 | def register():
278 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
279 | userId = request.form.get('userId')
280 | password = request.form.get('password')
281 | userName = request.form.get('userName')
282 |
283 | # 获取数据库的游标
284 | cursor = cur = db.cursor()
285 | # 获取操作数据库的游标
286 | count = cursor.execute("select * from user where userid = '" + userId+"'")
287 | count2 = cursor.execute("select * from user where username = '" + userName+"'")
288 | results = cursor.fetchall()
289 | if(count != 0):
290 | datalist = {"port": 401, "message": "账号已存在!"}
291 | elif(count2 != 0):
292 | datalist = {"port": 401, "message": "昵称已被占用!"}
293 | else:
294 | # 获取操作数据库的游标
295 | count = cursor.execute('insert into user(userid,password,username) VALUES(%s,%s,%s)',(userId,password,userName))
296 | results = cursor.fetchall()
297 | datalist = {"port": 200, "message": "注册成功!","userId": userId,"password": password,"userName": userName}
298 |
299 | # 提交,不然无法保存新建或者修改的数据
300 | db.commit()
301 | # 关闭游标
302 | cursor.close()
303 | # 关闭连接
304 | db.close()
305 | return jsonify(datalist)
306 |
307 | # 发表言论
308 | @app.route('/api/article/save', methods=['POST', 'GET'])
309 | def send():
310 | data = eval(request.data.decode())
311 | content = data['HostKey']
312 | categories = data['CategoryIDs']
313 |
314 | userID = data['userID']
315 | userName = data['userName']
316 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
317 |
318 | # 获取数据库的游标
319 | cursor = cur = db.cursor()
320 | # 获取操作数据库的游标
321 | count = cursor.execute('select * from category')
322 | results = cursor.fetchall()
323 | categories = results[int(categories)-1][1]
324 | tags = predict_rumor_LSTM(content)
325 | # 获取操作数据库的游标
326 | count = cursor.execute('insert into article(created_at,content,tags,personal_id,personal_name,categories) VALUES(%s,%s,%s,%s,%s,%s)',(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),content,tags,userID,userName,categories))
327 | results = cursor.fetchall()
328 | datalist = { "Code": 0,"Msg": "发表成功!"}
329 |
330 | # 提交,不然无法保存新建或者修改的数据
331 | db.commit()
332 | # 关闭游标
333 | cursor.close()
334 | # 关闭连接
335 | db.close()
336 | return jsonify(datalist)
337 |
338 | # 对言论进行评论
339 | @app.route('/api/comment/save', methods=['POST', 'GET'])
340 | def commentSave():
341 | data = eval(request.data.decode())
342 | content = data['Content']
343 | articleId = data['ArticleID']
344 | userID = data['Userid']
345 | userName = data['Username']
346 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
347 |
348 | # 获取数据库的游标
349 | cursor = cur = db.cursor()
350 | # 获取操作数据库的游标
351 | count = cursor.execute('select * from category')
352 | results = cursor.fetchall()
353 |
354 | # 获取操作数据库的游标
355 | count = cursor.execute('insert into article_comment(created_at,content,article_id,user_id,username) VALUES(%s,%s,%s,%s,%s)',(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),content,articleId,userID,userName))
356 | results = cursor.fetchall()
357 | data = {"Data": {
358 | "comment": {
359 | "ID": 58,
360 | "CreatedAt": datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
361 | "Content": content,
362 | "ArticleID": articleId,
363 | "GitUserID": 55419701,
364 | "Username": userName,
365 | "AvatarUrl": "https://avatars2.githubusercontent.com/u/55419701?v=4",
366 | "GithubUrl": "https://github.com/zucc-Zs",
367 | "ArticleTitle": "2"
368 | }
369 | }}
370 | datalist = { "Code": 0,"Msg": "评论成功!","Data": data}
371 |
372 | # 提交,不然无法保存新建或者修改的数据
373 | db.commit()
374 | # 关闭游标
375 | cursor.close()
376 | # 关闭连接
377 | db.close()
378 | return jsonify(datalist)
379 |
380 | # 用户主页
381 | @app.route('/api/user', methods=['POST', 'GET'])
382 | def user():
383 | # lock.acquire() # 上锁
384 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
385 | userId = request.form.get('userId')
386 | cursor = cur = db.cursor() # 获取数据库的游标
387 | count = cursor.execute('select * from comments where userId = '+userId) # 获取操作数据库的游标
388 | results = cursor.fetchall()
389 | for i in range(len(results)):
390 | datalist = {"userId": results[i][1], "password": results[i][3], "userName": results[i][2]}
391 |
392 | # 提交,不然无法保存新建或者修改的数据
393 | db.commit()
394 | # 关闭游标
395 | cursor.close()
396 | # 关闭连接
397 | db.close()
398 | # lock.release() # 解锁
399 | return jsonify(datalist)
400 |
401 |
402 |
403 | if __name__ == '__main__':
404 | lock = threading.Lock()
405 | db = pymysql.connect(host="127.0.0.1", user="root", password="yys981030", db="谣言", port=3306)
406 | app.run(debug=True,port=8848)
407 |
--------------------------------------------------------------------------------
/谣言.sql:
--------------------------------------------------------------------------------
1 | /*
2 | Navicat MySQL Data Transfer
3 |
4 | Source Server : localhost_3306
5 | Source Server Type : MySQL
6 | Source Server Version : 50615
7 | Source Host : localhost:3306
8 | Source Schema : 谣言
9 |
10 | Target Server Type : MySQL
11 | Target Server Version : 50615
12 | File Encoding : 65001
13 |
14 | Date: 12/07/2020 15:42:01
15 | */
16 |
17 | SET NAMES utf8mb4;
18 | SET FOREIGN_KEY_CHECKS = 0;
19 |
20 | -- ----------------------------
21 | -- Table structure for article
22 | -- ----------------------------
23 | DROP TABLE IF EXISTS `article`;
24 | CREATE TABLE `article` (
25 | `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
26 | `created_at` timestamp(0) NULL DEFAULT NULL,
27 | `content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
28 | `tags` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
29 | `personal_id` int(10) UNSIGNED NULL DEFAULT 0,
30 | `personal_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
31 | `categories` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
32 | PRIMARY KEY (`id`) USING BTREE
33 | ) ENGINE = InnoDB AUTO_INCREMENT = 59 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
34 |
35 | -- ----------------------------
36 | -- Table structure for article_category
37 | -- ----------------------------
38 | DROP TABLE IF EXISTS `article_category`;
39 | CREATE TABLE `article_category` (
40 | `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
41 | `created_at` timestamp(0) NULL DEFAULT NULL,
42 | `category_id` int(10) UNSIGNED NOT NULL,
43 | `article_id` int(10) UNSIGNED NOT NULL,
44 | `category_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
45 | PRIMARY KEY (`id`) USING BTREE
46 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
47 |
48 | -- ----------------------------
49 | -- Table structure for article_comment
50 | -- ----------------------------
51 | DROP TABLE IF EXISTS `article_comment`;
52 | CREATE TABLE `article_comment` (
53 | `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
54 | `created_at` timestamp(0) NULL DEFAULT NULL,
55 | `content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
56 | `article_id` int(10) UNSIGNED NULL DEFAULT NULL,
57 | `user_id` int(10) UNSIGNED NULL DEFAULT NULL,
58 | `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
59 | PRIMARY KEY (`id`) USING BTREE
60 | ) ENGINE = InnoDB AUTO_INCREMENT = 34 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
61 |
62 | -- ----------------------------
63 | -- Table structure for category
64 | -- ----------------------------
65 | DROP TABLE IF EXISTS `category`;
66 | CREATE TABLE `category` (
67 | `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
68 | `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
69 | PRIMARY KEY (`id`) USING BTREE
70 | ) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
71 |
72 | -- ----------------------------
73 | -- Table structure for user
74 | -- ----------------------------
75 | DROP TABLE IF EXISTS `user`;
76 | CREATE TABLE `user` (
77 | `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
78 | `userid` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
79 | `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
80 | `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
81 | PRIMARY KEY (`id`) USING BTREE
82 | ) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
83 |
84 | -- ----------------------------
85 | -- Table structure for user_comment
86 | -- ----------------------------
87 | DROP TABLE IF EXISTS `user_comment`;
88 | CREATE TABLE `user_comment` (
89 | `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
90 | `created_at` timestamp(0) NULL DEFAULT NULL,
91 | `content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
92 | `commented_id` int(10) UNSIGNED NULL DEFAULT NULL,
93 | `user_id` int(10) UNSIGNED NULL DEFAULT NULL,
94 | `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
95 | PRIMARY KEY (`id`) USING BTREE
96 | ) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
97 |
98 | SET FOREIGN_KEY_CHECKS = 1;
99 |
--------------------------------------------------------------------------------
/谣言检测.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # coding: utf-8
3 |
4 | # In[1]:
5 |
6 |
7 | import numpy as np
8 | import pandas as pd
9 | import re
10 |
11 |
12 | # # 导入词向量模型,https://github.com/Embedding/Chinese-Word-Vectors
13 |
14 | # In[2]:
15 |
16 |
17 | from gensim.models import KeyedVectors
18 |
19 |
20 | # In[3]:
21 |
22 |
23 | cn_model = KeyedVectors.load_word2vec_format('./embeddings/sgns.weibo.bigram',
24 | binary=False,
25 | unicode_errors="ignore")
26 |
27 |
28 | # In[46]:
29 |
30 |
31 | print(cn_model.vocab['心情'].index)
32 | print(cn_model.vectors[666].shape)
33 | print(cn_model.vectors[666])
34 |
35 |
36 | # # 读取数据
37 |
38 | # In[4]:
39 |
40 |
41 | from tensorflow.python.keras.preprocessing.text import Tokenizer
42 | from tensorflow.python.keras.preprocessing.sequence import pad_sequences
43 |
44 |
45 | # In[5]:
46 |
47 |
48 | weibo = pd.read_csv('./data/all_data.txt',sep='\t', names=['is_not_rumor','content'],encoding='utf-8')
49 | print(weibo.head())
50 |
51 | # In[6]:
52 |
53 |
54 | content = weibo.content.values.tolist()
55 | label=weibo.is_not_rumor.values.tolist()
56 |
57 |
58 | # In[33]:
59 |
60 |
61 | print(str(label[0])+'\t'+content[0])
62 |
63 |
64 | # # 分词和tokenize,https://github.com/lancopku/PKUSeg-python
65 |
66 | # In[7]:
67 |
68 |
69 | import pkuseg
70 |
71 |
72 | # In[8]:
73 |
74 |
75 | stopwords=pd.read_csv("./stopwords/stopwords.txt",index_col=False,sep="\t",quoting=3,names=['stopword'], encoding='utf-8')
76 | stopwords = stopwords.stopword.values.tolist()
77 |
78 |
79 | # In[9]:
80 |
81 |
82 | seg = pkuseg.pkuseg(model_name='web')
83 |
84 |
85 | # In[10]:
86 |
87 |
88 | train_tokens = []
89 | for text in content:
90 | text = re.sub("[\s+\.\!\/_,$%^*(+\"\']+|[+——!,。?、~@#¥%……&*()]+", "",text)
91 | cut_list = seg.cut(text)
92 | cut_list_clean=[]
93 | for word in cut_list:
94 | if word in stopwords:
95 | continue
96 | cut_list_clean.append(word)
97 |
98 | #索引化
99 | for i, word in enumerate(cut_list_clean):
100 | try:
101 | # 将词转换为索引index
102 | cut_list_clean[i] = cn_model.vocab[word].index
103 | except KeyError:
104 | # 如果词不在字典中,则输出0
105 | cut_list_clean[i] = 0
106 | train_tokens.append(cut_list_clean)
107 |
108 |
109 | # In[11]:
110 |
111 |
112 | # 获得所有tokens的长度
113 | num_tokens = [len(tokens) for tokens in train_tokens]
114 | num_tokens = np.array(num_tokens)
115 | # 取tokens平均值并加上两个tokens的标准差,
116 | max_tokens = np.mean(num_tokens) + 2 * np.std(num_tokens)
117 | max_tokens = int(max_tokens)
118 | print(max_tokens)
119 |
120 |
121 | # In[12]:
122 |
123 |
124 | train_pad = pad_sequences(train_tokens, maxlen=max_tokens,
125 | padding='pre', truncating='pre')
126 |
127 |
128 | # In[34]:
129 |
130 |
131 | print(train_pad)
132 |
133 |
134 | # # 生成词向量
135 |
136 | # In[13]:
137 |
138 |
139 | num_words = 50000 #选择使用前50k个使用频率最高的词
140 | embedding_dim=300 #每一个词汇都用一个长度为300的向量表示
141 | embedding_matrix = np.zeros((num_words, embedding_dim))
142 | for i in range(num_words):
143 | embedding_matrix[i,:] = cn_model[cn_model.index2word[i]]#前50000个index对应的词的词向量
144 | embedding_matrix = embedding_matrix.astype('float32')
145 |
146 |
147 | # In[14]:
148 |
149 |
150 | train_pad[train_pad>=num_words ] = 0
151 | train_target = np.array(label)
152 |
153 |
154 | # # 训练
155 |
156 | # In[15]:
157 |
158 |
159 | import tensorflow as tf
160 | from tensorflow.python.keras.models import Sequential
161 | from tensorflow.python.keras.layers import Dense, GRU, Embedding, LSTM, Bidirectional
162 | from tensorflow.python.keras.optimizers import RMSprop
163 | from tensorflow.python.keras.optimizers import Adam
164 | from tensorflow.python.keras.callbacks import EarlyStopping, ModelCheckpoint, TensorBoard, ReduceLROnPlateau
165 |
166 |
167 | # In[16]:
168 |
169 |
170 | from sklearn.model_selection import train_test_split
171 | X_train, X_test, y_train, y_test = train_test_split(train_pad,
172 | train_target,
173 | test_size=0.1,
174 | random_state=12)
175 |
176 |
177 | # In[17]:
178 |
179 |
180 | #序贯(Sequential)模型
181 | model = Sequential()
182 | # 嵌入层
183 | model.add(Embedding(num_words,
184 | embedding_dim,
185 | weights=[embedding_matrix],
186 | input_length=max_tokens,
187 | trainable=False))
188 | #Bidirectional包装器:双向RNN包装器
189 | model.add(Bidirectional(LSTM(units=64, return_sequences=True)))
190 | model.add(Bidirectional(LSTM(units=32, return_sequences=False)))
191 | #全连接层
192 | model.add(Dense(64, activation='relu'))
193 | model.add(Dense(1, activation='sigmoid'))
194 | optimizer=Adam(lr=1e-3)
195 |
196 |
197 | # In[18]:
198 |
199 |
200 | import os
201 |
202 |
203 | # In[19]:
204 |
205 |
206 | # 建立一个权重的存储点
207 | checkpoint_save_path="./checkpoint/rumor_LSTM.ckpt"
208 | if os.path.exists(checkpoint_save_path+'.index'):
209 | print('----------load the model----------')
210 | model.load_weights(checkpoint_save_path)
211 |
212 |
213 | # In[20]:
214 |
215 |
216 | #保存参数和模型
217 | checkpoint = ModelCheckpoint(filepath=checkpoint_save_path, monitor='val_loss',
218 | verbose=1, save_weights_only=True,
219 | save_best_only=True)
220 |
221 |
222 | # In[21]:
223 |
224 |
225 | # 5个epoch内validation loss没有改善则停止训练
226 | earlystopping = EarlyStopping(monitor='val_loss', patience=5, verbose=1)
227 |
228 | # 自动降低learning rate
229 | lr_reduction = ReduceLROnPlateau(monitor='val_loss',
230 | factor=0.1, min_lr=1e-8, patience=0,
231 | verbose=1)
232 | # 定义callback函数
233 | callbacks = [
234 | earlystopping,
235 | # checkpoint,
236 | lr_reduction
237 | ]
238 |
239 |
240 | # In[22]:
241 |
242 |
243 | model.compile(optimizer=optimizer,
244 | loss='binary_crossentropy',
245 | metrics=['accuracy'])
246 |
247 |
248 | # In[23]:
249 |
250 |
251 | model.fit(X_train, y_train,validation_split=0.1,epochs=20,batch_size=128,callbacks=callbacks)
252 |
253 |
254 | # # 保存模型
255 |
256 | # In[24]:
257 |
258 |
259 | model.save('LSTM_rumor_model_58.h5')
260 |
261 |
262 | # In[25]:
263 |
264 |
265 | result = model.evaluate(X_test, y_test)
266 | print('Accuracy:{0:.2%}'.format(result[1]))
267 |
268 |
269 | # In[26]:
270 |
271 |
272 | def predict_rumor_LSTM(text,label):
273 | print(text)
274 | text = re.sub("[\s+\.\!\/_,$%^*(+\"\']+|[+——!,。?、~@#¥%……&*()]+", "",text)
275 | cut = seg.cut(text)
276 |
277 | cut_clean=[]
278 | for word in cut:
279 | if word in stopwords:
280 | continue
281 | cut_clean.append(word)
282 |
283 | for i, word in enumerate(cut_clean):
284 | try:
285 | cut_clean[i] = cn_model.vocab[word].index
286 | if cut_clean[i] >= 50000:
287 | cut_clean[i] = 0
288 | except KeyError:
289 | cut_clean[i] = 0
290 |
291 | tokens_pad = pad_sequences([cut_clean], maxlen=max_tokens,
292 | padding='pre', truncating='pre')
293 |
294 | dic={0:'谣言',1:'非谣言'}
295 | result = model.predict(x=tokens_pad)
296 | coef = result[0][0]
297 | if coef >= 0.5:
298 | print('真实是'+dic[label],'预测是非谣言','output=%.2f'%coef)
299 | else:
300 | print('真实是'+dic[label],'预测是谣言','output=%.2f'%coef)
301 | print('---------------------------------------------')
302 |
303 |
304 | # In[27]:
305 |
306 |
307 | test_list = [
308 | '兴仁县今天抢小孩没抢走,把孩子母亲捅了一刀,看见这车的注意了,真事,车牌号辽HFM055!!!!!赶紧散播! 都别带孩子出去瞎转悠了 尤其别让老人自己带孩子出去 太危险了 注意了!!!!辽HFM055北京现代朗动,在各学校门口抢小孩!!!110已经 证实!!全市通缉!!',
309 | '重庆真实新闻:2016年6月1日在重庆梁平县袁驿镇发生一起抢儿童事件,做案人三个中年男人,在三中学校到镇街上的一条小路上,把小孩直接弄晕(儿童是袁驿新幼儿园中班的一名学生),正准备带走时被家长及时发现用棒子赶走了做案人,故此获救!请各位同胞们以此引起非常重视,希望大家有爱心的人传递下',
310 | '@尾熊C 要提前预习育儿知识的话,建议看一些小巫写的书,嘻嘻',
311 | ]
312 | test_label=[0,0,1]
313 | for i in range(len(test_list)):
314 | predict_rumor_LSTM(test_list[i],test_label[i])
315 |
316 |
--------------------------------------------------------------------------------