-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/rel-3.42.0'
- Loading branch information
Showing
23 changed files
with
657 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
h2o-genmodel/src/main/java/water/util/comparison/string/ExactComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package water.util.comparison.string; | ||
|
||
/* | ||
Copyright 2023 Lars Marius Garshol | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Original code: https://github.com/larsga/Duke/blob/duke-1.2/src/main/java/no/priv/garshol/duke/comparators/ExactComparator.java | ||
public class ExactComparator implements StringComparator { | ||
|
||
public boolean isTokenized() { | ||
return false; | ||
} | ||
|
||
public double compare(String v1, String v2) { | ||
return v1.equals(v2) ? 1.0 : 0.0; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
h2o-genmodel/src/main/java/water/util/comparison/string/JaccardIndexComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package water.util.comparison.string; | ||
|
||
/* | ||
Copyright 2023 Lars Marius Garshol | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Original code: https://github.com/larsga/Duke/blob/duke-1.2/src/main/java/no/priv/garshol/duke/comparators/JaccardIndexComparator.java | ||
public class JaccardIndexComparator implements StringComparator { | ||
private StringComparator subcomp; | ||
|
||
public JaccardIndexComparator() { | ||
this.subcomp = new ExactComparator(); | ||
} | ||
|
||
public void setComparator(StringComparator comp) { | ||
this.subcomp = comp; | ||
} | ||
|
||
public boolean isTokenized() { | ||
return true; | ||
} | ||
|
||
public double compare(String s1, String s2) { | ||
if (s1.equals(s2)) | ||
return 1.0; | ||
|
||
// tokenize | ||
String[] t1 = StringUtils.split(s1); | ||
String[] t2 = StringUtils.split(s2); | ||
|
||
// FIXME: we assume t1 and t2 do not have internal duplicates | ||
|
||
// ensure that t1 is shorter than or same length as t2 | ||
if (t1.length > t2.length) { | ||
String[] tmp = t2; | ||
t2 = t1; | ||
t1 = tmp; | ||
} | ||
|
||
// find best matches for each token in t1 | ||
double intersection = 0; | ||
double union = t1.length + t2.length; | ||
for (int ix1 = 0; ix1 < t1.length; ix1++) { | ||
double highest = 0; | ||
for (int ix2 = 0; ix2 < t2.length; ix2++) | ||
highest = Math.max(highest, subcomp.compare(t1[ix1], t2[ix2])); | ||
|
||
// INV: the best match for t1[ix1] in t2 is has similarity highest | ||
intersection += highest; | ||
union -= highest; // we reduce the union by this similarity | ||
} | ||
|
||
return intersection / union; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.