Tabnine Logo
JaroStrategy
Code IndexAdd Tabnine to your IDE (free)

How to use
JaroStrategy
in
net.ricecode.similarity

Best Java code snippets using net.ricecode.similarity.JaroStrategy (Showing top 15 results out of 315)

origin: net.ricecode/string-similarity

String m1 = getSetOfMatchingCharacterWithin(shorter, longer, halflength);
String m2 = getSetOfMatchingCharacterWithin(longer, shorter, halflength);
int transpositions = transpositions(m1, m2);
origin: ch.sahits/sahitsUtil

/**
 * Calculates the similarity score of objects, where 0.0 implies absolutely no similarity
 * and 1.0 implies absolute similarity.
 * 
 * @param first The first string to compare.
 * @param second The second string to compare.
 * @return A number between 0.0 and 1.0.
 */
public double score(String first, String second)
{
  double jaro = super.score(first, second);
  int cl = commonPrefixLength(first, second);
  // The Jaro–Winkler distance uses a prefix scale which gives more favorable ratings
  // to strings that match from the beginning for a set prefix length.
  double winkler = jaro + (scalingFactor * cl * (1.0 - jaro));
  return winkler;
}
origin: rrice/java-string-similarity

@Test
public void testAbsoluteSimilarity() {
  SimilarityStrategy s = new JaroStrategy();
  String first = "Mississippi";
  String second = "Mississippi";
  double expected = 1.000;
  double delta = 0.000;
  double actual = s.score(first, second);
  assertEquals(expected, actual, delta);
}

origin: rrice/java-string-similarity

@Test
public void testMisspelledSoundAlike() {
  SimilarityStrategy s = new JaroStrategy();
  String first = "Dixon";
  String second = "Dicksonx";
  double expected = 0.767;
  double delta = 0.001;
  double actual = s.score(first, second);
  assertEquals(expected, actual, delta);
  
}

origin: rrice/java-string-similarity

String m1 = getSetOfMatchingCharacterWithin(shorter, longer, halflength);
String m2 = getSetOfMatchingCharacterWithin(longer, shorter, halflength);
int transpositions = transpositions(m1, m2);
origin: net.ricecode/string-similarity

/**
 * Calculates the similarity score of objects, where 0.0 implies absolutely no similarity
 * and 1.0 implies absolute similarity.
 * 
 * @param first The first string to compare.
 * @param second The second string to compare.
 * @return A number between 0.0 and 1.0.
 */
public double score(String first, String second)
{
  double jaro = super.score(first, second);
  int cl = commonPrefixLength(first, second);
  // The Jaro–Winkler distance uses a prefix scale which gives more favorable ratings
  // to strings that match from the beginning for a set prefix length.
  double winkler = jaro + (scalingFactor * cl * (1.0 - jaro));
  return winkler;
}
origin: rrice/java-string-similarity

  @Test
  public void testAbsoluteDissimilarity() {
    SimilarityStrategy s = new JaroStrategy();
    String first = "Mississippi";
    String second = "Oklahoma";
    double expected = 0.000;
    double delta = 0.000;
    double actual = s.score(first, second);
    assertEquals(expected, actual, delta);
  }
}
origin: rrice/java-string-similarity

String m1 = getSetOfMatchingCharacterWithin(shorter, longer, halflength);
String m2 = getSetOfMatchingCharacterWithin(longer, shorter, halflength);
int transpositions = transpositions(m1, m2);
origin: rrice/java-string-similarity

/**
 * Calculates the similarity score of objects, where 0.0 implies absolutely no similarity
 * and 1.0 implies absolute similarity.
 * 
 * @param first The first string to compare.
 * @param second The second string to compare.
 * @return A number between 0.0 and 1.0.
 */
public double score(String first, String second)
{
  double jaro = super.score(first, second);
  int cl = commonPrefixLength(first, second);
  // The Jaro–Winkler distance uses a prefix scale which gives more favorable ratings
  // to strings that match from the beginning for a set prefix length.
  double winkler = jaro + (scalingFactor * cl * (1.0 - jaro));
  return winkler;
}
origin: rrice/java-string-similarity

@Test
public void testOneTranspostion() {
  SimilarityStrategy s = new JaroStrategy();
  String first = "Martha";
  String second = "Marhta";
  double expected = 0.944;
  double delta = 0.001;
  double actual = s.score(first, second);
  assertEquals(expected, actual, delta);
}
origin: ch.sahits/sahitsUtil

String m1 = getSetOfMatchingCharacterWithin(shorter, longer, halflength);
String m2 = getSetOfMatchingCharacterWithin(longer, shorter, halflength);
int transpositions = transpositions(m1, m2);
origin: rrice/java-string-similarity

/**
 * Calculates the similarity score of objects, where 0.0 implies absolutely no similarity
 * and 1.0 implies absolute similarity.
 * 
 * @param first The first string to compare.
 * @param second The second string to compare.
 * @return A number between 0.0 and 1.0.
 */
public double score(String first, String second)
{
  double jaro = super.score(first, second);
  int cl = commonPrefixLength(first, second);
  // The Jaro–Winkler distance uses a prefix scale which gives more favorable ratings
  // to strings that match from the beginning for a set prefix length.
  double winkler = jaro + (scalingFactor * cl * (1.0 - jaro));
  return winkler;
}
origin: rrice/java-string-similarity

@Test
public void testSoundAlike() {
  SimilarityStrategy s = new JaroStrategy();
  String first = "Dwayne";
  String second = "Duane";
  double expected = 0.822;
  double delta = 0.001;
  double actual = s.score(first, second);
  assertEquals(expected, actual, delta);
  
}

origin: rrice/java-string-similarity

@Test
public void testAbsoluteSimilarity() {
  SimilarityStrategy s = new JaroStrategy();
  String first = "Mississippi";
  String second = "Mississippi";
  double expected = 1.000;
  double delta = 0.000;
  double actual = s.score(first, second);
  assertEquals(expected, actual, delta);
}

origin: rrice/java-string-similarity

@Test
public void testAbsoluteDissimilarity() {
  SimilarityStrategy s = new JaroStrategy();
  String first = "Mississippi";
  String second = "Oklahoma";
  double expected = 0.000;
  double delta = 0.000;
  double actual = s.score(first, second);
  assertEquals(expected, actual, delta);
}

net.ricecode.similarityJaroStrategy

Javadoc

A strategy that uses the Jaro Distance to calculate the similarity of two strings.

Most used methods

  • getSetOfMatchingCharacterWithin
    Gets a set of matching characters between two strings.
  • score
    Calculates the similarity score of objects, where 0.0 implies absolutely no similarity and 1.0 impli
  • transpositions
    Calculates the number of transpositions between two strings.
  • <init>

Popular in Java

  • Making http post requests using okhttp
  • getContentResolver (Context)
  • setRequestProperty (URLConnection)
  • setScale (BigDecimal)
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now