Examples of LevenshteinDistance


Examples of com.sk89q.worldedit.util.function.LevenshteinDistance

    public static BaseBiome findBiomeByName(Collection<BaseBiome> biomes, String name, BiomeRegistry registry) {
        checkNotNull(biomes);
        checkNotNull(name);
        checkNotNull(registry);

        Function<String, ? extends Number> compare = new LevenshteinDistance(name, false, LevenshteinDistance.STANDARD_CHARS);
        WeightedChoice<BaseBiome> chooser = new WeightedChoice<BaseBiome>(Functions.compose(compare, new BiomeName(registry)), 0);
        for (BaseBiome biome : biomes) {
            chooser.consider(biome);
        }
        Optional<Choice<BaseBiome>> choice = chooser.getChoice();
View Full Code Here

Examples of org.owasp.passfault.dictionary.LevenshteinDistance

    assertEquals(expectedValue, actualValue);
  }

  private int getIncrementalDistance(String s, String t) {
    int actualValue;
    LevenshteinDistance ld = new LevenshteinDistance(s);

    for (int i = 0, len = t.length(); i < len; i++) {
      ld.appendToTarget(t.charAt(i));
      actualValue = ld.updateDist();
      System.out.println("add char: " + t.charAt(i) + " dist = " + actualValue + "(" + ld.distance()
          + "), relativeDistance = " + ld.partialDistance());
    }
    actualValue = ld.distance();
    return actualValue;
  }
View Full Code Here

Examples of org.owasp.passfault.dictionary.LevenshteinDistance

  @Test
  public void test_partial_distance() {
    String s = "country";
    String t = "cougary";

    LevenshteinDistance ld = new LevenshteinDistance(s);
    ld.appendToTarget('c');
    ld.updateDist();
    assertEquals(0, ld.partialDistance());
    assertEquals(6, ld.distance());

    ld.appendToTarget('o');
    ld.updateDist();
    assertEquals(0, ld.partialDistance());
    assertEquals(5, ld.distance());

    ld.appendToTarget('u');
    ld.updateDist();
    assertEquals(0, ld.partialDistance());
    assertEquals(4, ld.distance());

    ld.appendToTarget('g');
    ld.updateDist();
    assertEquals(1, ld.partialDistance());
    assertEquals(4, ld.distance());

    ld.appendToTarget('a');
    ld.updateDist();
    assertEquals(2, ld.partialDistance());
    assertEquals(4, ld.distance());

    ld.appendToTarget('r');
    ld.updateDist();
    assertEquals(2, ld.partialDistance());
    assertEquals(3, ld.distance());

    ld.appendToTarget('y');
    ld.updateDist();
    assertEquals(2, ld.partialDistance());
    assertEquals(2, ld.distance());

  }
View Full Code Here

Examples of org.owasp.passfault.dictionary.LevenshteinDistance

  @Test
  public void test_partialDistance() {
    String s = "wisp";
    int expectedValue = 1;
    LevenshteinDistance ld = new LevenshteinDistance(s);
    ld.appendToTarget('a');
    ld.appendToTarget('i');
    ld.updateDist();
    int actualValue = ld.partialDistance();
    assertEquals(expectedValue, actualValue);
  }
View Full Code Here

Examples of org.owasp.webscarab.util.LevenshteinDistance

                    if (type == null || !type.startsWith("text")) {
                        _logger.warning("Base response is not text, skipping!");
                        return;
                    }
                    List baseline = tokenize(baseBytes);
                    _diff = new LevenshteinDistance(baseline);
                   
                    count = cmodel.getConversationCount();
                    _logger.info("Checking " + count + " conversaitons");
                    for (int i=0; i<count; i++) {
                        ConversationID cid = cmodel.getConversationAt(i);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.