Sobes.tech
Junior

Selecting rows containing at least one keyword

livecode

Task condition

Given:

  1. File keywords.txt – a list of keywords, one per line (about 1000 lines).
  2. File texts.txt – a set of phrases, also one per line (about 1,000,000 lines).

You need to write a program that creates a new file containing only those lines from texts.txt where at least one word from keywords.txt appears.

Example:

Input files:

keywords.txt:
foo
bar
baz

texts.txt:
aaa bbb ccc
aa foo bb cc dd
aa abarb bb cc
ccc baz xyz zoo

Expected result:

aa foo bb cc dd
ccc baz xyz zoo