Coder Social home page Coder Social logo

godice's Introduction

godice

Go version of the Sørensen–Dice coefficient. It can be used to compare two strings or return the best match in a slice of strings.

Note: The code was part of an exercise in learning Go. Pull requests are welcome.

Install

go get github.com/imjasonmiller/godice

Usage

godice.compareString(a, b str) float64

Compare string a to string b and return the score.

godice.CompareString("gopher", "golang") 

The above would return 0.2.

Strings are converted to lowercase

godice.compareStrings(a str, b []str) Matches

Compare string a to a slice of strings. Strings are sorted by their score.

godice.CompareStrings("golang", []string{"gopher", "gerbil", "grison"})

The above would return:

Matches{
  BestMatch:{ Text: "gopher", Score: 0.2 },
  Candidates:[
    { Text: "gopher", Score: 0.2 },
    { Text: "gerbil", Score: 0.0 },
    { Text: "grison", Score: 0.0 },
  ],
}

godice's People

Contributors

imjasonmiller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

godice's Issues

License

Please add a license, I dont think I can use your code otherwise.

Might I suggest MIT?

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.