Java implementation of some fuzzy search algorithms.
- Add to your build.gradle:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
- Add dependency:
dependencies {
implementation 'com.github.EugeneLesnov:fuzzy-search:{version}'
}
- NgramSearch
int power = 3;
String token = "query";
Collection<String> source = getSomeStringCollection();
Map<String, Float> matched = ngramSearch(power, token, source, String::toString);
matched.forEach((k, v) -> System.out.println("Token: " + k + "; Percentage: " + v));
- LevenshteinSearch
int precision = 4;
String token = "query";
Collection<String> source = getStringCollection();
Map<String, Integer> matched = levenshteinSearch(precision, token, source, String::toString);
matched.forEach((k, v) -> System.out.println("Token: " + k + "; Levenshtein distance: " + v));