didyoumean

package module
v0.0.0-...-22d3156 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 2 Imported by: 2

README

didyoumean

Go Go Report Card

Didyoumean written in golang, find the similar string from the given string list. Currently it use Levenshtein distance to calculate edit distannce between two strings. See: https://en.wikipedia.org/wiki/Levenshtein_distance

Installation

$ go get https://github.com/sc0vu/didyoumean

or you can

import (
    "https://github.com/sc0vu/didyoumean"
)

Usage

Parameters

ThresholdRate float64

ThresholdRate is the rate that allows the edit distanse less than, eg 0.4 means the edit distance less than 40%

CaseInsensitive bool

CaseInsensitive compare the edit distance in case insensitive mode

FirstMatch

Find first match of the given string list

didyoumean.FirstMatch("key", []string{"kkk", "apple", "kea"})

Match

Find all match of the given string list

didyoumean.Match("key", []string{"kkk", "apple", "kea"})

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ThresholdRate is the rate that allows the edit distanse less than, eg 0.4
	// means the edit distance less than 40%
	ThresholdRate float64
	// CaseInsensitive compare the edit distance in case insensitive mode
	CaseInsensitive bool
)

Functions

func FirstMatch

func FirstMatch(key string, list []string) (result string)

FirstMatch returns first match of didyoumean

func Match

func Match(key string, list []string) (results []string)

Match returns all match of didyoumean

Types

This section is empty.

Jump to

Keyboard shortcuts

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