damerau-levenshtein 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67c6faa0317240defb0210ab642c514942855fdb
4
- data.tar.gz: 4ad7bd77b1eb7fec82c489e78d572fa75f25c2c9
3
+ metadata.gz: c8156a6bf2a0032eb58ce73f65532b8166592b0c
4
+ data.tar.gz: a3014e1f2cdd6aaa14438cee6fcf83a51edcdc05
5
5
  SHA512:
6
- metadata.gz: fd15b89736839baa55d4023c15a5ff8511364b55b4e585c3bf68dcd4bb75e62e9e5dfdff1505691694c502c875f19b74c996691dec7261d184be97e0b0636ede
7
- data.tar.gz: ae7e131dcd30ed4f3d98c78bfbe4359a63392c34f301c76aef975fbf94ec9f60abd9e61f500f71c0a1bfe9e493080eb6291c50a736d2c68802681524ad580f47
6
+ metadata.gz: a359dd70503719ae7d213059db6b255e113cd9795fb02b79d4d43d71244f47e874f86fb206ed00916c91d07ef44594ce117d801104fa2b7593b2ed207c270957
7
+ data.tar.gz: e91104f2e39d2a3f536c5b6819ad10d65b9cc6839481b8522ab4025bffe87310568f818a5bac0c2c7c81f66b2bddd1f6302411460e00f844a3e74da74cf157b3
@@ -1 +1 @@
1
- 2.4.1
1
+ 2.3.4
@@ -1,6 +1,4 @@
1
1
  rvm:
2
- - 2.0
3
- - 2.1
4
2
  - 2.2
5
3
  - 2.3
6
4
  - 2.4
@@ -1,6 +1,8 @@
1
1
  damerau-levenshtein CHANGELOG
2
2
  =============================
3
3
 
4
+ 1.3.1 -- gems update
5
+
4
6
  1.3.0 -- (issue #10) shows difference between two strings
5
7
 
6
8
  1.2.0 -- add edit distance for array of integers (by @azhi)
data/README.md CHANGED
@@ -65,7 +65,7 @@ dl.distance("Something", "Smoething", 0) #returns 2
65
65
  dl.distance("Something", "meSothing", 2) #returns 2 instead of 4
66
66
  ```
67
67
 
68
- * comparison of words with utf-8 characters should work fine:
68
+ * comparison of words with UTF-8 characters should work fine:
69
69
 
70
70
  ```ruby
71
71
  dl.distance("Sjöstedt", "Sjostedt") #returns 1
@@ -175,6 +175,31 @@ differ.run("Something", "smthng")
175
175
 
176
176
  ```
177
177
 
178
+ Or with parsing:
179
+
180
+ ```ruby
181
+ require "damerau-levenshtein"
182
+ require "nokogiri"
183
+
184
+ differ = DamerauLevenshtein::Differ.new
185
+ res = differ.run("Something", "Smothing!")
186
+ nodes = Nokogiri::XML("<root>#{res.first}</root>")
187
+
188
+ markup = nodes.root.children.map do |n|
189
+ case n.name
190
+ when "text"
191
+ n.text
192
+ when "del"
193
+ "~~#{n.children.first.text}~~"
194
+ when "ins"
195
+ "*#{n.children.first.text}*"
196
+ when "subst"
197
+ "**#{n.children.first.text}**"
198
+ end
199
+ end.join("")
200
+
201
+ puts markup
202
+ ```
178
203
 
179
204
  ## Contributing to damerau-levenshtein ##
180
205
 
@@ -7,6 +7,7 @@ require "damerau-levenshtein/version"
7
7
  # rubocop:disable Metrics/BlockLength
8
8
 
9
9
  Gem::Specification.new do |s|
10
+ s.required_ruby_version = "~> 2.3"
10
11
  s.name = "damerau-levenshtein"
11
12
  s.version = DamerauLevenshtein::VERSION
12
13
  s.homepage = "https://github.com/GlobalNamesArchitecture/damerau-levenshtein"
@@ -26,18 +27,18 @@ Gem::Specification.new do |s|
26
27
  s.extensions = ["ext/damerau_levenshtein/extconf.rb"]
27
28
  s.require_paths = ["lib", "lib/damerau-levenshtein"]
28
29
 
29
- s.add_development_dependency "rspec", "~> 3.5"
30
+ s.add_development_dependency "rspec", "~> 3.7"
30
31
  # activesupport >= 5.0 does not support Ruby < 2.2
31
- s.add_development_dependency "activesupport", "~> 4.2"
32
+ s.add_development_dependency "activesupport", "~> 5.1"
33
+ s.add_development_dependency "bundler", "~> 1.16"
32
34
  s.add_development_dependency "byebug", "~> 9.0"
33
- s.add_development_dependency "cucumber", "~> 2.4"
34
- s.add_development_dependency "ruby-prof", "~> 0.15"
35
- s.add_development_dependency "shoulda", "~> 3.5"
36
- s.add_development_dependency "rubocop", "~> 0.41"
37
35
  s.add_development_dependency "coveralls", "~> 0.8"
38
- s.add_development_dependency "bundler", "~> 1.11"
39
- s.add_development_dependency "rake", "~> 11.2"
36
+ s.add_development_dependency "cucumber", "~> 3.1"
37
+ s.add_development_dependency "rake", "~> 12.3"
40
38
  s.add_development_dependency "rake-compiler", "~> 1.0"
39
+ s.add_development_dependency "rubocop", "~> 0.52"
40
+ s.add_development_dependency "ruby-prof", "~> 0.17"
41
+ s.add_development_dependency "shoulda", "~> 3.5"
41
42
  end
42
43
 
43
44
  # rubocop:enable all
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require_relative "damerau-levenshtein/version"
@@ -5,7 +5,7 @@ module DamerauLevenshtein
5
5
  # resolution
6
6
  class Differ
7
7
  FORMATS = %i[raw tag].freeze
8
- attr_accessor :format
8
+ attr_reader :format
9
9
 
10
10
  def initialize
11
11
  @format = :tag
@@ -50,7 +50,7 @@ module DamerauLevenshtein
50
50
  raw.each_with_index do |e, i|
51
51
  process_entry(e, i, data)
52
52
  end
53
- data[:res] << format("</%s>", data[:type]) if data[:type] != :same
53
+ data[:res] << format("</%<type>s>", data) if data[:type] != :same
54
54
  data[:res].join("")
55
55
  end
56
56
 
@@ -58,14 +58,14 @@ module DamerauLevenshtein
58
58
  if data[:type] && e[:type] != data[:type]
59
59
  insert_tags(e, data)
60
60
  elsif data[:type].nil?
61
- data[:res] << format("<%s>", e[:type]) if e[:type] != :same
61
+ data[:res] << format("<%<type>s>", e) if e[:type] != :same
62
62
  end
63
63
  insert_letter(e, i, data)
64
64
  end
65
65
 
66
66
  def insert_tags(entry, data)
67
- data[:res] << format("</%s>", data[:type]) if data[:type] != :same
68
- data[:res] << format("<%s>", entry[:type]) if entry[:type] != :same
67
+ data[:res] << format("</%<type>s>", data) if data[:type] != :same
68
+ data[:res] << format("<%<type>s>", entry) if entry[:type] != :same
69
69
  end
70
70
 
71
71
  def insert_letter(entry, index, data)
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Damerau Levenshtein algorithm
4
4
  module DamerauLevenshtein
5
- VERSION = "1.3.0"
5
+ VERSION = "1.3.1"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: damerau-levenshtein
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Mozzherin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-07 00:00:00.000000000 Z
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -16,154 +16,154 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.5'
19
+ version: '3.7'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.5'
26
+ version: '3.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '4.2'
33
+ version: '5.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4.2'
40
+ version: '5.1'
41
41
  - !ruby/object:Gem::Dependency
42
- name: byebug
42
+ name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '9.0'
47
+ version: '1.16'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '9.0'
54
+ version: '1.16'
55
55
  - !ruby/object:Gem::Dependency
56
- name: cucumber
56
+ name: byebug
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.4'
61
+ version: '9.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '2.4'
68
+ version: '9.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: ruby-prof
70
+ name: coveralls
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.15'
75
+ version: '0.8'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.15'
82
+ version: '0.8'
83
83
  - !ruby/object:Gem::Dependency
84
- name: shoulda
84
+ name: cucumber
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.5'
89
+ version: '3.1'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.5'
96
+ version: '3.1'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rubocop
98
+ name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.41'
103
+ version: '12.3'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0.41'
110
+ version: '12.3'
111
111
  - !ruby/object:Gem::Dependency
112
- name: coveralls
112
+ name: rake-compiler
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0.8'
117
+ version: '1.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0.8'
124
+ version: '1.0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: bundler
126
+ name: rubocop
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '1.11'
131
+ version: '0.52'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '1.11'
138
+ version: '0.52'
139
139
  - !ruby/object:Gem::Dependency
140
- name: rake
140
+ name: ruby-prof
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '11.2'
145
+ version: '0.17'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '11.2'
152
+ version: '0.17'
153
153
  - !ruby/object:Gem::Dependency
154
- name: rake-compiler
154
+ name: shoulda
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '1.0'
159
+ version: '3.5'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '1.0'
166
+ version: '3.5'
167
167
  description: This gem implements pure Levenshtein algorithm, Damerau modification
168
168
  (where 2 character transposition counts as 1 edit distance). It also includes Boehmer
169
169
  & Rees 2008 modification, to handle transposition in blocks with more than 2 characters
@@ -204,9 +204,9 @@ require_paths:
204
204
  - lib/damerau-levenshtein
205
205
  required_ruby_version: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - ">="
207
+ - - "~>"
208
208
  - !ruby/object:Gem::Version
209
- version: '0'
209
+ version: '2.3'
210
210
  required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  requirements:
212
212
  - - ">="
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  version: '0'
215
215
  requirements: []
216
216
  rubyforge_project:
217
- rubygems_version: 2.6.11
217
+ rubygems_version: 2.5.2
218
218
  signing_key:
219
219
  specification_version: 4
220
220
  summary: Calculation of editing distance for 2 strings using Levenshtein or Damerau-Levenshtein