Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: Syntax highlight #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 92 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,96 +24,98 @@ 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
```ruby
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

Expand Down