mindwords 0.3.1 → 0.4.0

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
  SHA256:
3
- metadata.gz: 6221b29c92e35c56991faead9b0065df928bb5ce5664f9511ad36a41b9382e9c
4
- data.tar.gz: 9aefdce231368e36caf338567b5b8063a12e12c5468a5bd92c7395db04ff28bc
3
+ metadata.gz: 85426d79852d7306a24090b6c4fca89929b8004d4c084e60e2a19e6cd684d43d
4
+ data.tar.gz: ae8b9179bc0d486a75c12ccc5a241e52ed58e82cd32919957925f26a68d91527
5
5
  SHA512:
6
- metadata.gz: cf7874e88c03ae3148102bf2ad8ecc539502c16bd620208303f54ea750262b9041de7c97b4c5bbf90b0aaf33a381f935b03be9228b1131be467c314bbd6b8344
7
- data.tar.gz: d98408eab67356ef1312e3464ec671a381d149e7d2584ab63df6c87e4098d22c59e032dc360cd819fca2cd74d94071a5a8e400f4f87616e058f6f59a4b467c25
6
+ metadata.gz: bf8ef8f8031725781221f97f0779e9660f03a193354d62e5206302b2cfe54cb4296d5360d093e70b6e5835164d3e9dbcf18d486b33dcb85b084f7872db5e0280
7
+ data.tar.gz: 507bf3d566e2f3d8377efe32ff559e2d8fcc832ade715bbb33aa305c7a20e0d4355da90eed7513066159aa821864e38ee5f959ddb9bb4a85ce38a2e896f94022
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -47,24 +47,25 @@ class MindWords
47
47
 
48
48
  @hashtags = h.deep_clone.sort.map {|tag, fields| [tag, fields.sort]}.to_h
49
49
 
50
- # does the key exist as a field? Nesting of hash object is performed here.
51
-
52
- h.keys.each do |key|
53
-
54
- r = h.detect {|_, value| value.include? key}
55
- next unless r
56
- h[r.first].delete key
57
- h[r.first] << {key => h[key]}
58
- #puts r.inspect
59
- h.delete key
60
-
61
- end
62
-
63
- @h = h
64
50
 
65
51
  a = rexlize(h)
66
52
  doc = Rexle.new(['root', {}, '', *a])
67
53
 
54
+ # apply node nesting
55
+
56
+ doc.root.elements.each do |e|
57
+
58
+ doc.root.xpath('//' + e.name).each do |e2|
59
+
60
+ next if e2 === e
61
+
62
+ e2.parent.add e
63
+ e2.delete
64
+
65
+ end
66
+
67
+ end
68
+
68
69
 
69
70
  # remove duplicates which appear in the same branch above the nested node
70
71
  rm_duplicates(doc)
@@ -83,7 +84,7 @@ class MindWords
83
84
  end
84
85
 
85
86
  redundants.compact.each {|x| doc.element(x).delete }
86
- rm_duplicates(doc)
87
+
87
88
 
88
89
  node = if parent then
89
90
  found = doc.root.element('//' + parent)
@@ -245,24 +246,22 @@ class MindWords
245
246
  def rm_duplicates(doc)
246
247
 
247
248
  duplicates = []
249
+
248
250
  doc.root.each_recursive do |e|
249
251
 
250
- puts 'e: ' + e.name.inspect if @debug
251
252
  rows = e.parent.xpath('//' + e.name)
252
253
  next if rows.length < 2
253
254
 
254
- rows[1..-1].each do |e2|
255
- puts 'e2: ' + e2.name.inspect if @debug
256
- duplicates << [e.backtrack.to_s, e2.backtrack.to_s]
257
- end
255
+ rows[0..-2].each {|e2| duplicates << e.backtrack.to_s }
256
+
258
257
  end
259
258
 
260
- duplicates.each do |path, oldpath|
261
- e = doc.element(path);
262
- e2 = doc.element(oldpath);
263
- next unless e2
264
- e2.parent.add e
265
- e2.delete
259
+ duplicates.each do |path|
260
+
261
+ puts 'path: ' + path.inspect if @debug
262
+ e = doc.element(path)
263
+ e.delete if e
264
+
266
265
  end
267
266
 
268
267
  end
@@ -304,4 +303,3 @@ class MindWords
304
303
  end
305
304
 
306
305
  end
307
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mindwords
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  aWH7D2AmhOpqNwWnPHzWR/yzpigAVTrvpHfRxZleQj6Z/090nIH2KR0RdioMmPFq
36
36
  3+574KQzs/gR9Y5a+iMcvHRN
37
37
  -----END CERTIFICATE-----
38
- date: 2021-01-20 00:00:00.000000000 Z
38
+ date: 2021-01-22 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: line-tree
metadata.gz.sig CHANGED
Binary file