Skip to content

Instantly share code, notes, and snippets.

@mirismaili
Created August 16, 2021 15:17
Show Gist options
  • Save mirismaili/b2203d20474aa5acaca64634ef917a59 to your computer and use it in GitHub Desktop.
Save mirismaili/b2203d20474aa5acaca64634ef917a59 to your computer and use it in GitHub Desktop.
const fs = require("fs");
const keywords = JSON.parse(fs.readFileSync("keywords.txt").toString());
const news = JSON.parse(fs.readFileSync("news.txt").toString());
const start1 = Date.now();
const foundNews = []
for (const aNews of news) {
const stack = [];
for (const keyword of keywords) {
if (aNews["title"].includes(keyword["title"]) || aNews["lead"]?.includes(keyword["title"])) {
stack.push(keyword["title"]);
}
}
if (stack.length) {
foundNews.push([aNews["id"], stack]);
}
}
console.log(Date.now() - start1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment