Can't get String Replace (Dictionary) to work

I can't get the simple String Replace (Dictionary) node to work.  I've extracted some Locations usine the Standard Named Entity Filter. I then want to replace some strings in that resulting Document column.  I created a simple test file to try and replace "Hi" with "No" since "Hi" has been incorrectly extracted as a location:

No, Hi

In the node configuration, I selected the column to update but can't get it to work. I've tried switching the order of the fields, changing the delimiter, and creating the dictionary in a new file.  Any suggestions as to what I might be doing wrong?

 

 

You need to specify the terms to search for and the replacement the other way round. First the search term, than the replacement. In your case this would be

Hi,No

Attached is an example workflow and an example dictionary. Be aware that if you have applied any tagging the tagged terms might be unmodifiable. Unmodifiable terms will not be replaced unless it has been set in the node dialog!

Cheers, Kilian

Hi,

actually the example is not clarifying the doubt on the String Replace with Dictionary. I'm having the same issue.

very simple dictionary, and no replacement happening at all.

Can anyone please provide a working example?

Thanks

Hi there,

I presume you are better off using the "cell replacer" node, which takes a convenient "table creator" node input, as well as any "reader" node you can think of (to read old dictionary files).

Never bothered with dictionary files myself TBH.

Hope this helps at least a little bit... :-)

-E

Same problem here.

                  <b><font color="dodgerblue">en la web d pucca hay algunos XD <a rel="nofollow" 
href="https://www.domain.es/redirect-to/?redirect=http%3A%2F%2Fwww.puccaclub.com" 
target="_blank">/a><br>
besos</font></b>

I want to replace http%3A%2F%2Fwww.puccaclub.com with www.puccaclub.com. I’m using the string replacer dictionary because I have a long list of cells with such texts.

My dictionary looks currently like this:

*http%3A%2F%2Fwww.puccaclub.com*,*http://www.puccaclub.com*

As I’ve tried with and without wildcards. Just nothing happens.

Also, it’s a nuisance to only have a file-based dictionary available.

Triead with the text-processing nodes and I have the same problem. I have thousands of instances to replace so…

Hi there @iagovar,

so first goes the new value you want to have in table and after you can have multiple matches (keys) upon which replacement should happen. So syntax is following for your use case:

http://www.puccaclub.com, http%3A%2F%2Fwww.puccaclub.com

Just tried it and works fine. Also only exact matches are supported so no wildcards.

Br,
Ivan

@ipazin

Still not working for me. It does nothing, the appended column is the same as the original, an none of the texts have been replaced.

It seems like it only works if the only content in the cell is the value you’re trying to replace, if there’s more text around it doesn’t work. This make this node useless for what I’m trying to do.

Hi @iagovar,

That’s correct. What is your use case? I suggest open up a new topic, describe it and someone will hopefully be able to help.

Br,
Ivan

To replace in cells that look like this:

                  <b><font color="dodgerblue">en la web d pucca hay algunos XD <a rel="nofollow" 
href="https://www.domain.es/redirect-to/?redirect=http%3A%2F%2Fwww.puccaclub.com" 
target="_blank">/a><br>
besos</font></b>

Hi there @iagovar,

so what are the rules/possibilities you have? Do you always want to replace %3A%2F%2F with :// or you always want to replace whatever is between http and www with :// or there are multiple part you are replacing in same cell or something else?

Br,
Ivan

Typically multiple parts. It’s basically encoded URLs, thousands of them.

Hi there @iagovar,

so in that case you can try following options:

  • series of String Manipulation nodes with *regexReplace()/*replace() function inside
  • URL Decode node from Vernalis KNIME Nodes extension
  • Java Snippet (for example see this topic)

Br,
Ivan

1 Like

Now, what do you do when you want to replace symbols in a document?
This node somehow needs Document type and string, but the reads only from strings. It’s really confusing me.
I’ve got one stream with a Preprocessed document, and another with symbols I want to match, replace or remove.