2017-09-06 23:19:58 +09:00
|
|
|
import Post from '../../api/models/post';
|
2017-09-06 23:58:28 +09:00
|
|
|
import Core from './core';
|
2017-09-06 23:19:58 +09:00
|
|
|
|
2017-09-06 23:58:28 +09:00
|
|
|
const c = new Core();
|
2017-09-06 23:19:58 +09:00
|
|
|
|
2017-09-06 23:58:28 +09:00
|
|
|
c.init().then(() => {
|
2017-09-06 23:19:58 +09:00
|
|
|
// 全ての(人間によって証明されていない)投稿を取得
|
|
|
|
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}`);
|
2017-09-06 23:58:28 +09:00
|
|
|
const category = c.predict(post.text);
|
2017-09-06 23:19:58 +09:00
|
|
|
|
|
|
|
Post.update({ _id: post._id }, {
|
|
|
|
$set: {
|
|
|
|
category: category
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|