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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mindwords.rb +25 -27
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85426d79852d7306a24090b6c4fca89929b8004d4c084e60e2a19e6cd684d43d
|
4
|
+
data.tar.gz: ae8b9179bc0d486a75c12ccc5a241e52ed58e82cd32919957925f26a68d91527
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf8ef8f8031725781221f97f0779e9660f03a193354d62e5206302b2cfe54cb4296d5360d093e70b6e5835164d3e9dbcf18d486b33dcb85b084f7872db5e0280
|
7
|
+
data.tar.gz: 507bf3d566e2f3d8377efe32ff559e2d8fcc832ade715bbb33aa305c7a20e0d4355da90eed7513066159aa821864e38ee5f959ddb9bb4a85ce38a2e896f94022
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/mindwords.rb
CHANGED
@@ -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
|
-
|
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[
|
255
|
-
|
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
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
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.
|
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-
|
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
|