Verified Owner
Top Fields Constructors Methods
org.jabref.logic.util.strings

public Class StringSimilarity

extends Object
Class Inheritance
Imports
java.util.Locale, info.debatty.java.stringsimilarity.Levenshtein, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private static final Logger
private final Levenshtein
private final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static double

Returns:

a value in the interval [0, 1] indicating the degree of match.
correlateByWords
(final String
The first string
s1
,
final String
The second string
s2
)

Compare two strings on the basis of word-by-word correlation analysis.

public double
public boolean

Returns:

true if Strings are considered as similar by the algorithm
isSimilar
(String
String to compare
a
,
String
String to compare
b
)

String similarity based on Levenshtein, ignoreCase, and fixed metric threshold of 4.

public static double
LCSSimilarity(String first, String second)

Returns the Longest Common Substring (LCS) similarity rating between two strings, ignoring case.

public double
similarity(final String first, final String second)

Calculates the similarity (a number within 0 and 1) between two strings.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGGERback to summary
private static final Logger LOGGER
METRIC_DISTANCEback to summary
private final Levenshtein METRIC_DISTANCE
METRIC_THRESHOLDback to summary
private final int METRIC_THRESHOLD

Constructor Detail

StringSimilarityback to summary
public StringSimilarity()

Method Detail

correlateByWordsback to summary
public static double correlateByWords(final String s1, final String s2)

Compare two strings on the basis of word-by-word correlation analysis.

Parameters
s1:String

The first string

s2:String

The second string

Returns:double

a value in the interval [0, 1] indicating the degree of match.

editDistanceIgnoreCaseback to summary
public double editDistanceIgnoreCase(String a, String b)
isSimilarback to summary
public boolean isSimilar(String a, String b)

String similarity based on Levenshtein, ignoreCase, and fixed metric threshold of 4.

Parameters
a:String

String to compare

b:String

String to compare

Returns:boolean

true if Strings are considered as similar by the algorithm

LCSSimilarityback to summary
public static double LCSSimilarity(String first, String second)

Returns the Longest Common Substring (LCS) similarity rating between two strings, ignoring case.

This function uses the following formula = (length of longest substring) / (length of shorter string). The longest common substring is calculated using a space-optimized dynamic programming implementation of the LCS algorithm found on Wikipedia.

similarityback to summary
public double similarity(final String first, final String second)

Calculates the similarity (a number within 0 and 1) between two strings. http://stackoverflow.com/questions/955110/similarity-string-comparison-in-java