Codota Logo
StringSimilarityService
Code IndexAdd Codota to your IDE (free)

How to use
StringSimilarityService
in
net.ricecode.similarity

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

  • Common ways to obtain StringSimilarityService
private void myMethod () {
StringSimilarityService s =
  • Codota IconSimilarityStrategy strategy;new StringSimilarityServiceImpl(strategy)
  • Smart code suggestions by Codota
}
origin: com.infotel.seleniumRobot/core

private void selectCorrespondingText(final String text) {
  double score = 0;
  WebElement optionToSelect = null;
  for (WebElement option : options) {
    String source = option.getText();
    if (service.score(source, text) > score) {
      score = service.score(source, text);
      optionToSelect = option;
    }
  }
  if (optionToSelect != null) {
    setSelected(optionToSelect);
  } else {
    throw new NoSuchElementException("Cannot locate option with corresponding text " + text);
  }
}
 
origin: ch.sahits/sahitsUtil

for (ComparableFilenameWord misspelledWord : words) {
  StringBuilder sb = new StringBuilder();
  List<SimilarityScore> scores = service.scoreAll(dict.getWords(), misspelledWord.toString());
  Collections.sort(scores, comp);
  sb.append(misspelledWord).append(": ");
origin: rrice/java-string-similarity

@Test 
public void testFindTop() {
  SimilarityStrategy strategy = mock(SimilarityStrategy.class);
  String target = "McDonalds";
  String c1 = "MacMahons";
  String c2 = "McPherson";
  String c3 = "McDonalds";
  
  SimilarityScore expected = new SimilarityScore(c3, 1.000);
  
  when(strategy.score(c1, target)).thenReturn(0.90);
  when(strategy.score(c2, target)).thenReturn(0.74);
  when(strategy.score(c3, target)).thenReturn(1.000);
  
  StringSimilarityService service = new StringSimilarityServiceImpl(strategy);
  List<String> features = new ArrayList<String>();
  features.add(c1);
  features.add(c2);
  features.add(c3);
  
  SimilarityScore top= service.findTop(features,target);
  verify(strategy).score(c1, target);
  verify(strategy).score(c2, target);
  verify(strategy).score(c3, target);
  assertEquals(expected, top);
  
}

origin: rrice/java-string-similarity

@Test
public void testScoreAll() {
  SimilarityStrategy strategy = mock(SimilarityStrategy.class);
  String target = "McDonalds";
  String c1 = "MacMahons";
  String c2 = "McPherson";
  String c3 = "McDonalds";
  
  when(strategy.score(target, c1)).thenReturn(0.90);
  when(strategy.score(target, c2)).thenReturn(0.74);
  when(strategy.score(target, c3)).thenReturn(1.000);
  
  StringSimilarityService service = new StringSimilarityServiceImpl(strategy);
  List<String> features = new ArrayList<String>();
  features.add(c1);
  features.add(c2);
  features.add(c3);
  
  List<SimilarityScore> scores = service.scoreAll(features, target);
  verify(strategy).score(c1, target);
  verify(strategy).score(c2, target);
  verify(strategy).score(c3, target);
  assertEquals(3, scores.size());
}
origin: rrice/java-string-similarity

@Test 
public void testFindTop_Ascending() {
  SimilarityStrategy strategy = mock(SimilarityStrategy.class);
  String target = "McDonalds";
  String c1 = "MacMahons";
  String c2 = "McPherson";
  String c3 = "McDonalds";
  
  SimilarityScore expected = new SimilarityScore(c2, 0.74);
  
  when(strategy.score(c1, target)).thenReturn(0.90);
  when(strategy.score(c2, target)).thenReturn(0.74);
  when(strategy.score(c3, target)).thenReturn(1.000);
  
  StringSimilarityService service = new StringSimilarityServiceImpl(strategy);
  List<String> features = new ArrayList<String>();
  features.add(c1);
  features.add(c2);
  features.add(c3);
  
  AscendingSimilarityScoreComparator comparator = new AscendingSimilarityScoreComparator();
  SimilarityScore top= service.findTop(features,target, comparator);
  verify(strategy).score(c1, target);
  verify(strategy).score(c2, target);
  verify(strategy).score(c3, target);
  assertEquals(expected, top);
}

origin: crowdin/crowdin-cli-2

crowdinCommands.add(COMMAND_PULL);
for (String cmd : crowdinCommands) {
  s = service.score(cmd, command);
  if (s > score) {
    score = s;
origin: rrice/java-string-similarity

  @Test 
  public void testFindTop_Descending() {
    SimilarityStrategy strategy = mock(SimilarityStrategy.class);
    String target = "McDonalds";
    String c1 = "MacMahons";
    String c2 = "McPherson";
    String c3 = "McDonalds";
    
    SimilarityScore expected = new SimilarityScore(c3, 1.000);
    
    when(strategy.score(c1, target)).thenReturn(0.90);
    when(strategy.score(c2, target)).thenReturn(0.74);
    when(strategy.score(c3, target)).thenReturn(1.000);
    
    StringSimilarityService service = new StringSimilarityServiceImpl(strategy);
    List<String> features = new ArrayList<String>();
    features.add(c1);
    features.add(c2);
    features.add(c3);
    
    DescendingSimilarityScoreComparator comparator = new DescendingSimilarityScoreComparator();
    SimilarityScore top= service.findTop(features,target, comparator);
    verify(strategy).score(c1, target);
    verify(strategy).score(c2, target);
    verify(strategy).score(c3, target);
    assertEquals(expected, top);
    
  }
}
origin: com.infotel.seleniumRobot/core

@ReplayOnError
public void deselectByCorrespondingText(final String text) {
  if (!isMultiple()) {
    throw new UnsupportedOperationException("You may only deselect all options of a multi-select");
  }
  
  try {
    findElement();
    double score = 0;
    WebElement optionToSelect = null;
    for (WebElement option : options) {
      String source = option.getText();
      if (service.score(source, text) > score) {
        score = service.score(source, text);
        optionToSelect = option;
      }
    }
    if (optionToSelect != null) {
      setDeselected(optionToSelect);
    } else {
      throw new NoSuchElementException("Cannot locate option with corresponding text " + text);
    }
    
  } finally {
    finalizeAction();
  }
}
origin: rrice/java-string-similarity

@Test
public void testScore() {
  SimilarityStrategy strategy = mock(SimilarityStrategy.class);
  String target = "McDonalds";
  String c1 = "MacMahons";
  String c2 = "McPherson";
  String c3 = "McDonalds";
  
  when(strategy.score(c1, target)).thenReturn(0.90);
  when(strategy.score(c2, target)).thenReturn(0.74);
  when(strategy.score(c3, target)).thenReturn(1.000);
  
  StringSimilarityService service = new StringSimilarityServiceImpl(strategy);
  
  double score = service.score(c1, target);
  verify(strategy).score(c1, target);
  assertEquals(0.90, score, 0.000);
  
}
net.ricecode.similarityStringSimilarityService

Javadoc

A service that performs string similarity calculations.

Most used methods

  • score
    Calculates the similarity score of a single feature.
  • scoreAll
    Calculates all similarity scores for a given set of features.
  • findTop
    Finds the feature within a set of given features that best match the target string.

Popular in Java

  • Finding current android device location
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • onCreateOptionsMenu (Activity)
  • getExternalFilesDir (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now