jarowinkler

package
v2.30.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package jarowinkler implements fuzzy matching based on the Jaro-Winkler metric.

Index

Constants

View Source
const AdaptiveThreshold = -1

AdaptiveThreshold indicates that the threshold should be computed dynamically based on the input length.

Variables

This section is empty.

Functions

func Select

func Select(choices []string, target string, setters ...SelectOpt) []string

Select selects items from the set of available choices based on similarity to the target according to the Jaro-Winkler metric. The selections are sorted in descending order with respect to their similarity to the target string.

By default,

  • Choices that are not sufficiently similar to the string are discarded based on an adaptive threshold. If a custom threshold is desired, use the WithThreshold option.
  • The number of choices that are returned is unlimited; to limit the number of returned results, use the WithLimit option.
  • The selection process is case-insensitive; to change this, use the WithCaseInsensitivity option.

func Similarity

func Similarity(a, b []rune) float64

Similarity computes the Jaro-Winkler similarity between a and b. The result falls in the range 0, indicating no match, to 1, indicating a perfect match.

Types

type SelectOpt

type SelectOpt func(*selectOpts)

A SelectOpt enables fine-tuning of the selection process.

func WithCaseSensitivity

func WithCaseSensitivity(enabled bool) SelectOpt

WithCaseSensitivity returns an option that enables/disables case-sensitive matching based on the enabled parameter.

func WithLimit

func WithLimit(limit int) SelectOpt

WithLimit returns an option that limits the number of returned results to at most limit. If limit < 0, the number of results is unlimited.

func WithThreshold

func WithThreshold(threshold float64) SelectOpt

WithThreshold returns an option that discards choices such that the Jaro-Winkler similarity to the target string is less than threshold. If threshold == AdaptiveThreshold, an adaptive threshold based on the length of the target string will be used.

Jump to

Keyboard shortcuts

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