Sniffer is a library for fuzzy match strings in kotlin. For example ybe is a match for Youtube. This provides a easy and user friendly way to search for a match without the need for a lot of code.
To install the library add the the jitpack url in your project settings.gradle.kts
maven {
setUrl("https://jitpack.io")
}
Then add the library in your app build.gradle.kts
implementation("com.github.Whiskers-Apps:sniffer-kt:1.1.0")
The usage of the library is very simple. It provides 4 algorithms for searching and a sniffer object that contains sane defaults for searching.
val sniffer = Sniffer()
val matches = sniffer.matches("banana", "bana")
val sniffer = Sniffer(caseSensitive = true)
val matches = sniffer.matches("Banana", "banana")
Returns the amount of characters that are different.
val matches = getLevenshteinDistance("Banana", "banin3")
Returns the amount of positional characters different. It only works with same size strings.
val matches = getHammingDistance("banana", "banin3")
Returns the difference in a percentage. From 0.0 to 1.0.
val matches = getJaroWinklerDistance("banana", "banan")
Returns true if the characters are inside the string.
val matches = getInnerMatch("Sprigatito", "agt")
Returns true if the search string is inside the the original. It matches even if it has spaces.
val contains = getContainMatch("youtube", "utu")
val contains = getContainMatch("macacos me mordam", "smem")
The sniffer match object can be changed in its initialization in case you don't like the default values.
val sniffer = Sniffer(
levenshteinDistance = 2,
doLevenshteinMatch = true,
hammingDistance = 2,
doHammingMatch = true,
jaroWinklerDistance = 0.8,
doJaroWinklerMatch = true,
doInnerMatch = true,
caseSensitive = false
)
The sniffer result returns the values of the algorithms from a match. It's more appropriate for debuging.
val result = getSnifferResult("Luxray", "lux")
The people that are helping the project with minor or big changes.