levenshtein

package module
v0.0.0-...-48b4e1c Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2016 License: BSD-3-Clause Imports: 0 Imported by: 39

README

Levenshtein Distance

Go package to calculate the Levenshtein Distance

Install

go get github.com/arbovm/levenshtein

Example

package main

import (
	"fmt"
	"github.com/arbovm/levenshtein"
)

func main() {
	s1 := "kitten"
	s2 := "sitting"
	fmt.Printf("The distance between %v and %v is %v\n",
		s1, s2, levenshtein.Distance(s1, s2))
	// -> The distance between kitten and sitting is 3
}

Documentation

Located here

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distance

func Distance(str1, str2 string) int

The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character http://en.wikipedia.org/wiki/Levenshtein_distance

This implemention is optimized to use O(min(m,n)) space. It is based on the optimized C version found here: http://en.wikibooks.org/wiki/Algorithm_implementation/Strings/Levenshtein_distance#C

Types

This section is empty.

Jump to

Keyboard shortcuts

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