mindwords 0.6.7 → 0.8.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/lib/mindwords.rb +190 -6
- data.tar.gz.sig +0 -0
- metadata +8 -29
- metadata.gz.sig +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7201b9f1950ecacaf5bac313bf8dd0c7485efe308829fa8bc73d5fa442cca5e
|
4
|
+
data.tar.gz: e61b0229f2c75c11c71f68ba6c0139bd6f5ed8110a78c66da5d66aa6144e84c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5db0ccb709a730e47bdf753aa82956cce15d662f6fa35a8921b6580ecf2624b64b1187b4ce5eaaf5cb63e1e3b437a114097ed85b6945e8a8877451a5706ac4e0
|
7
|
+
data.tar.gz: 64826bf627e098697d504116ea6cadd7b93daee1314ebb98506af685d4b600e6e5b990200d8c380ee49d9b1b59b44565aec6feba631b310dcee0db1afec11824
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/mindwords.rb
CHANGED
@@ -3,8 +3,10 @@
|
|
3
3
|
# file: mindwords.rb
|
4
4
|
|
5
5
|
require 'rexle'
|
6
|
-
require '
|
6
|
+
require 'rxfreadwrite'
|
7
7
|
require 'line-tree'
|
8
|
+
require 'polyrex'
|
9
|
+
|
8
10
|
|
9
11
|
module HashCopy
|
10
12
|
refine Hash do
|
@@ -19,8 +21,9 @@ end
|
|
19
21
|
class MindWords
|
20
22
|
using ColouredText
|
21
23
|
using HashCopy
|
22
|
-
include
|
24
|
+
include RXFReadWriteModule
|
23
25
|
|
26
|
+
attr_reader :words_missing
|
24
27
|
attr_accessor :lines, :filepath
|
25
28
|
|
26
29
|
def initialize(raws='', parent: nil, debug: false)
|
@@ -72,13 +75,57 @@ class MindWords
|
|
72
75
|
|
73
76
|
def import(raws)
|
74
77
|
|
75
|
-
s, type =
|
78
|
+
s, type = RXFReader.read raws
|
76
79
|
|
77
80
|
@filepath = raws if type == :file or type == :dfs
|
78
|
-
|
79
|
-
|
81
|
+
rawlines = (s.strip.gsub(/(^\n|\r)/,'') + "\n").lines.uniq
|
82
|
+
rawlines.shift if rawlines.first =~ /<\?mindwords\?>/
|
83
|
+
|
84
|
+
# remove mindwords lines which don't have a hashtag
|
85
|
+
lines = rawlines.reject do |line|
|
86
|
+
|
87
|
+
found = line[/^\w+[^#]+$/]
|
88
|
+
|
89
|
+
if found then
|
90
|
+
puts ('no hashtag found on this line -> ' + line).warn
|
91
|
+
end
|
92
|
+
|
93
|
+
found
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
#--- handle indented text, indicated there are *groups* of words
|
98
|
+
|
99
|
+
s2 = lines.join.gsub(/\n\s*$/,'')
|
100
|
+
puts s2 if @debug
|
101
|
+
a = s2.strip.split(/(?=^\w+)/)
|
102
|
+
a2 = a.inject([]) do |r,x|
|
103
|
+
|
104
|
+
if x =~ /\n\s+/ then
|
80
105
|
|
81
|
-
|
106
|
+
a4 = x.lines[1..-1].map do |line|
|
107
|
+
|
108
|
+
puts 'x.lines[0]: ' + x.lines[0].inspect if @debug
|
109
|
+
hashtag = if x.lines[0][/ /] then
|
110
|
+
x.lines[0].gsub(/\b\w/) {|x| x.upcase}.gsub(/ /,'')
|
111
|
+
else
|
112
|
+
x.lines[0]
|
113
|
+
end
|
114
|
+
|
115
|
+
"%s #%s" % [line.strip, hashtag]
|
116
|
+
end
|
117
|
+
|
118
|
+
r.concat a4
|
119
|
+
|
120
|
+
else
|
121
|
+
r << x
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
#-- end of indented text handler
|
127
|
+
|
128
|
+
@lines = a2.inject([]) do |r,line|
|
82
129
|
|
83
130
|
# the following does 2 things:
|
84
131
|
# 1. splits words separated by a bar (|) onto their own line
|
@@ -345,6 +392,7 @@ class MindWords
|
|
345
392
|
|
346
393
|
a = rexlize(h)
|
347
394
|
doc = Rexle.new(['root', {}, '', *a])
|
395
|
+
puts 'doc.xml: ' + doc.xml(pretty: true) if @debug
|
348
396
|
|
349
397
|
# apply node nesting
|
350
398
|
|
@@ -361,6 +409,7 @@ class MindWords
|
|
361
409
|
|
362
410
|
end
|
363
411
|
|
412
|
+
puts 'after nesting; doc.xml: ' + doc.xml(pretty: true) if @debug
|
364
413
|
|
365
414
|
# remove duplicates which appear in the same branch above the nested node
|
366
415
|
rm_duplicates(doc)
|
@@ -408,6 +457,45 @@ class MindWords
|
|
408
457
|
|
409
458
|
@outline = treeize node
|
410
459
|
|
460
|
+
# ----
|
461
|
+
|
462
|
+
# It's common for words to be missing from the outline, either because
|
463
|
+
# they have erroneously been flagged as redundant or lack specific hashtag
|
464
|
+
# context. Below, we attempt to identify the missing words with a
|
465
|
+
# suggestion on how to fix it.
|
466
|
+
|
467
|
+
words = @outline.lines.map(&:strip)
|
468
|
+
orig_words = to_s().lines.map {|x| x[/^[^#]+(?= #)/]}.compact
|
469
|
+
@words_missing = orig_words - words
|
470
|
+
|
471
|
+
if @words_missing.any? then
|
472
|
+
|
473
|
+
tags = []
|
474
|
+
@words_missing.inject(tags) do |r,word|
|
475
|
+
|
476
|
+
found = to_s().lines.grep(/#{word}/)
|
477
|
+
|
478
|
+
if found then
|
479
|
+
r << found.first.scan(/#\w+/).map {|x| x[1..-1]}
|
480
|
+
else
|
481
|
+
r
|
482
|
+
end
|
483
|
+
|
484
|
+
end
|
485
|
+
|
486
|
+
add_sugg = tags.uniq.map do |atag|
|
487
|
+
("%s #%s" % [atag[0], atag[1]]).bg_black
|
488
|
+
end
|
489
|
+
|
490
|
+
puts ('@words_missing: ' + @words_missing.join(', ') ).warn
|
491
|
+
puts "suggestion: try adding the following:".info
|
492
|
+
puts add_sugg.join("\n")
|
493
|
+
puts
|
494
|
+
|
495
|
+
end
|
496
|
+
|
497
|
+
# ----
|
498
|
+
|
411
499
|
node.root.each_recursive do |e|
|
412
500
|
|
413
501
|
e.attributes[:id] = e.attributes[:title].downcase.gsub(/ +/,'-')
|
@@ -536,3 +624,99 @@ EOF
|
|
536
624
|
end
|
537
625
|
|
538
626
|
end
|
627
|
+
|
628
|
+
class MindWordsPlus
|
629
|
+
|
630
|
+
attr_reader :to_px
|
631
|
+
|
632
|
+
def initialize(s, fields: %w(title content), debug: false)
|
633
|
+
|
634
|
+
lt = LineTree.new(s)
|
635
|
+
h = lt.to_h
|
636
|
+
|
637
|
+
mw = MindWords.new(h.keys.join("\n"))
|
638
|
+
outline = mw.to_outline
|
639
|
+
|
640
|
+
out = outline.lines.map do |line|
|
641
|
+
|
642
|
+
word = line[/\w[^$]+/]
|
643
|
+
|
644
|
+
found = h.keys.find do |key, value|
|
645
|
+
|
646
|
+
if debug then
|
647
|
+
puts 'key2: ' + key[/^[^#]+(?= #)/].inspect
|
648
|
+
puts 'word: ' + word.chomp.inspect
|
649
|
+
end
|
650
|
+
|
651
|
+
word.chomp == key[/^[^#]+(?= #)/]
|
652
|
+
end
|
653
|
+
|
654
|
+
puts 'found: ' + found.inspect if debug
|
655
|
+
|
656
|
+
if found and h[found][:body] then
|
657
|
+
puts '***' + h[found][:body].keys.inspect if debug
|
658
|
+
line.chomp + ' # ' + h[found][:body].keys.join('<br/>') + "\n"
|
659
|
+
else
|
660
|
+
line
|
661
|
+
end
|
662
|
+
|
663
|
+
end
|
664
|
+
|
665
|
+
puts out.join if debug
|
666
|
+
|
667
|
+
px = Polyrex.new(schema: "entries[title]/entry[#{fields.join(', ')}]",
|
668
|
+
delimiter: ' # ')
|
669
|
+
px.import out.join
|
670
|
+
@px = px
|
671
|
+
|
672
|
+
end
|
673
|
+
|
674
|
+
def to_ph()
|
675
|
+
|
676
|
+
lines = []
|
677
|
+
|
678
|
+
@px.each_recursive do |x, parent, level|
|
679
|
+
|
680
|
+
if level.to_i < 3 then
|
681
|
+
line = ("\n" + '#' * (level.to_i + 1)) + ' ' + x.title + "\n\n"
|
682
|
+
else
|
683
|
+
line = '*' + ' ' + x.title + "\n"
|
684
|
+
end
|
685
|
+
|
686
|
+
if x.content.length >= 1 then
|
687
|
+
txt = '- ' + x.content.gsub('<','<').gsub('>','>')
|
688
|
+
line += "\n" + txt.gsub('<br/>',"\n- ") + "\n"
|
689
|
+
end
|
690
|
+
|
691
|
+
lines << line
|
692
|
+
|
693
|
+
end
|
694
|
+
|
695
|
+
lines.join.gsub(/\n\n\n/,"\n\n")
|
696
|
+
end
|
697
|
+
|
698
|
+
def to_px()
|
699
|
+
@px
|
700
|
+
end
|
701
|
+
|
702
|
+
def to_tree()
|
703
|
+
|
704
|
+
lines = []
|
705
|
+
@px.each_recursive do |x, parent, level|
|
706
|
+
|
707
|
+
line = (' ' * level) + x.title
|
708
|
+
|
709
|
+
if x.content.length >= 1 then
|
710
|
+
txt = x.content.gsub('<','<').gsub('>','>')
|
711
|
+
indent = ' ' * (level+1) + '* '
|
712
|
+
line += "\n" + indent + txt.gsub('<br/>',"\n" + indent)
|
713
|
+
end
|
714
|
+
|
715
|
+
lines << line
|
716
|
+
end
|
717
|
+
|
718
|
+
lines.join("\n")
|
719
|
+
|
720
|
+
end
|
721
|
+
|
722
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
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.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,48 +35,28 @@ cert_chain:
|
|
35
35
|
eUqhPOSrxIRLebVebvo/SHN6+ed3Q1tXowsbLGCT9QwqbaZ5MZ7zks92mIWeJvsA
|
36
36
|
JdpabIXfcOANNKd0ha4NO+Yu
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2022-
|
38
|
+
date: 2022-04-08 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
|
-
name:
|
41
|
+
name: polyrex
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '1.4'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: 1.4.1
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '1.4'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: rxfhelper
|
62
|
-
requirement: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - "~>"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '1.2'
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 1.2.1
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - "~>"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '1.2'
|
77
|
-
- - ">="
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: 1.2.1
|
59
|
+
version: 1.4.1
|
80
60
|
description:
|
81
61
|
email: digital.robertson@gmail.com
|
82
62
|
executables: []
|
@@ -103,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
83
|
- !ruby/object:Gem::Version
|
104
84
|
version: '0'
|
105
85
|
requirements: []
|
106
|
-
|
107
|
-
rubygems_version: 2.7.10
|
86
|
+
rubygems_version: 3.2.22
|
108
87
|
signing_key:
|
109
88
|
specification_version: 4
|
110
89
|
summary: Helps get what's in your mind into a structure using words and hashtags.
|
metadata.gz.sig
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
2
|
2
|
-
|
3
|
-
|
1
|
+
T6&�'`sV����>�䟂�є�Yx���^F=f���mq�2pf�o6ܢ3�8��f�.!c"�)�&.�Yj�������g�v�]h|
|
2
|
+
�ij�|�_A*��˱�F�G��0P�(�
|
3
|
+
��ǚ�K��a��W���}�s�W��zv�� ��d
|