Multiple if statement based on a variable

Hello knimers,
wish you the best.
I need to check whether keywords exist in a set of many comments.
more specifically, I have row which contain comments, and i have a table with keywrods. i need those all those keywords to be checked whether they are included in the comment or not. if only one is included then i need to write included. then again them i need the same to be done for the next comment

i tried a loop but there smth missing i can t figure it out

Picture1yyyy

Hello @mh_elhassan
You may find useful to take a look into the following post. The first grey shadowed result table in the workflow [Logical Indexing Matrix], would be the output that you are expecting.

BR

2 Likes

thanks a lot @gonhaddock
what if we want to use the same workflow but search for exact match of the words

just replace “(?i)(.*?(”

“)[^$]*)$”

by “”

Hello @mh_elhassan and thx for validating the solution.

I’m a little out of context with your question, so I’m trying to give you my best guess for the answer ‘exact match of the words’.

The process in this node is a regexMatcher() function, then if you expect the exact match of the wildcard (case sensitive); you will have to remove the regex operator (?i) no case sensitive

regexMatcher($description$, 
 	join( 
 		"(.*?(" ,
 		$wildcards$ ,
 		")[^$]*)$"  
 	) 
)

However if you look for the exact match of the whole string in the cell; then

regexMatcher($description$, $wildcards$)

Let me know if it works.

BR

hey @gonhaddock , What i need is if the word i provided in the wildcard table is available in the string exactly as it looks in the table.

Moreover, I m checking the data now. in most of the cases, the workflow fails to find the word. it gives a false flag for the word eventhough it must be true

Thx for the feedback @mh_elhassan
Can you provide some representative sample data? so we can try to set up a workflow for debugging, and understand better your use case.

BR

@gonhaddock
thanks for your help. I think i know the reason, but i would appreciate your help also in finding the silution. the string is written in arabic in an excel sheet and with skipped lines, so if the word is not in the same line as the 1st it will not find it.

i copied the same in the table node, and it wroked.

is there a ways we can make knime ignore skipped lines within the same cell

1 Like

@mh_elhassan
Regex coding can handle multiple line text; It would require some evolutive of the workflow, and it will also require some investing time in testing…

Unfortunately I’m quite busy these days and I can no deliver right now, I will add it in my ‘to do’ list for the weekend.

BR

Hello @mh_elhassan
Sorry for my late answer. The best option would be a pre-processing of the multi-line column into a concatenated one. Then submit the concatenated data for the logical indexing workflow.

20240805_wildcard_multiline_text_preprocessing.knwf (20.5 KB)

Let me know if it’s useful.

BR

Hello @gonhaddock thanks a lot for your help. I am sure i ll need it in the future

i solved it, however, with the string replacer node (the node was configured as follows choosing the regular expression tab and writing \n)

2 Likes

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