How would you replace all occurrences of the word “car” with “bike”?
somecar --> somebike
carphone --> bikephone
this car is black --> this bike is black
This is somewhat like a spell check…
Thanks.
How would you replace all occurrences of the word “car” with “bike”?
somecar --> somebike
carphone --> bikephone
this car is black --> this bike is black
This is somewhat like a spell check…
Thanks.
Hi @sw1336 and welcome back to the KNIME community forum,
Thanks for creating a new topic for your question.
You can use the replace() function in the String Manipulation node like this:
replace($column1$, "car", "bike")
Or for more complex cases, you can use the regexReplace() function.
That was exactly not my issue, but your response jogged a memory and I was able to implement it.
My Solution - have a simple two col table. Loop that against the table in question and replace the bad word with the good one using variables.
Thanks!
Maybe if you provide a more complete explanation of your issue, I can provide you with a better solution.
I guess what you are doing can be done by using the Rule Engine (Dictionary) node instead of looping.
I had used a String Replace (Dict) to find and replace the entire sentence with the correct sentence. This was bad and cumbersome.
This is what I did…
Could you provide a sample input please?
SONORA PLOICE DEPARTMENT
BEAN STATATION POLICE
IBERIA PARSH GOVT
CITY OF PASADENA POLCE DEPT
SAN JOAQUIN VLLY
FIRE DIRSTRICT 3
And what should be replaced?
The words PLOICE, STATATION, PARSH, POLCE, VLLY, DIRSTRICT should be replaced with POLICE, STATION, PARISH, VALLEY, DISTRICT.
The spell checker in KNIME didn’t catch these and a lot of the others that I haven’t shown…
You can use Bing spell check API. Here is an example using my trial key (7 days remaining). Feel free to use it. You need to get your own key after the trial period:
22489-1-1.knwf (78.4 KB)
Interesting!!
Many thanks, Armin…
The problem is that you have enclosed variable names in double quotations (String Manipulation).
If you insist to use your own list of “bad -> good” words, then how about this:
22489-1-2.knwf (78.6 KB)
P.S. 2 points:
Fantastic Armin. Many, many thanks.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.