max of two columns Java Snippet

Hi there I am trying to calculate the max value of two columns using the Java Snippet node since I am using it to calculate two string similarity measures.

With the help of the forum members I managed to calculate the two measures separately, but I cannot “merge” both results in a single node.

The final desired output is the following:

image

The code used is this one:

Cheers

Jaccard + RO Forum.knwf (21.7 KB)

Hi @mauuuuu5 ,

You have a couple of things you need to fix. Firstly you have two objects with the same name “instance” so you’ll need to define these separately, e.g. jInstance and roInstance:

// Your custom variables:

Jaccard jInstance = new Jaccard(2);
RatcliffObershelp roInstance = new RatcliffObershelp();

then in your code section, reference these instances as follows:

out_Jaccard = jInstance.similarity(c_NAMESONE, c_NAMESTWO);
out_RatcliffObershelp = roInstance.similarity(c_NAMESONE, c_NAMESTWO);

Finally the “max” function in java is part of the Math class, so you can access it like this:

out_Max = Math.max(out_Jaccard,out_RatcliffObershelp);

Then it should compile ok.

1 Like

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