levenshtein

package module
Version: v0.0.0-...-a12aecc Latest Latest
Warning

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

Go to latest
Published: May 18, 2016 License: MIT Imports: 1 Imported by: 4

README

Levenshtein Distance in Golang

Godoc Build Status

Calculate levenshtein distance in Golang.

Install

By go tool: go get github.com/ferhatelmas/levenshtein

Usage

This uses default calculator which has cost of 1 for additions, deletions and substitutions.

import github.com/ferhatelmas/levenshtein

levenshtein.Dist("aaa", "ab") // 2

You can specify different weights to increment/deletion and substitutions.

levenshtein.New(1, 1).Dist("aaa", "ab") // 2
levenshtein.New(1, 2).Dist("aaa", "ab") // 3
levenshtein.New(1, 3).Dist("aaa", "ab") // 3
levenshtein.New(1, 4).Dist("aaa", "ab") // 3
levenshtein.New(2, 2).Dist("aaa", "ab") // 4
levenshtein.New(3, 2).Dist("aaa", "ab") // 5

LICENSE

MIT © Ferhat Elmas

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dist

func Dist(s1, s2 string) int

Dist is a convenience function for a levenshtein distance calculator with equal costs.

Types

type D

type D interface {
	// Dist calculates levenshtein distance between two utf-8 encoded strings
	Dist(string, string) int
}

D is the levenshtein distance calculator interface

func New

func New(indel, sub int) D

New creates a new levenshtein distance calculator where indel is increment/deletion cost and sub is the substitution cost.

Source Files

Jump to

Keyboard shortcuts

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