Top Description Constructors Methods
info.debatty.java.stringsimilarity

public final Class OptimalStringAlignment

extends Object
implements StringDistance
Class Inheritance
All Implemented Interfaces
info.debatty.java.stringsimilarity.interfaces.StringDistance, java.io.Serializable
Annotations
@Immutable
Imports
info.debatty.java.stringsimilarity.interfaces.StringDistance, net.jcip.annotations.Immutable

Implementation of the the Optimal String Alignment (sometimes called the restricted edit distance) variant of the Damerau-Levenshtein distance. The difference between the two algorithms consists in that the Optimal String Alignment algorithm computes the number of edit operations needed to make the strings equal under the condition that no substring is edited more than once, whereas Damerau-Levenshtein presents no such restriction.
Author
Michail Bogdanos

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public double

Returns:

the OSA distance
distance
(final String
The first string to compare.
s1
,
final String
The second string to compare.
s2
)

Implements info.debatty.java.stringsimilarity.interfaces.StringDistance.distance.

Compute the distance between strings: the minimum number of operations needed to transform one string into the other (insertion, deletion, substitution of a single character, or a transposition of two adjacent characters) while no substring is edited more than once.

private static int
min(final int a, final int b, final int c)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

OptimalStringAlignmentback to summary
public OptimalStringAlignment()

Method Detail

distanceback to summary
public double distance(final String s1, final String s2)

Implements info.debatty.java.stringsimilarity.interfaces.StringDistance.distance.

Compute the distance between strings: the minimum number of operations needed to transform one string into the other (insertion, deletion, substitution of a single character, or a transposition of two adjacent characters) while no substring is edited more than once.

Parameters
s1:String

The first string to compare.

s2:String

The second string to compare.

Returns:double

the OSA distance

Exceptions
NullPointerException:
if s1 or s2 is null.
minback to summary
private static int min(final int a, final int b, final int c)