smatch

package module
v0.0.0-...-3a53fe3 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: GPL-3.0 Imports: 2 Imported by: 0

README

smatch go documentatio

Approximate string matching for go.
This packages uses the Levenshtein distance algorithm implemented in edi(Edit distance calculator)

go get git.markveres.ro/mark/smatch

package main

import "git.markveres.ro/mark/smatch"

func main() {
    choices := []string{"Hello world", "Hellow world!", "hello friends", "hello their"}

    smatch.Ratio("ab", "ac") // 0.5
    smatch.Percent("ab", "ac") // 50
    
    smatch.Match("hello there", choices)
    // [{hello their 75} {hello friends 53} {Hello world 50} {Hellow world! 46}]
}

Read more about Approximate string matching on wikipedia.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Percent

func Percent(a, b string) int

func Ratio

func Ratio(a, b string) float64

Types

type Pair

type Pair struct {
	// contains filtered or unexported fields
}

func Match

func Match(s string, choices []string) []Pair

Jump to

Keyboard shortcuts

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