@@ -56,6 +56,7 @@ public class RatcliffObershelp implements
56
56
* @return The RatcliffObershelp similarity in the range [0, 1]
57
57
* @throws NullPointerException if s1 or s2 is null.
58
58
*/
59
+ @ Override
59
60
public final double similarity (final String s1 , final String s2 ) {
60
61
if (s1 == null ) {
61
62
throw new NullPointerException ("s1 must not be null" );
@@ -70,15 +71,13 @@ public final double similarity(final String s1, final String s2) {
70
71
}
71
72
72
73
List <String > matches = getMatchList (s1 , s2 );
73
- int sumofmatches = 0 ;
74
- Iterator it = matches .iterator ();
74
+ int sum_of_matches = 0 ;
75
75
76
- while (it .hasNext ()) {
77
- String element = it .next ().toString ();
78
- sumofmatches += element .length ();
76
+ for (String match : matches ) {
77
+ sum_of_matches += match .length ();
79
78
}
80
79
81
- return 2.0d * sumofmatches / (s1 .length () + s2 .length ());
80
+ return 2.0d * sum_of_matches / (s1 .length () + s2 .length ());
82
81
}
83
82
84
83
/**
@@ -89,6 +88,7 @@ public final double similarity(final String s1, final String s2) {
89
88
* @return 1 - similarity
90
89
* @throws NullPointerException if s1 or s2 is null.
91
90
*/
91
+ @ Override
92
92
public final double distance (final String s1 , final String s2 ) {
93
93
return 1.0d - similarity (s1 , s2 );
94
94
}
0 commit comments