use of org.eclipse.sw360.cvesearch.datasource.matcher.Match in project sw360portal by sw360.
the class ModifiedLevenshteinDistanceTest method getDistanceTestFullSubstringMatch.
@Test
public void getDistanceTestFullSubstringMatch() {
String needle = "needle";
String noise = "bla";
String haystack = "prefix needle " + noise + " postfix";
Match match = levenshteinMatch(needle, haystack);
assertThat(match.getDistance(), is(0));
}
use of org.eclipse.sw360.cvesearch.datasource.matcher.Match in project sw360portal by sw360.
the class ModifiedLevenshteinDistanceTest method getDistanceTestFullMatch.
@Test
public void getDistanceTestFullMatch() {
String needle = "needle";
String haystack = "needle";
Match match = levenshteinMatch(needle, haystack);
assertThat(match.getDistance(), is(0));
}
use of org.eclipse.sw360.cvesearch.datasource.matcher.Match in project sw360portal by sw360.
the class ModifiedLevenshteinDistanceTest method getDistanceTestUpToPrefixMatch.
@Test
public void getDistanceTestUpToPrefixMatch() {
String needle = "needle";
String haystack = "prefix needle";
Match match = levenshteinMatch(needle, haystack);
assertThat(match.getDistance(), is(0));
}
use of org.eclipse.sw360.cvesearch.datasource.matcher.Match in project sw360portal by sw360.
the class ModifiedLevenshteinDistanceTest method getDistanceTestPartialMatch.
@Test
public void getDistanceTestPartialMatch() {
String needle = "needle";
String haystack = "ndle";
Match match = levenshteinMatch(needle, haystack);
assertThat(match.getDistance(), is(2));
}
use of org.eclipse.sw360.cvesearch.datasource.matcher.Match in project sw360portal by sw360.
the class CveSearchGuesser method guessVendorAndProducts.
public List<Match> guessVendorAndProducts(String vendorHaystack, String productHaystack) throws IOException {
List<Match> result = new ArrayList<>();
List<Match> vendors = guessVendors(vendorHaystack);
for (Match vendor : vendors) {
result.addAll(guessProducts(vendor.getNeedle(), productHaystack).stream().map(product -> vendor.concat(product)).collect(Collectors.toList()));
}
return result.stream().sorted((sm1, sm2) -> sm1.compareTo(sm2)).filter(sm -> cutoff == 0 || cutoff > sm.getDistance()).collect(Collectors.toList());
}
Aggregations