Enum Class SearchAlgorithm
- All Implemented Interfaces:
Serializable
,Comparable<SearchAlgorithm>
,Constable
,StringDistance
Enumerates available string distance algorithms which can be used to compare similarity or dissimilarity
between two strings. Each algorithm follows the
StringDistance
interface to provide a standardized
approach for calculation.- Since:
- 2023-06-23
- Version:
- 1.0.0
- Author:
- notzune
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionJaro-Winkler distance algorithm.Normalized Levenshtein distance algorithm. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final @Unmodifiable Map<String,
SearchAlgorithm> A map of search algorithm names to their correspondingSearchAlgorithm
enum constants. -
Method Summary
Modifier and TypeMethodDescriptiondouble
calculate
(byte @NotNull [] x, byte @NotNull [] y) Calculates the string distance between two sequences of bytes using the associated algorithm.static SearchAlgorithm
Returns the enum constant of this class with the specified name.static SearchAlgorithm[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NORMALIZED_LEVENSHTEIN
Normalized Levenshtein distance algorithm. -
DUKE_JARO_WINKLER
Jaro-Winkler distance algorithm.
-
-
Field Details
-
NAMES
A map of search algorithm names to their correspondingSearchAlgorithm
enum constants. This allows for easy lookup and usage of search algorithms by their name.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
calculate
public double calculate(byte @NotNull [] x, byte @NotNull [] y) Calculates the string distance between two sequences of bytes using the associated algorithm. The result is negated to transform a distance measure into a similarity score where a higher value means greater similarity.- Specified by:
calculate
in interfaceStringDistance
- Parameters:
x
- The first byte array.y
- The second byte array.- Returns:
- The negated string distance, interpreted as a similarity score.
-