Search for keywords in a couple fields (REGEX maybe?)

I’m trying to search for a certain list of keywords in column 1 or 2 and compare that to whether they are in columns 3 and 4. Here’s an example table. I’d like to look for the words “car”, “vehicle”, “auto”, not case sensitive, in these fields. The “Desired Result” column shows an example output.

Title 1 URL 1 Title 2 URL 2 Keyword Match
Car world carworld.com The best cars carplanet.com 1 and 2
vehicle sales vehicles.com selling everything everything.com 1 only
friendly people friendly.com automotive splendour auto.com 2 only
Best options options.com friendly people friendly.com None

I’m guessing that some version of regular expressions will help me do this, but I have so little experience with KNIME and no experience with regular expressions, so I’m struggling to figure this out. Any suggestions would be greatly appreciated!

Hi,
You could use a Rule Engine node with the LIKE operator.Your rule could look like this:

($title1$ LIKE "*car*" OR $title1$ LIKE "*vehicle*" OR ...) AND ($url1$ LIKE "*car*" OR $url1$ LIKE "*vehicle*" OR ...) => "1 and 2"
($title1$ LIKE "*car*" OR $title1$ LIKE "*vehicle*" OR ...) AND NOT ($url1$ LIKE "*car*" OR $url1$ LIKE "*vehicle*" OR ...) => "1 only"
...

To simplify this, you can use the Rule Engine (Dictionary) node. It allows you to read the rules from a table, so you can generate them automatically and don’t have to enter them by hand.
Kind regards
Alexander

4 Likes

Hi there @stevelp,

this topic might help. Also includes references to other same/similar topics as well.

Considering you have “no experience with regular expressions and little with KNIME” I don’t think a bit of learning would do any harm :wink: Apart from this community KNIME provides lot of resources here:
https://www.knime.com/resources

Good luck and if any questions feel free to ask!

Br,
Ivan

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.