mindwords 0.1.0 → 0.1.1
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 +31 -22
- metadata +1 -1
- 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: 7e0812d6fb0ec5d2b09105de96160ed832007144ac15f036418e1e9207234b60
|
4
|
+
data.tar.gz: 1c121aae9d22bc87535fb0c8df0c41333530dfa180970bd9685488b49b209f9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 706128a061c541504d6214d0a0cd1bdf23aecb3794761c43d842c9cd24b34d704ae7c1fa70b9ddba67cb8a785b88a72e37f462fe4f6eb5f5c9bfb38c81471f57
|
7
|
+
data.tar.gz: ad5dce9ac225ba26711d6ab92c16d7fe7a2dcf906173ea52318fe7452437da685227340d3cdaf8061842f3ab5704cf7494a47f5fea9ec122f09cac930b3cd0a7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/mindwords.rb
CHANGED
@@ -44,27 +44,11 @@ class MindWords
|
|
44
44
|
a = rexlize(h)
|
45
45
|
doc = Rexle.new(['root', {}, '', *a])
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
next if rows.length < 2
|
53
|
-
|
54
|
-
rows[1..-1].each do |e2|
|
55
|
-
puts 'e2: ' + e2.name.inspect if @debug
|
56
|
-
duplicates << [e.backtrack.to_s, e2.backtrack.to_s] #unless e2.has_elements?
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
duplicates.each do |path, oldpath|
|
61
|
-
e = doc.element(path);
|
62
|
-
e2 = doc.element(oldpath);
|
63
|
-
e2.parent.add e
|
64
|
-
e2.delete
|
65
|
-
end
|
66
|
-
|
67
|
-
# remove redundant nodes
|
47
|
+
|
48
|
+
# remove duplicates which appear in the same branch above the nested node
|
49
|
+
rm_duplicates(doc)
|
50
|
+
|
51
|
+
# remove redundant nodes (outsiders)
|
68
52
|
# a redundant node is where all children exist in existing nested nodes
|
69
53
|
|
70
54
|
redundants = doc.root.elements.map do |e|
|
@@ -78,7 +62,8 @@ class MindWords
|
|
78
62
|
end
|
79
63
|
|
80
64
|
redundants.compact.each {|x| doc.element(x).delete }
|
81
|
-
|
65
|
+
rm_duplicates(doc)
|
66
|
+
|
82
67
|
@outline = treeize doc.root
|
83
68
|
|
84
69
|
end
|
@@ -106,6 +91,30 @@ class MindWords
|
|
106
91
|
end
|
107
92
|
|
108
93
|
end
|
94
|
+
|
95
|
+
def rm_duplicates(doc)
|
96
|
+
|
97
|
+
duplicates = []
|
98
|
+
doc.root.each_recursive do |e|
|
99
|
+
|
100
|
+
puts 'e: ' + e.name.inspect if @debug
|
101
|
+
rows = e.parent.xpath('//' + e.name)
|
102
|
+
next if rows.length < 2
|
103
|
+
|
104
|
+
rows[1..-1].each do |e2|
|
105
|
+
puts 'e2: ' + e2.name.inspect if @debug
|
106
|
+
duplicates << [e.backtrack.to_s, e2.backtrack.to_s]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
duplicates.each do |path, oldpath|
|
111
|
+
e = doc.element(path);
|
112
|
+
e2 = doc.element(oldpath);
|
113
|
+
e2.parent.add e
|
114
|
+
e2.delete
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
109
118
|
|
110
119
|
def treeize(node, indent=0)
|
111
120
|
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|