str

package
v0.0.0-...-06831c0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLevenshteinDistance is the default levenshtein distance
	DefaultLevenshteinDistance = 3

	CaseInSensitiveMatch = iota
	CaseSensitiveMatch
	LevenshteinDistance
	Soundex
)

Variables

This section is empty.

Functions

func HashStringSHA256

func HashStringSHA256(str string) string

func Match

func Match(str1, str2 string, algorithm int) bool

Match will match string as per given algorithm

func ParseStrings

func ParseStrings(ss []string) (m map[string]string, err error)

func ToLevenshteinDistance

func ToLevenshteinDistance(a, b string) int

write Levenshtein Distance search algorithm for strings https://en.wikipedia.org/wiki/Levenshtein_distance

func ToSoundex

func ToSoundex(s string) string

ToSoundex takes a word and returns the soundex code for it. https://en.wikipedia.org/wiki/Soundex

  1. Retain the first letter of the name and drop all other occurrences of a, e, i, o, u, y, h, w.
  2. Replace consonants with digits as follows (after the first letter): b, f, p, v → 1 c, g, j, k, q, s, x, z → 2 d, t → 3 l → 4 m, n → 5 r → 6
  3. If two or more letters with the same number are adjacent in the original name (before step 1), only retain the first letter; also two letters with the same number separated by 'h' or 'w' are coded as a single number, whereas such letters separated by a vowel are coded twice. This rule also applies to the first letter.
  4. Iterate the previous step until you have one letter and three numbers. If you have too few letters in your word that you can't assign three numbers, append with zeros until there are three numbers. If you have more than 3 letters, just retain the first 3 numbers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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