amatch 0.2.10 → 0.2.11

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .*.sw[pon]
2
+ .AppleDouble
2
3
  Gemfile.lock
3
4
  pkg
data/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ 2013-01-16 (0.2.11)
2
+ * Include some fixes from Jason Colburne <jason@redbeardenterprises.com>.
3
+ Thx!
1
4
  2012-02-06 (0.2.10)
2
5
  * Use xfree instead of free to avoid (possible) problems.
3
6
  2011-11-14 (0.2.9)
data/Rakefile CHANGED
@@ -16,12 +16,13 @@ EOT
16
16
  executables << 'agrep.rb'
17
17
  bindir 'bin'
18
18
  test_dir 'tests'
19
- ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock'
19
+ ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', '.AppleDouble'
20
20
  title "#{name.camelize} - Approximate Matching"
21
21
  readme 'README.rdoc'
22
22
  require_paths %w[lib ext]
23
23
  dependency 'tins', '~>0.3'
24
24
  development_dependency 'test-unit', '~>2.3'
25
+ development_dependency 'utils'
25
26
 
26
27
  install_library do
27
28
  libdir = CONFIG["sitelibdir"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.10
1
+ 0.2.11
@@ -2,39 +2,42 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "amatch"
5
- s.version = "0.2.10"
5
+ s.version = "0.2.11"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Florian Frank"]
9
- s.date = "2012-02-06"
9
+ s.date = "2013-01-16"
10
10
  s.description = "Amatch is a library for approximate string matching and searching in strings.\nSeveral algorithms can be used to do this, and it's also possible to compute a\nsimilarity metric number between 0.0 and 1.0 for two given strings.\n"
11
11
  s.email = "flori@ping.de"
12
12
  s.executables = ["agrep.rb"]
13
13
  s.extensions = ["ext/extconf.rb"]
14
- s.extra_rdoc_files = ["README.rdoc", "lib/amatch.rb", "lib/amatch/version.rb", "lib/amatch/rude.rb", "lib/amatch/polite.rb", "ext/amatch_ext.c", "ext/pair.c"]
14
+ s.extra_rdoc_files = ["README.rdoc", "lib/amatch.rb", "lib/amatch/polite.rb", "lib/amatch/rude.rb", "lib/amatch/version.rb", "ext/amatch_ext.c", "ext/pair.c"]
15
15
  s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "VERSION", "amatch.gemspec", "bin/agrep.rb", "ext/amatch_ext.c", "ext/common.h", "ext/extconf.rb", "ext/pair.c", "ext/pair.h", "install.rb", "lib/amatch.rb", "lib/amatch/.keep", "lib/amatch/polite.rb", "lib/amatch/rude.rb", "lib/amatch/version.rb", "tests/test_hamming.rb", "tests/test_jaro.rb", "tests/test_jaro_winkler.rb", "tests/test_levenshtein.rb", "tests/test_longest_subsequence.rb", "tests/test_longest_substring.rb", "tests/test_pair_distance.rb", "tests/test_sellers.rb"]
16
16
  s.homepage = "http://github.com/flori/amatch"
17
17
  s.rdoc_options = ["--title", "Amatch - Approximate Matching", "--main", "README.rdoc"]
18
18
  s.require_paths = ["lib", "ext"]
19
- s.rubygems_version = "1.8.15"
19
+ s.rubygems_version = "1.8.24"
20
20
  s.summary = "Approximate String Matching library"
21
- s.test_files = ["tests/test_sellers.rb", "tests/test_jaro.rb", "tests/test_longest_subsequence.rb", "tests/test_longest_substring.rb", "tests/test_hamming.rb", "tests/test_pair_distance.rb", "tests/test_levenshtein.rb", "tests/test_jaro_winkler.rb"]
21
+ s.test_files = ["tests/test_hamming.rb", "tests/test_jaro.rb", "tests/test_jaro_winkler.rb", "tests/test_levenshtein.rb", "tests/test_longest_subsequence.rb", "tests/test_longest_substring.rb", "tests/test_pair_distance.rb", "tests/test_sellers.rb"]
22
22
 
23
23
  if s.respond_to? :specification_version then
24
24
  s.specification_version = 3
25
25
 
26
26
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
- s.add_development_dependency(%q<gem_hadar>, ["~> 0.1.4"])
27
+ s.add_development_dependency(%q<gem_hadar>, ["~> 0.1.8"])
28
28
  s.add_development_dependency(%q<test-unit>, ["~> 2.3"])
29
+ s.add_development_dependency(%q<utils>, [">= 0"])
29
30
  s.add_runtime_dependency(%q<tins>, ["~> 0.3"])
30
31
  else
31
- s.add_dependency(%q<gem_hadar>, ["~> 0.1.4"])
32
+ s.add_dependency(%q<gem_hadar>, ["~> 0.1.8"])
32
33
  s.add_dependency(%q<test-unit>, ["~> 2.3"])
34
+ s.add_dependency(%q<utils>, [">= 0"])
33
35
  s.add_dependency(%q<tins>, ["~> 0.3"])
34
36
  end
35
37
  else
36
- s.add_dependency(%q<gem_hadar>, ["~> 0.1.4"])
38
+ s.add_dependency(%q<gem_hadar>, ["~> 0.1.8"])
37
39
  s.add_dependency(%q<test-unit>, ["~> 2.3"])
40
+ s.add_dependency(%q<utils>, [">= 0"])
38
41
  s.add_dependency(%q<tins>, ["~> 0.3"])
39
42
  end
40
43
  end
@@ -661,8 +661,8 @@ static VALUE LongestSubstring_similar(General *amatch, VALUE string)
661
661
  m = 0; \
662
662
  for (i = 0; i < a_len; i++) { \
663
663
  low = (i > max_dist ? i - max_dist : 0); \
664
- high = (i + max_dist < b_len ? i + max_dist : b_len); \
665
- for (j = low; j <= high; j++) { \
664
+ high = (i + max_dist < b_len ? i + max_dist : b_len - 1); \
665
+ for (j = low; j <= high; j++) { \
666
666
  if (!l[1][j] && a_ptr[i] == b_ptr[j]) { \
667
667
  l[0][i] = 1; \
668
668
  l[1][j] = 1; \
@@ -710,10 +710,6 @@ static VALUE LongestSubstring_similar(General *amatch, VALUE string)
710
710
  if (islower(b_ptr[i])) b_ptr[i] = toupper(b_ptr[i]); \
711
711
  }
712
712
 
713
- #define FREE_STRINGS \
714
- xfree(a_ptr); \
715
- xfree(b_ptr);
716
-
717
713
  static VALUE Jaro_match(Jaro *amatch, VALUE string)
718
714
  {
719
715
  char *a_ptr, *b_ptr;
@@ -730,7 +726,8 @@ static VALUE Jaro_match(Jaro *amatch, VALUE string)
730
726
  }
731
727
  COMPUTE_JARO
732
728
  if (amatch->ignore_case) {
733
- FREE_STRINGS
729
+ xfree(a_ptr);
730
+ xfree(b_ptr);
734
731
  }
735
732
  return rb_float_new(result);
736
733
  }
@@ -764,7 +761,8 @@ static VALUE JaroWinkler_match(JaroWinkler *amatch, VALUE string)
764
761
  }
765
762
  result = result + n*amatch->scaling_factor*(1-result);
766
763
  if (amatch->ignore_case) {
767
- FREE_STRINGS
764
+ xfree(a_ptr);
765
+ xfree(b_ptr);
768
766
  }
769
767
  return rb_float_new(result);
770
768
  }
@@ -1,6 +1,21 @@
1
1
  require 'mkmf'
2
2
  require 'rbconfig'
3
- if CONFIG['CC'] == 'gcc'
4
- CONFIG['CC'] = 'gcc -Wall '
3
+
4
+ if CONFIG['CC'] =~ /gcc/
5
+ $CFLAGS << ' -Wall'
6
+ if ENV['DEBUG']
7
+ $CFLAGS << ' -O0 -ggdb'
8
+ else
9
+ $CFLAGS << ' -O3'
10
+ end
11
+ else
12
+ $CFLAGS << ' -O3'
13
+ end
14
+ create_makefile 'amatch_ext'
15
+
16
+ # WTF, is this really the only way to get a decent output out of mkmf?
17
+ mf = File.read 'Makefile'
18
+ if mf.sub!(/V = 0/, 'V = 1')
19
+ warn "Rewriting the generated Makefile to get my compiler output displayed..."
20
+ File.open('Makefile', 'w') { |f| f.write mf }
5
21
  end
6
- create_makefile 'amatch_ext'
@@ -1,6 +1,6 @@
1
1
  module Amatch
2
2
  # Amatch version
3
- VERSION = '0.2.10'
3
+ VERSION = '0.2.11'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -1,10 +1,9 @@
1
1
  require 'test/unit'
2
2
  require 'amatch'
3
- require 'test_levenshtein'
4
3
 
5
- class TestSellers < TestLevenshtein
4
+ class TestSellers < Test::Unit::TestCase
6
5
  include Amatch
7
-
6
+
8
7
  def setup
9
8
  @d = 0.000001
10
9
  @empty = Sellers.new('')
@@ -69,7 +68,7 @@ class TestSellers < TestLevenshtein
69
68
  assert_in_delta 0.75, @simple.pattern.levenshtein_similar('est'), @d
70
69
  end
71
70
 
72
- def test_similar
71
+ def test_similar2
73
72
  assert_in_delta 1, @empty.similar(''), @d
74
73
  assert_in_delta 0, @empty.similar('not empty'), @d
75
74
  assert_in_delta 0.0, @simple.similar(''), @d
metadata CHANGED
@@ -1,71 +1,101 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: amatch
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.10
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 11
10
+ version: 0.2.11
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Florian Frank
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-02-06 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-01-16 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: gem_hadar
16
- requirement: &70350437582780 !ruby/object:Gem::Requirement
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
23
  none: false
18
- requirements:
24
+ requirements:
19
25
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 0.1.4
22
- type: :development
26
+ - !ruby/object:Gem::Version
27
+ hash: 11
28
+ segments:
29
+ - 0
30
+ - 1
31
+ - 8
32
+ version: 0.1.8
23
33
  prerelease: false
24
- version_requirements: *70350437582780
25
- - !ruby/object:Gem::Dependency
34
+ type: :development
35
+ requirement: *id001
36
+ - !ruby/object:Gem::Dependency
26
37
  name: test-unit
27
- requirement: &70350437581920 !ruby/object:Gem::Requirement
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
28
39
  none: false
29
- requirements:
40
+ requirements:
30
41
  - - ~>
31
- - !ruby/object:Gem::Version
32
- version: '2.3'
42
+ - !ruby/object:Gem::Version
43
+ hash: 5
44
+ segments:
45
+ - 2
46
+ - 3
47
+ version: "2.3"
48
+ prerelease: false
33
49
  type: :development
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: utils
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
34
62
  prerelease: false
35
- version_requirements: *70350437581920
36
- - !ruby/object:Gem::Dependency
63
+ type: :development
64
+ requirement: *id003
65
+ - !ruby/object:Gem::Dependency
37
66
  name: tins
38
- requirement: &70350437581240 !ruby/object:Gem::Requirement
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
39
68
  none: false
40
- requirements:
69
+ requirements:
41
70
  - - ~>
42
- - !ruby/object:Gem::Version
43
- version: '0.3'
44
- type: :runtime
71
+ - !ruby/object:Gem::Version
72
+ hash: 13
73
+ segments:
74
+ - 0
75
+ - 3
76
+ version: "0.3"
45
77
  prerelease: false
46
- version_requirements: *70350437581240
47
- description: ! 'Amatch is a library for approximate string matching and searching
48
- in strings.
49
-
50
- Several algorithms can be used to do this, and it''s also possible to compute a
51
-
78
+ type: :runtime
79
+ requirement: *id004
80
+ description: |
81
+ Amatch is a library for approximate string matching and searching in strings.
82
+ Several algorithms can be used to do this, and it's also possible to compute a
52
83
  similarity metric number between 0.0 and 1.0 for two given strings.
53
84
 
54
- '
55
85
  email: flori@ping.de
56
- executables:
86
+ executables:
57
87
  - agrep.rb
58
- extensions:
88
+ extensions:
59
89
  - ext/extconf.rb
60
- extra_rdoc_files:
90
+ extra_rdoc_files:
61
91
  - README.rdoc
62
92
  - lib/amatch.rb
63
- - lib/amatch/version.rb
64
- - lib/amatch/rude.rb
65
93
  - lib/amatch/polite.rb
94
+ - lib/amatch/rude.rb
95
+ - lib/amatch/version.rb
66
96
  - ext/amatch_ext.c
67
97
  - ext/pair.c
68
- files:
98
+ files:
69
99
  - .gitignore
70
100
  - .travis.yml
71
101
  - CHANGES
@@ -97,42 +127,47 @@ files:
97
127
  - tests/test_sellers.rb
98
128
  homepage: http://github.com/flori/amatch
99
129
  licenses: []
130
+
100
131
  post_install_message:
101
- rdoc_options:
132
+ rdoc_options:
102
133
  - --title
103
134
  - Amatch - Approximate Matching
104
135
  - --main
105
136
  - README.rdoc
106
- require_paths:
137
+ require_paths:
107
138
  - lib
108
139
  - ext
109
- required_ruby_version: !ruby/object:Gem::Requirement
140
+ required_ruby_version: !ruby/object:Gem::Requirement
110
141
  none: false
111
- requirements:
112
- - - ! '>='
113
- - !ruby/object:Gem::Version
114
- version: '0'
115
- segments:
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ hash: 3
146
+ segments:
116
147
  - 0
117
- hash: -987218193532166989
118
- required_rubygems_version: !ruby/object:Gem::Requirement
148
+ version: "0"
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
150
  none: false
120
- requirements:
121
- - - ! '>='
122
- - !ruby/object:Gem::Version
123
- version: '0'
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ hash: 3
155
+ segments:
156
+ - 0
157
+ version: "0"
124
158
  requirements: []
159
+
125
160
  rubyforge_project:
126
- rubygems_version: 1.8.15
161
+ rubygems_version: 1.8.24
127
162
  signing_key:
128
163
  specification_version: 3
129
164
  summary: Approximate String Matching library
130
- test_files:
131
- - tests/test_sellers.rb
165
+ test_files:
166
+ - tests/test_hamming.rb
132
167
  - tests/test_jaro.rb
168
+ - tests/test_jaro_winkler.rb
169
+ - tests/test_levenshtein.rb
133
170
  - tests/test_longest_subsequence.rb
134
171
  - tests/test_longest_substring.rb
135
- - tests/test_hamming.rb
136
172
  - tests/test_pair_distance.rb
137
- - tests/test_levenshtein.rb
138
- - tests/test_jaro_winkler.rb
173
+ - tests/test_sellers.rb