stringscore

package
v0.54.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BestPairCombinationJaroWinkler added in v0.51.0

func BestPairCombinationJaroWinkler(searchTokens []string, indexedTokens []string) float64

BestPairCombinationJaroWinkler compares a search query to an indexed term with improved handling of short words and spacing variations

func BestPairsJaroWinkler

func BestPairsJaroWinkler(searchTokens []string, indexedTokens []string) float64

BestPairsJaroWinkler compares a search query to an indexed term (name, address, etc) and returns a decimal fraction score.

The algorithm splits each string into tokens, and does a pairwise Jaro-Winkler score of all token combinations (outer product). The best match for each search token is chosen, such that each index token can be matched at most once.

The pairwise scores are combined into an average in a way that corrects for character length, and the fraction of the indexed term that didn't match.

func GenerateWordCombinations added in v0.51.0

func GenerateWordCombinations(tokens []string) [][]string

GenerateWordCombinations creates variations of the input words by combining short words with their neighbors, to handle cases like "JSC ARGUMENT" vs "JSCARGUMENT"

func JaroWinkler

func JaroWinkler(s1, s2 string) float64

jaroWinkler runs the similarly named algorithm over the two input strings and averages their match percentages according to the second string (assumed to be the user's query)

Terms are compared between a few adjacent terms and accumulate the highest near-neighbor match.

For more details see https://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance

func JaroWinklerWithFavoritism

func JaroWinklerWithFavoritism(indexedTerm, query string, favoritism float64) float64

Types

This section is empty.

Jump to

Keyboard shortcuts

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