All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.xdrop.fuzzywuzzy.ratios.SimpleRatio Maven / Gradle / Ivy

package me.xdrop.fuzzywuzzy.ratios;

import me.xdrop.diffutils.DiffUtils;
import me.xdrop.fuzzywuzzy.Ratio;
import me.xdrop.fuzzywuzzy.StringProcessor;

public class SimpleRatio implements Ratio {

    /**
     * Computes a simple Levenshtein distance ratio between the strings
     *
     * @param s1 Input string
     * @param s2 Input string
     * @return The resulting ratio of similarity
     */
    @Override
    public int apply(String s1, String s2) {

        return (int) Math.round(100 * DiffUtils.getRatio(s1, s2));

    }

    @Override
    public int apply(String s1, String s2, StringProcessor sp) {
        return apply(sp.process(s1), sp.process(s2));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy