search_utils

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: LGPL-3.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunWorkers

func RunWorkers(
	count int,
	workerCount int,
	timeout time.Duration,
	worker func(int, int) []*common.SearchResultLow,
) []*common.SearchResultLow

func ScoreFuzzy

func ScoreFuzzy(
	terms []string,
	args *ScoreFuzzyArgs,
	buff []uint16,
) uint8

ScoreFuzzy returns fuzzy score between query and term list Make sure you don't use the same buff in multiple goroutines Returns a number in 0..200 range, but 80 is a good minimum score to use which is equivalent of %70 similarity in single-word query and term Because we spread out %50 .. %100 similarity to scores of 100..200 for example "abstracted" is %70 similar to "abstrac" query, but gets score of 80

func ScoreSimpleFuzzy

func ScoreSimpleFuzzy(
	terms []string,
	args *ScoreSimpleFuzzyArgs,
	buff []uint16,
) uint8

ScoreSimpleFuzzy returns fuzzy score between query and term list Make sure you don't use the same buff in multiple goroutines This is the same as ScoreFuzzy for single-word terms It does not look into words of a term. But it does check if term starts with the query.

func ScoreStartsWith

func ScoreStartsWith(terms []string, query string) uint8

func ScoreWordMatch

func ScoreWordMatch(terms []string, query string) uint8

ScoreWordMatch returns a score based on exact word match between query words and term words

func Similarity

func Similarity(
	r1 []rune,
	r2 []rune,
	buff []uint16,
	subtract uint8,
) uint8

Similarity calculates a similarity score between 0 and 200 Except any score between 1 and 131 (<%66) will become zero as optimization SimilaritySlow func does not have this limitation Make sure you don't use the same buff in multiple goroutines

func SimilaritySlow

func SimilaritySlow(
	r1 []rune,
	r2 []rune,
	buff []uint16,
	subtract uint8,
) uint8

SimilaritySlow calculates a similarity score between 0 and 200 Make sure you don't use the same buff in multiple goroutines

Types

type ScoreFuzzyArgs

type ScoreFuzzyArgs struct {
	Query          string
	QueryRunes     []rune
	QueryMainWord  []rune
	QueryWordCount int // number of words in query, excluding * (indicates any word)
	MinWordCount   int
	MainWordIndex  int
}

type ScoreSimpleFuzzyArgs

type ScoreSimpleFuzzyArgs struct {
	Query      string
	QueryRunes []rune
}

Directories

Path Synopsis
test-generator
data-check command
data-gen command

Jump to

Keyboard shortcuts

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