Giter VIP home page Giter VIP logo

golang-levenshtein's People

Contributors

fatih avatar keegancsmith avatar mrsln avatar texttheater avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

golang-levenshtein's Issues

Usage documentation

Would it be possible to add some examples or documentation? I want to calculate the difference for a set of words but I don't know how to do this.

Thanks

index out of range in EditScriptForMatrix

The following program panics:

package main

import "github.com/texttheater/golang-levenshtein/levenshtein"

func main() {
        m := levenshtein.MatrixForStrings(
                []rune("a"),
                []rune("aa"),
                levenshtein.DefaultOptions,
        )
        levenshtein.EditScriptForMatrix(m, levenshtein.DefaultOptions)
}

DistanceForStrings: Initialization costs don't match options

Hello and thank you for your lib.
In your DistanceForStrings method, initialization costs should match insert/delete costs on lines 91, 94 and 102.
Currently it supposes costs are 1, but if you increase option costs you get wrong results.

Let's suppose insert and delete costs are 2, then if you compute distance between "meme" and "me", you'll get 2 instead of 4.

In the mentioned lines, I multiplied the value by the corresponding costs and now it works fine.

result doesn't match expected

I'm comparing a few different Levenshtein libraries and yours comes up with different values for my test cases:

  • The distance between 'Orange' and 'Apple' computed as 9. - Expected 5
  • The distance between 'kitten' and 'sitting' computed as 5. - Expected 3

I've checked with a few online checkers as well and they match my expected values. Is there a bug or are you calculating something different to the others?

The code I'm using is taken from your examples:

package main

import "fmt"
import "github.com/texttheater/golang-levenshtein/levenshtein"

func main() {
    source := "kitten"
    target := "sitting"
    distance := levenshtein.DistanceForStrings([]rune(source), []rune(target), levenshtein.DefaultOptions)
    fmt.Printf("The distance between '%s' and '%s' computed as %d.\n", source, target, distance)
}

Distances of strings of unequal size panics

Try to run
DistanceForStrings([]rune("aa"), []rune("a"), DefaultOptions)

and get exception in
return matrix[len(target)][len(source)]

You have len(source) == len(matrix[len(target)]).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.