Replace multi string with java snippet

Hello everyone,
at the moment I’m trying to use the function “replace” in a “Java Snippet” node for the replacement of strings in column. My gender column have variety so i want to replace it with only 3 main gender. Just like this:

other = [‘A little about you’, ‘p’, ‘Nah’, ‘Enby’, ‘Trans-female’,‘something kinda male?’,‘■■■■■/she/they’,‘non-binary’,‘All’,‘fluid’, ‘Genderqueer’,‘Androgyne’, ‘Agender’,‘Guy (-ish) ^_^’, ‘male leaning androgynous’,‘Trans woman’,‘Neuter’, ‘Female (trans)’,‘■■■■■’,‘ostensibly male, unsure what that really means’,‘trans’]

male = [‘male’, ‘Male’,‘M’, ‘m’, ‘Male-ish’, ‘maile’,‘Cis Male’,‘Mal’, ‘Male (CIS)’,‘Make’,'Male ', ‘Man’, ‘msle’,‘cis male’, ‘Cis Man’,‘Malr’,‘Mail’]

female = [‘Female’, ‘female’,‘Cis Female’, ‘F’,‘f’,‘Femake’, ‘woman’,'Female ',‘cis-female/femme’,‘Female (cis)’,‘femail’,‘Woman’,‘female’]

Can anyone help me with this? Any help would be appreciated!
Thank you !

Hi @Khim , what is this symbol?
And, do the subgenders for the 3 main categories you listed here all-inclusive?
Are you open to do it with other nodes?

Yes, the subgenders for the 3 main categories i listed are all-inclusive, you can ignore the symbol as it just some normal text. I would love to try any other nodes if you recommend any, because i am new to this and only know some basic nodes.

@Khim Hi, here’s one way to do it, just to give you an idea to apply on your own dataset.

Replacing Values for Gender.knwf (26.7 KB)

Let me know if you encounter problems.

1 Like

@badger101 well, I appreciated your help, but I don’t think it works with my data set. It has more than 1 thousand rows so I can not do as your way. Here is the data set so you can get the idea of how i want to do it
final.knwf (9.5 KB)

I’m not sure how I missed this post. Sorry for replying too late.

My method uses the Rule Engine (Dictionary). By right, the number of rows you have in the original dataset will not matter, unless you’re talking about performance issues?

By the way, the workflow that you uploaded in your last post was not in an executed state. I could not see any data at all due to this.

I know this reply is 2 months late, but if somehow you’re still stuck in the issue, let me know. Apologies on my behalf.

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