fuzzy

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Score

func Score(text, query string) (int, []int)

Score calculates fuzzy match score for a query against text Higher score is better. Returns 0 if no match.

Algorithm: - Consecutive character matches get bonus points - Case-sensitive matches get bonus points - Matches at word boundaries get bonus points - Earlier matches get higher scores.

Types

type Match

type Match struct {
	Text     string
	Score    int
	Matched  bool
	Indices  []int
	Original interface{}
}

func Filter

func Filter(query string, items []string) []Match

Filter returns matches sorted by score (highest first).

func FilterWithData

func FilterWithData(query string, items []string, data []interface{}) []Match

FilterWithData is like Filter but preserves arbitrary data with each item.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL