Example usage for com.google.gwt.dev.util.editdistance ModifiedBerghelRoachEditDistance getDistance

List of usage examples for com.google.gwt.dev.util.editdistance ModifiedBerghelRoachEditDistance getDistance

Introduction

In this page you can find the example usage for com.google.gwt.dev.util.editdistance ModifiedBerghelRoachEditDistance getDistance.

Prototype

public int getDistance(CharSequence targetSequence, int limit) 

Source Link

Usage

From source file:org.emau.icmvc.ganimed.deduplication.impl.LevenshteinBlockingAlgorithm.java

License:Open Source License

@Override
public float block(String str1, String str2) throws DeduplicationException {

    if (str1 == null || str2 == null) {
        throw new IllegalArgumentException("Strings must not be null");
    }/* w  w w. j  a  v a 2s  .  c  o  m*/

    //choose longest string
    int length = str1.length() >= str2.length() ? str1.length() : str2.length();
    ModifiedBerghelRoachEditDistance brInstance = ModifiedBerghelRoachEditDistance.getInstance(str1);
    float r = (float) (length > 0 ? 1 - brInstance.getDistance(str2, length) / (float) length : 1.0);
    if (logger.isTraceEnabled()) {
        logger.trace("Levenshtein distance for blogging " + str1 + " and " + str2 + " = " + r);
    }

    return r;
}

From source file:org.emau.icmvc.ganimed.deduplication.impl.LevenstheinMatchingAlgorithm.java

License:Open Source License

/**
 * Returns 0 if complete one element is empty
 *           1 if equal/*from w  w w .  ja  v  a 2  s  .c  o m*/
 *          value between 0 and 1 else
 */
@Override
public double match(String str1, String str2) {

    if (str1 == null || str2 == null) {
        throw new IllegalArgumentException("Strings must not be null");
    }

    //choose longest string
    int length = str1.length() >= str2.length() ? str1.length() : str2.length();
    ModifiedBerghelRoachEditDistance brInstance = ModifiedBerghelRoachEditDistance.getInstance(str1);
    float r = (float) (length > 0 ? 1 - brInstance.getDistance(str2, length) / (float) length : 1.0);
    if (logger.isTraceEnabled()) {
        logger.trace("Levenshtein distance for matching " + str1 + " and " + str2 + " = " + r);
    }
    return r;
}