ld

package
v0.4.0-beta Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MPL-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ld implements levenshtein distance in order to provide suggestions based on similarity.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distance

func Distance(s, t string, ignoreCase bool) int

Distance compares two strings and returns the levenshtein distance between them.

func Suggestions

func Suggestions(input string, options []string, distanceCutoff int, ignoreCase bool) []string

Suggestions takes in an input and a set of valid options. It returns a set of suggested values based on the levenshtein distance between them. The distanceCutoff can be used to control the required similarity of the option to the input for it to be included in the suggestions.

func SuggestionsWithOverride

func SuggestionsWithOverride(input string, options []string, distanceCutoff int, ignoreCase bool, override func(input, option string) bool) []string

SuggestionsWithOverride is similar to Suggestions, except it takes an optional include function. If the distance is less than the cutoff, the passed override function will be invoked, and if it returns true, the option will be added to the suggestions list. This allows custom suggestion logic to be added.

Types

This section is empty.

Jump to

Keyboard shortcuts

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