Icon

20230505 Pikairos Filter Out List of Words from All Rows in Given Table

This workflow shows how to remove a list of specific words from all the sentences of the rows in a table.

This workflow is, let’s say, L2 KNIME level where it is needed to use loops and variables.

The word $${SWords}$$ means variable Words, which appears in the “Flow Variable List”. It is named with an S character at the beginning to indicate that it is of type String.

The variable $${SWords}$$ is created by the -Table Row to Variable- node and it provides as a variable to the -String Manipulation- node the word to be replaced at every iteration of the recursive loop.

A recursive loop is needed because it is required to eliminate ‘ANY’ word appearing in a table of words (2nd Table) if several words to eliminate appear in the same sentence. The recursive loop injects back the same table of sentences into next loop iteration, and at every new iteration, a word is checked and eliminated. So for instance, ‘new york’ is eliminated in first iteration from your sentences and once this is done, then ‘paris’ is eliminated from those updated sentences in the second iteration. And so on so forth until all the words of the table of words are checked. The final number of iterations is necessarily the number of words to check, and this information is gathered by the -Extract Table Dimension- node.

Your sentencesTable with Wordsto RemoveLoop overyour Table of Sentencesas Many Timesas Different WordsNeed to be RemovedGather theresulting SentencesOnly at the End ofthe Looping ProcessRemove Current Wordfrom your SentencesSet CurrentWord to Removeas VariableSelect from the Tableof Words the Wordthat needs to be Removedat Current IterationGather Number ofWords toRemove fromyour SentencesDuplicate Columnto keep a BackUpSplit TableintoPreserved (1st Output)& Modified (2nd Output)Table Creator Table Creator RecursiveLoop Start Recursive Loop End String Manipulation Table Rowto Variable Row Filter Extract TableDimension String Manipulation Rule-basedRow Splitter Your sentencesTable with Wordsto RemoveLoop overyour Table of Sentencesas Many Timesas Different WordsNeed to be RemovedGather theresulting SentencesOnly at the End ofthe Looping ProcessRemove Current Wordfrom your SentencesSet CurrentWord to Removeas VariableSelect from the Tableof Words the Wordthat needs to be Removedat Current IterationGather Number ofWords toRemove fromyour SentencesDuplicate Columnto keep a BackUpSplit TableintoPreserved (1st Output)& Modified (2nd Output)Table Creator Table Creator RecursiveLoop Start Recursive Loop End String Manipulation Table Rowto Variable Row Filter Extract TableDimension String Manipulation Rule-basedRow Splitter

Nodes

Extensions

Links