• Stars
    star
    364
  • Rank 112,977 (Top 3 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created over 14 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Approximate String Matching library

amatch - Approximate Matching Extension for Ruby

Description

This is a collection of classes that can be used for Approximate matching, searching, and comparing of Strings. They implement algorithms that compute the Levenshtein edit distance, Sellers edit distance, the Hamming distance, the longest common subsequence length, the longest common substring length, the pair distance metric, the Jaro-Winkler metric.

Installation

To install this extension as a gem type

gem install amatch

into the shell.

Download

The homepage of this library is located at

Examples

require 'amatch'
# => true
include Amatch
# => Object

m = Sellers.new("pattern")
# => #<Amatch::Sellers:0x40366324>
m.match("pattren")
# => 2.0
m.substitution = m.insertion = 3
# => 3
m.match("pattren")
# => 4.0
m.reset_weights
# => #<Amatch::Sellers:0x40366324>
m.match(["pattren","parent"])
# => [2.0, 4.0]
m.search("abcpattrendef")
# => 2.0

m = Levenshtein.new("pattern")
# => #<Amatch::Levenshtein:0x4035919c>
m.match("pattren")
# => 2
m.search("abcpattrendef")
# => 2
"pattern language".levenshtein_similar("language of patterns")
# => 0.2

m = Amatch::DamerauLevenshtein.new("pattern")
# => #<Amatch::DamerauLevenshtein:0x007fc3483dd278>
m.match("pattren")
# => 1
"pattern language".damerau_levenshtein_similar("language of patterns")
# => 0.19999999999999996

m = Hamming.new("pattern")
# => #<Amatch::Hamming:0x40350858>
m.match("pattren")
# => 2
"pattern language".hamming_similar("language of patterns")
# => 0.1

m = PairDistance.new("pattern")
# => #<Amatch::PairDistance:0x40349be8>
m.match("pattr en")
# => 0.545454545454545
m.match("pattr en", nil)
# => 0.461538461538462
m.match("pattr en", /t+/)
# => 0.285714285714286
"pattern language".pair_distance_similar("language of patterns")
# => 0.928571428571429

m = LongestSubsequence.new("pattern")
# => #<Amatch::LongestSubsequence:0x4033e900>
m.match("pattren")
# => 6
"pattern language".longest_subsequence_similar("language of patterns")
# => 0.4

m = LongestSubstring.new("pattern")
# => #<Amatch::LongestSubstring:0x403378d0>
m.match("pattren")
# => 4
"pattern language".longest_substring_similar("language of patterns")
# => 0.4

m = Jaro.new("pattern")
# => #<Amatch::Jaro:0x363b70>
m.match("paTTren")
# => 0.952380952380952
m.ignore_case = false
m.match("paTTren")
# => 0.742857142857143
"pattern language".jaro_similar("language of patterns")
# => 0.672222222222222

m = JaroWinkler.new("pattern")
# #<Amatch::JaroWinkler:0x3530b8>
m.match("paTTren")
# => 0.971428571712403
m.ignore_case = false
m.match("paTTren")
# => 0.79428571505206
m.scaling_factor = 0.05
m.match("pattren")
# => 0.961904762046678
"pattern language".jarowinkler_similar("language of patterns")
# => 0.672222222222222

Author

Florian Frank mailto:[email protected]

License

Apache License, Version 2.0 – See the COPYING file in the source archive.

More Repositories

1

json

JSON implementation for Ruby
Ruby
665
star
2

term-ansicolor

Ruby library that colors strings using ANSI escape sequences
Ruby
168
star
3

file-tail

File::Tail for Ruby
Ruby
158
star
4

permutation

Permutation library in Ruby
Ruby
29
star
5

more_math

Library that provides more mathematics.
Ruby
27
star
6

neuro

Neural Network Extension for Ruby
Ruby
21
star
7

tins

This Is Not Spruz
Ruby
20
star
8

protocol

Method Protocols for Ruby Classes
Ruby
15
star
9

spruz

All the stuff that isn't good/big enough for a real library.
Ruby
15
star
10

bullshit

The Bullshit Benchmarking Library provides the means to measure, analyse, compare, and report the execution time of ruby code. It also provides statistical tests and values computed from the measured data.
Ruby
12
star
11

lazylist

Implementation of lazy lists for Ruby
Ruby
9
star
12

active_record_mutex

Implementation of a Mutex for Active Record
Ruby
5
star
13

dslkit

Kit for building DSLs in Ruby
Ruby
4
star
14

cpu

Ruby library to read Model Specific Registers, e. g. core temperature, via the msr linux kernel module
Ruby
3
star
15

vim-config

My vim configuration
Vim Script
3
star
16

utils

Ruby
3
star
17

gem_hadar

Library providing a bunch of rake tasks for handling gems
Ruby
3
star
18

mize

Memoize methods/functions in Ruby
Ruby
3
star
19

blinkenlights

Control the Blinkenlights on your keyboard from Ruby
Ruby
2
star
20

jsturtle

Turtle Graphics with Javascript and Canvas
JavaScript
1
star
21

wirecard_checkout_page

Ruby
1
star
22

complex_config

configuration library using YAML
Ruby
1
star
23

caddy-stats

Go
1
star
24

docker-tinyproxy

Makefile
1
star
25

hackmac

Some ruby tools for working with a Hackintosh, which also might be (partially) useful an a regular Mac.
Ruby
1
star
26

ctapi

Ruby extension for Chipcard Cardterminal-API (CTAPI)
Ruby
1
star