Port of https://github.com/joshaven/string_score from js to ruby. Install and use via Rubygems: `gem install string_score`
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
LICENSE
README.mdown
Rakefile
string_score.gemspec

README.mdown

String Score (Ruby)

Port of https://github.com/joshaven/string_score from js to ruby.

It provides scores between 0 (no match) and 1 (exact match) for a comparison string to the base string.

Compatibility

Tested under Ruby 1.9.2 and Ruby 1.8.7.

Usage

$ gem install string_score

scorer = StringScore.new("string to test against")
scorer.score("string to test")
scorer.sort_by_score(['strings', 'to', 'sort'])

Or, include it into String for a convenience method:

require 'string_score/ext/string'

"Hello World".score("hello")
"Hello World".score("Whirl", 0.5) # or for fuzzy

"Hello World".sort_by_score(["xyz", "hello"]) #=> ["hello", "xyx"]

Copyright

MIT License, see LICENSE file.

Credits

Closely ported from the JS version, using roughly the same algorithm and the same test suite for implementation.

JS Original Version at: https://github.com/joshaven/string_score Copyright (C) 2009-2011 Joshaven Potter Copyright (C) 2010-2011 Yesudeep Mangalapilly