Created
August 16, 2021 15:17
-
-
Save mirismaili/b2203d20474aa5acaca64634ef917a59 to your computer and use it in GitHub Desktop.
This file contains hidden or 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()); | |
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