All Projects → anirbanmu → Str_metrics

anirbanmu / Str_metrics

Licence: mit
Ruby gem (native extension in Rust) providing implementations of various string metrics

Programming Languages

ruby
36898 projects - #4 most used programming language
rust
11053 projects

Projects that are alternatives of or similar to Str metrics

rarbg
Ruby client for the RARBG Torrent API.
Stars: ✭ 17 (-75%)
Mutual labels:  ruby-gem, rubygem
strings-case
Convert strings between different cases.
Stars: ✭ 65 (-4.41%)
Mutual labels:  rubygem, strings
strings-ansi
Handle ANSI escape codes in strings
Stars: ✭ 17 (-75%)
Mutual labels:  rubygem, strings
Elf Strings
elf-strings will programmatically read an ELF binary's string sections within a given binary. This is meant to be much like the strings UNIX utility, however is purpose built for ELF binaries.
Stars: ✭ 127 (+86.76%)
Mutual labels:  utility, strings
glimmer-dsl-swt
Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
Stars: ✭ 53 (-22.06%)
Mutual labels:  ruby-gem, rubygem
glimmer-dsl-opal
Glimmer DSL for Opal (Pure-Ruby Web GUI and Auto-Webifier of Desktop Apps)
Stars: ✭ 22 (-67.65%)
Mutual labels:  ruby-gem, rubygem
ruby terraform
A simple Ruby wrapper for invoking terraform commands.
Stars: ✭ 92 (+35.29%)
Mutual labels:  ruby-gem, rubygem
Util
A collection of useful utility functions
Stars: ✭ 201 (+195.59%)
Mutual labels:  utility, strings
ruby attic
💍 Unmaintained ruby projects needing people!
Stars: ✭ 26 (-61.76%)
Mutual labels:  ruby-gem, rubygem
glimmer-dsl-tk
Glimmer DSL for Tk (Ruby Tk Desktop Development GUI Library)
Stars: ✭ 26 (-61.76%)
Mutual labels:  ruby-gem, rubygem
Api Fuzzer
API Fuzzer which allows to fuzz request attributes using common pentesting techniques and lists vulnerabilities
Stars: ✭ 238 (+250%)
Mutual labels:  ruby-gem, rubygem
Ruby Fann
Ruby library for interfacing with FANN (Fast Artificial Neural Network)
Stars: ✭ 425 (+525%)
Mutual labels:  ruby-gem, native
jekyll-gzip
Generate gzipped assets and files for your Jekyll site at build time
Stars: ✭ 34 (-50%)
Mutual labels:  ruby-gem, rubygem
ruby-sdk
♦️ Ruby SDK to use the IBM Watson services.
Stars: ✭ 45 (-33.82%)
Mutual labels:  ruby-gem, rubygem
strings-truncation
Truncate strings with fullwidth characters and ANSI codes.
Stars: ✭ 45 (-33.82%)
Mutual labels:  rubygem, strings
Matestack Ui Core
Matestack enables you to create sophisticated, reactive UIs in pure Ruby, without touching JavaScript and HTML. You end up writing 50% less code while increasing productivity, maintainability and developer happiness.
Stars: ✭ 469 (+589.71%)
Mutual labels:  ruby-gem, rubygem
React Native Redux Firebase Todo
React Native Redux Firebase Todo
Stars: ✭ 59 (-13.24%)
Mutual labels:  native
Rom Http
Abstract HTTP adapter for ROM
Stars: ✭ 65 (-4.41%)
Mutual labels:  rubygem
Cameo
CMIO DAL plugin explorer
Stars: ✭ 59 (-13.24%)
Mutual labels:  utility
Kattlo Cli
Kattlo CLI Project
Stars: ✭ 58 (-14.71%)
Mutual labels:  native

StrMetrics

checks Gem Version license

Ruby gem (native extension in Rust) providing implementations of various string metrics. Current metrics supported are: Sørensen–Dice, Levenshtein, Damerau–Levenshtein, Jaro & Jaro–Winkler. Strings that are UTF-8 encodable (convertible to UTF-8 representation) are supported. All comparison of strings is done at the grapheme cluster level as described by Unicode Standard Annex #29; this may be different from many gems that calculate string metrics. See here for known compatibility.

Getting Started

Prerequisites

Install Rust (tested with version >= 1.38.0) with:

curl https://sh.rustup.rs -sSf | sh

Known compatibility

Ruby

2.7, 2.6, 2.5, 2.4, 2.3, jruby, truffleruby

Rust

1.46.0, 1.45.2, 1.44.1, 1.43.1, 1.42.0, 1.41.1, 1.40.0, 1.39.0, 1.38.0

Platforms

Linux, MacOS, Windows

Installation

With bundler

Add this line to your application's Gemfile:

gem 'str_metrics'

And then execute:

$ bundle install

Without bundler

$ gem install str_metrics

Usage

All you need to do to use the metrics provided in this gem is to make sure str_metrics is required like:

require 'str_metrics'

Each metric is shown below with an example & meanings of optional parameters.

Sørensen–Dice

StrMetrics::SorensenDice.coefficient('abc', 'bcd', ignore_case: false)
 => 0.5

Options:

Keyword Type Default Description
ignore_case boolean false Case insensitive comparison?

Levenshtein

StrMetrics::Levenshtein.distance('abc', 'acb', ignore_case: false)
 => 2

Options:

Keyword Type Default Description
ignore_case boolean false Case insensitive comparison?

Damerau–Levenshtein

StrMetrics::DamerauLevenshtein.distance('abc', 'acb', ignore_case: false)
 => 1

Options:

Keyword Type Default Description
ignore_case boolean false Case insensitive comparison?

Jaro

StrMetrics::Jaro.similarity('abc', 'aac', ignore_case: false)
 => 0.7777777777777777

Options:

Keyword Type Default Description
ignore_case boolean false Case insensitive comparison?

Jaro–Winkler

StrMetrics::JaroWinkler.similarity('abc', 'aac', ignore_case: false, prefix_scaling_factor: 0.1, prefix_scaling_bonus_threshold: 0.7)
 => 0.7999999999999999

StrMetrics::JaroWinkler.distance('abc', 'aac', ignore_case: false, prefix_scaling_factor: 0.1, prefix_scaling_bonus_threshold: 0.7)
 => 0.20000000000000007

Options:

Keyword Type Default Description
ignore_case boolean false Case insensitive comparison?
prefix_scaling_factor decimal 0.1 Constant scaling factor for how much to weight common prefixes. Should not exceed 0.25.
prefix_scaling_bonus_threshold decimal 0.7 Prefix bonus weighting will only be applied if the Jaro similarity is greater given value.

Motivation

The main motivation was to have a central gem which can provide a variety of string metric calculations. Secondary motivation was to experiment with writing a native extension in Rust (instead of C).

Development

Getting started

gem install bundler
git clone https://github.com/anirbanmu/str_metrics.git
cd ./str_metrics
bundle install

Building (for native component)

rake rust_build

Testing (will build native component before running tests)

rake spec

Local installation

rake install

Deploying a new version

To deploy a new version of the gem to rubygems:

  1. Bump version in version.rb according to SemVer.
  2. Get your code merged to master
  3. After a git pull on master:
rake build && rake release

Authors

See all repo contributors here.

Versioning

SemVer is employed. See tags for released versions.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/anirbanmu/str_metrics.

Code of Conduct

Everyone interacting in this project's codebase, issue trackers etc. are expected to follow the code of conduct.

License

This project is licensed under the MIT License - see the LICENSE file for details

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].