runelite-client/src/main/java/net/runelite/client/plugins/config/FuzzySearch.java
/**
	 * Try to find a match and call callback on each match, sorted by score and filtered by average
	 *
	 * @param query    query to search for
	 * @param entries  entries to search in
	 * @param callback callback to call
	 */
Try to find a match and call callback on each match, sorted by score and filtered by average
@param query    query to search for
@param entries  entries to search in
@param callback callback to call
Try to find a match and call callback on each match sorted by score and filtered by average @param query query to search for @param entries entries to search in @param callback callback to call
public static void findAndProcess(final String query, final Collection<String> entries, final Consumer<String> callback)
	{
		final Set<FuzzyMatch> matches = entries.stream()
			.map(entry -> new FuzzyMatch(
				FUZZY_SCORE.apply(query, entry)
					+ calculateStringOccurrenceBonus(entry, query)
					* STRING_OCCURRENCE_MULTIPLIER,
				entry))
			.collect(Collectors.toSet());
		final double average = matches.stream().mapToDouble(m -> m.score).average().orElse(0);
		final double max = matches.stream().mapToDouble(m -> m.score).max().orElse(0);
		final double limit = Math.min(average * 1.7, max);
		matches.stream()
			.filter(m -> m.score >= limit)
			.sorted((left, right) -> Double.compare(right.score, left.score))
			.map(m -> m.value)
			.forEach(callback);
	}
public static void findAndProcess ( final String query , final Collection < String > entries , final Consumer < String > callback ) { final Set < FuzzyMatch > matches = entries . stream ( ) . map ( entry -> new FuzzyMatch ( FUZZY_SCORE . apply ( query , entry ) + calculateStringOccurrenceBonus ( entry , query ) * STRING_OCCURRENCE_MULTIPLIER , entry ) ) . collect ( Collectors . toSet ( ) ) ; final double average = matches . stream ( ) . mapToDouble ( m -> m . score ) . average ( ) . orElse ( 0 ) ; final double max = matches . stream ( ) . mapToDouble ( m -> m . score ) . max ( ) . orElse ( 0 ) ; final double limit = Math . min ( average * 1.7 , max ) ; matches . stream ( ) . filter ( m -> m . score >= limit ) . sorted ( ( left , right ) -> Double . compare ( right . score , left . score ) ) . map ( m -> m . value ) . forEach ( callback ) ; }
Try to find a match and call callback on each match, sorted by score and filtered by average
 @param query    query to search for
 @param entries  entries to search in
 @param callback callback to call
Try to find a match and call callback on each match sorted by score and filtered by average @param query query to search for @param entries entries to search in @param callback callback to call
// Calculate score for each entry matching query // Calculate average score of the matches to filter out the less relevant ones