summaryrefslogtreecommitdiff
path: root/src/tools/analysis/predict-all-post-category.ts
blob: 058c4f99efa81b52b667df89674205338dc376e6 (plain)
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
28
29
30
31
32
33
34
35
import Post from '../../api/models/post';
import Core from './core';

const c = new Core();

c.init().then(() => {
	// 全ての(人間によって証明されていない)投稿を取得
	Post.find({
		text: {
			$exists: true
		},
		is_category_verified: {
			$ne: true
		}
	}, {
		sort: {
			_id: -1
		},
		fields: {
			_id: true,
			text: true
		}
	}).then(posts => {
		posts.forEach(post => {
			console.log(`predicting... ${post._id}`);
			const category = c.predict(post.text);

			Post.update({ _id: post._id }, {
				$set: {
					category: category
				}
			});
		});
	});
});