@Test public void testContained() { String s = "onlaptopwork"; String s2 = "laptop"; assert(jw.similarity(s,s2) < .8); }
public final double similarity(@NonNull final String s1, @NonNull final String s2) { if (s1 == null) { throw new NullPointerException("s1 must not be null"); } if (s2 == null) { throw new NullPointerException("s2 must not be null"); } if (s1.equals(s2)) { return 1; } int[] mtp = matches(s1, s2); float m = mtp[0]; if (m == 0) { return 0f; } double j = ((m / s1.length() + m / s2.length() + (m - mtp[1]) / m)) / THREE; double jw = j; if (j > getThreshold()) { jw = j + Math.min(JW_COEF, 1.0 / mtp[THREE]) * mtp[2] * (1 - j); } return jw; }
JaroWinkler { public final double similarity(@NonNull final String s1, @NonNull final String s2) { if (s1 == null) { throw new NullPointerException("s1 must not be null"); } if (s2 == null) { throw new NullPointerException("s2 must not be null"); } if (s1.equals(s2)) { return 1; } int[] mtp = matches(s1, s2); float m = mtp[0]; if (m == 0) { return 0f; } double j = ((m / s1.length() + m / s2.length() + (m - mtp[1]) / m)) / THREE; double jw = j; if (j > getThreshold()) { jw = j + Math.min(JW_COEF, 1.0 / mtp[THREE]) * mtp[2] * (1 - j); } return jw; } }
JaroWinkler { public final double similarity(@NonNull final String s1, @NonNull final String s2) { if (s1 == null) { throw new NullPointerException("s1 must not be null"); } if (s2 == null) { throw new NullPointerException("s2 must not be null"); } if (s1.equals(s2)) { return 1; } int[] mtp = matches(s1, s2); float m = mtp[0]; if (m == 0) { return 0f; } double j = ((m / s1.length() + m / s2.length() + (m - mtp[1]) / m)) / THREE; double jw = j; if (j > getThreshold()) { jw = j + Math.min(JW_COEF, 1.0 / mtp[THREE]) * mtp[2] * (1 - j); } return jw; } JaroWinkler();  JaroWinkler(final double threshold); }
JaroWinkler { public final double similarity(@NonNull final String s1, @NonNull final String s2) { if (s1 == null) { throw new NullPointerException("s1 must not be null"); } if (s2 == null) { throw new NullPointerException("s2 must not be null"); } if (s1.equals(s2)) { return 1; } int[] mtp = matches(s1, s2); float m = mtp[0]; if (m == 0) { return 0f; } double j = ((m / s1.length() + m / s2.length() + (m - mtp[1]) / m)) / THREE; double jw = j; if (j > getThreshold()) { jw = j + Math.min(JW_COEF, 1.0 / mtp[THREE]) * mtp[2] * (1 - j); } return jw; } JaroWinkler();  JaroWinkler(final double threshold); final double getThreshold(); final double similarity(@NonNull final String s1, @NonNull final String s2); final double distance(@NonNull final String s1, @NonNull final String s2); }
JaroWinkler { public final double similarity(@NonNull final String s1, @NonNull final String s2) { if (s1 == null) { throw new NullPointerException("s1 must not be null"); } if (s2 == null) { throw new NullPointerException("s2 must not be null"); } if (s1.equals(s2)) { return 1; } int[] mtp = matches(s1, s2); float m = mtp[0]; if (m == 0) { return 0f; } double j = ((m / s1.length() + m / s2.length() + (m - mtp[1]) / m)) / THREE; double jw = j; if (j > getThreshold()) { jw = j + Math.min(JW_COEF, 1.0 / mtp[THREE]) * mtp[2] * (1 - j); } return jw; } JaroWinkler();  JaroWinkler(final double threshold); final double getThreshold(); final double similarity(@NonNull final String s1, @NonNull final String s2); final double distance(@NonNull final String s1, @NonNull final String s2);  }