public final class LevenshteinDistance extends Object
For given two strings, provide the minimum number of single-character edits (i.e. insertions, deletions or substitutions). The default cost for each edit is 1, and each value is configurable.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_DELETION_COST
A constant holding the default deletion cost.
|
static int |
DEFAULT_INSERTION_COST
A constant holding the default insertion cost.
|
static int |
DEFAULT_SUBSTITUTION_COST
A constant holding the default substitution cost.
|
Modifier and Type | Method and Description |
---|---|
static int |
getDeletionCost()
Get the cost for "deletion".
|
static int |
getDistance(CharSequence a,
CharSequence b)
Get the Levenshtein distance for given two strings.
|
static int |
getInsertionCost()
Get the cost for "insertion".
|
static int |
getSubstitutionCost()
Get the cost for "substitution".
|
static void |
setDeletionCost(int cost)
Set the cost for "deletion".
|
static void |
setInsertionCost(int cost)
Set the cost for "insertion".
|
static void |
setSubstitutionCost(int cost)
Set the cost for "substitution".
|
public static final int DEFAULT_INSERTION_COST
public static final int DEFAULT_DELETION_COST
public static final int DEFAULT_SUBSTITUTION_COST
public static int getInsertionCost()
public static void setInsertionCost(int cost)
cost
- a cost for "insertion"public static int getDeletionCost()
public static void setDeletionCost(int cost)
cost
- a cost for "deletio"public static int getSubstitutionCost()
public static void setSubstitutionCost(int cost)
cost
- a cost for "substitution"public static int getDistance(CharSequence a, CharSequence b)
a
- a string.b
- one another string.Copyright © 2015. All rights reserved.