hercules.v9: gopkg.in/src-d/hercules.v9/internal/levenshtein Index | Files

package levenshtein

import "gopkg.in/src-d/hercules.v9/internal/levenshtein"


Package Files


type Context Uses

type Context struct {
    // contains filtered or unexported fields

Context is the object which allows to calculate the Levenshtein distance with Distance() method. It is needed to ensure 0 memory allocations.

func (*Context) Distance Uses

func (c *Context) Distance(str1, str2 string) int

Distance calculates the Levenshtein distance between two strings which 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 implementation 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

Package levenshtein is imported by 2 packages. Updated 2019-03-19. Refresh now. Tools for package owners.