Simple .NET and .NET Core package to find a closer word in a list of synonyms.
This package clears a string and compares it to a list of synonyms accepted a limited of changes to find the nearest word into the list. "operations" means the insertion, exclusion or replacement of a character.
Typed Word | Example word in list | Operations |
---|---|---|
Brazil | Brasil | 1 |
My income tax | Income tax | 2 |
Intention | Execution | 4 |
Today is Friday!! | Today is Monday | 5 |
Do this to remove the irrelevant word, remove the special characters, and use Levenshtein to get the nearest word in the synonym list.
var typedWord = "Intention";
var foundWord = ReplaceRegex(typedWord, RemoveStopWord(regexPattern))
.RemoveSpecialCharacters()
.LevenshteinDistance(synonyms, maxChanges);
if you prefer, you can use the extension methods separately just to clean your string
- .ReplaceRegex()
- .CreateRegexPattern()
- .RemoveSpecialCharacters()
- .LevenshteinDistance()