fleet/website/scripts/test-ai-weights.js
Mike McNeil ee880d953b
Website: Trivial code shortening (#29231)
Just a nit

---------

Co-authored-by: Eric <[email protected]>
2025-05-16 18:25:06 -05:00

54 lines
1.1 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'Test ai weights',
description: '',
fn: async function () {
sails.log('Running custom shell script... (`sails run test-ai-weights`)');
let posts = [
{
id: 1,
author: 'mikermcneil',
tweet: 'I fed this one stray cat and now I have 20 stray cats coming to my house',
},
{
id: 2,
author: 'fancydoilies',
tweet: 'My cat is named Rory'
},
{
id: 3,
author: 'koo',
tweet: 'Sails.js is the best JavaScript framework'
},
{
id: 4,
author: 'koo',
tweet: 'The 4th annual SailsConf is coming up in May in Abuja!'
},
];
let weighedPosts = await ƒ.simultaneouslyForEach(posts, async (post)=>{
return {
...post,
scoresByTopic: await ƒ.weigh(post, [
'related to cats',
'related to javascript',
'A social media post that is both (a) VERY interesting and (b) in reasonably good taste'
])
};
});//∞
return weighedPosts;
}
};