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

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

Introduction

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

Prototype

public static ModifiedBerghelRoachEditDistance getInstance(String pattern) 

Source Link

Document

Creates an instance for computing edit distance from pattern .

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");
    }/*from  w ww  . j  a va2 s.  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/* www.  ja  v  a2  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;
}