Last active
August 16, 2021 15:31
-
-
Save mirismaili/1668be429925087810f455326cbc4d86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const keywords = JSON.parse(fs.readFileSync("keywords.txt").toString()); | |
const news = JSON.parse(fs.readFileSync("news.txt").toString()); | |
console.time(); | |
news.reduce((foundNews, aNews) => { | |
const stack = keywords.reduce((stack, keyword) => { | |
if (aNews["title"].includes(keyword["title"]) || aNews["lead"]?.includes(keyword["title"])) | |
stack.push(keyword["title"]); | |
return stack; | |
}, []); | |
if (stack.length) { | |
foundNews.push([aNews["id"], stack]); | |
} | |
return foundNews | |
}, []) | |
console.timeEnd(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment