StringSearchUtilities Class

public static class StringSearchUtilities

No documentation is available.

Methods

NameDescription
Hamming(string, string)Compute the Hamming distance.
Hamming(uint, uint)Compute the Hamming distance.
Hamming<T>(IEnumerable<T>, IEnumerable<T>)Compute the Hamming distance.
Levenshtein(ReadOnlySpan<char>, ReadOnlySpan<char>)Compute the Levenshtein distance.
Levenshtein(ReadOnlySpan<char>, ReadOnlySpan<char>, int)Compute the Levenshtein distance with a maximum distance threshold.
Levenshtein(string, string)Compute the Hamming distance.
LevenshteinBatch(string, IReadOnlyList<string>, int)Compute Levenshtein distance between one word and multiple candidates.
Metaphone(string)
Soundex(string, IReadOnlyDictionary<char, byte>, IReadOnlyDictionary<string, char>?)Compute the soundex of a string.
Soundex2(string)Compute an improved French soundex.
SoundexEnglish(string)Compute English soundex.
SoundexFrench(string)Compute French soundex.

Hamming overloads

Hamming(string, string)

StringSearchUtilities.cs

Compute the Hamming distance.

public static int Hamming(string word1, string word2)
Parameters
word1 string
The first word.
word2 string
The second word.
Returns

int The hamming distance.

Exceptions
ArgumentException
Lists must have the same length.

Hamming(uint, uint)

StringSearchUtilities.cs

Compute the Hamming distance.

public static uint Hamming(uint word1, uint word2)
Parameters
word1 uint
The first word.
word2 uint
The second word.
Returns

uint The hamming distance.

Hamming<T>(IEnumerable<T>, IEnumerable<T>)

StringSearchUtilities.cs

Compute the Hamming distance.

public static int Hamming<T>(IEnumerable<T> word1, IEnumerable<T> word2) where T : notnull
Type parameters
T
Type of elements.
Parameters
word1 IEnumerable<T>
The first list.
word2 IEnumerable<T>
The second most.
Returns

int The hamming distance.

Exceptions
ArgumentException
Lists must have the same length.

Levenshtein overloads

Levenshtein(ReadOnlySpan<char>, ReadOnlySpan<char>)

StringSearchUtilities.cs
public static int Levenshtein(ReadOnlySpan<char> word1, ReadOnlySpan<char> word2)
Parameters
word1 ReadOnlySpan<char>
The first word.
word2 ReadOnlySpan<char>
The second word.
Returns

int The Levenshtein distance.

Levenshtein(ReadOnlySpan<char>, ReadOnlySpan<char>, int)

StringSearchUtilities.cs

Compute the Levenshtein distance with a maximum distance threshold.

public static int Levenshtein(ReadOnlySpan<char> word1, ReadOnlySpan<char> word2, int maxDistance)
Parameters
word1 ReadOnlySpan<char>
The first word.
word2 ReadOnlySpan<char>
The second word.
maxDistance int
Maximum accepted distance. If the computed distance is greater, this method returns maxDistance + 1.
Returns

int The Levenshtein distance, or maxDistance + 1 when the distance is greater than maxDistance.

Levenshtein(string, string)

StringSearchUtilities.cs

Compute the Hamming distance.

public static int Levenshtein(string word1, string word2)
Parameters
word1 string
The first word.
word2 string
The second word.
Returns

int The Levenshtein distance.

LevenshteinBatch(string, IReadOnlyList<string>, int)

StringSearchUtilities.cs

Compute Levenshtein distance between one word and multiple candidates.

public static int[] LevenshteinBatch(string word, IReadOnlyList<string> candidates, int maxDegreeOfParallelism = -1)

Parameters

word string
Word used as reference.
candidates IReadOnlyList<string>
Candidate words.
maxDegreeOfParallelism int
Maximum number of worker threads, or -1 for default.

Returns

int[] An array containing one distance per candidate.

public static string Metaphone(string s)

Parameters

s string

Returns

string

No documentation is available.

Soundex(string, IReadOnlyDictionary<char, byte>, IReadOnlyDictionary<string, char>?)

StringSearchUtilities.Soundex.cs

Compute the soundex of a string.

public static string Soundex(string s, IReadOnlyDictionary<char, byte> dic, IReadOnlyDictionary<string, char>? replace = null)

Parameters

s string
The string.
dic IReadOnlyDictionary<char, byte>
Dictionary containing value of characters.
replace IReadOnlyDictionary<string, char>?
List of replacement to do before computing the soundex.

Returns

string The soundex.

Exceptions

ArgumentException
Dictionary does not contain character a character of the string s

Compute an improved French soundex.

public static string Soundex2(string s)

Parameters

s string
The string.

Returns

string The soundex.

SoundexEnglish(string)

StringSearchUtilities.Soundex.cs

Compute English soundex.

public static string SoundexEnglish(string s)

Parameters

s string
The string.

Returns

string The soundex.

Compute French soundex.

public static string SoundexFrench(string s)

Parameters

s string
The string.

Returns

string The soundex.