mindwords 0.6.6 → 0.8.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/lib/mindwords.rb +145 -4
- data.tar.gz.sig +0 -0
- metadata +30 -51
- 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: 1f5bf74dd560883c0f522b3bf9eb94ba34e1655360347bb25871762e4c592cc1
|
4
|
+
data.tar.gz: 8da5c28a10e9086c72f82eb7615af347da8ec80432249f4716f866c6450b8baf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 361eee1873d6b3aa00ccfc415485c86723e28f398b19824d2e9f7b42322304579a9d672db7e4f13b5caa6711fee38028c4a0e361bdddf27451417a77a5476d64
|
7
|
+
data.tar.gz: 1eb29c350266e6122059017955e2ae615fb8368aec887df5fc6a6ac18aed7d8a3fbfe1ea0cdc6e6fe2050a55d0b7b9cd753e1280d2b101a0a765d9d6d29603fa
|
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,7 +21,9 @@ end
|
|
19
21
|
class MindWords
|
20
22
|
using ColouredText
|
21
23
|
using HashCopy
|
24
|
+
include RXFReadWriteModule
|
22
25
|
|
26
|
+
attr_reader :words_missing
|
23
27
|
attr_accessor :lines, :filepath
|
24
28
|
|
25
29
|
def initialize(raws='', parent: nil, debug: false)
|
@@ -64,14 +68,14 @@ class MindWords
|
|
64
68
|
found = search(title)
|
65
69
|
found.hashtags() if found
|
66
70
|
else
|
67
|
-
@parent.attributes[:hashtags].split if @parent
|
71
|
+
@parent.attributes[:hashtags].split if @parent and @parent.attributes[:hashtags]
|
68
72
|
end
|
69
73
|
|
70
74
|
end
|
71
75
|
|
72
76
|
def import(raws)
|
73
77
|
|
74
|
-
s, type =
|
78
|
+
s, type = RXFReader.read raws
|
75
79
|
|
76
80
|
@filepath = raws if type == :file or type == :dfs
|
77
81
|
lines = (s.strip.gsub(/(^\n|\r)/,'') + "\n").lines.uniq
|
@@ -124,7 +128,7 @@ class MindWords
|
|
124
128
|
|
125
129
|
puts 'before save' if @debug
|
126
130
|
|
127
|
-
|
131
|
+
FileX.write file, to_s()
|
128
132
|
|
129
133
|
end
|
130
134
|
|
@@ -344,6 +348,7 @@ class MindWords
|
|
344
348
|
|
345
349
|
a = rexlize(h)
|
346
350
|
doc = Rexle.new(['root', {}, '', *a])
|
351
|
+
puts 'doc.xml: ' + doc.xml(pretty: true) if @debug
|
347
352
|
|
348
353
|
# apply node nesting
|
349
354
|
|
@@ -360,6 +365,7 @@ class MindWords
|
|
360
365
|
|
361
366
|
end
|
362
367
|
|
368
|
+
puts 'after nesting; doc.xml: ' + doc.xml(pretty: true) if @debug
|
363
369
|
|
364
370
|
# remove duplicates which appear in the same branch above the nested node
|
365
371
|
rm_duplicates(doc)
|
@@ -407,6 +413,45 @@ class MindWords
|
|
407
413
|
|
408
414
|
@outline = treeize node
|
409
415
|
|
416
|
+
# ----
|
417
|
+
|
418
|
+
# It's common for words to be missing from the outline, either because
|
419
|
+
# they have erroneously been flagged as redundant or lack specific hashtag
|
420
|
+
# context. Below, we attempt to identify the missing words with a
|
421
|
+
# suggestion on how to fix it.
|
422
|
+
|
423
|
+
words = @outline.lines.map(&:strip)
|
424
|
+
orig_words = to_s().lines.map {|x| x[/^[^#]+(?= #)/]}.compact
|
425
|
+
@words_missing = orig_words - words
|
426
|
+
|
427
|
+
if @words_missing.any? then
|
428
|
+
|
429
|
+
tags = []
|
430
|
+
@words_missing.inject(tags) do |r,word|
|
431
|
+
|
432
|
+
found = to_s().lines.grep(/#{word}/)
|
433
|
+
|
434
|
+
if found then
|
435
|
+
r << found.first.scan(/#\w+/).map {|x| x[1..-1]}
|
436
|
+
else
|
437
|
+
r
|
438
|
+
end
|
439
|
+
|
440
|
+
end
|
441
|
+
|
442
|
+
add_sugg = tags.uniq.map do |atag|
|
443
|
+
("%s #%s" % [atag[0], atag[1]]).bg_black
|
444
|
+
end
|
445
|
+
|
446
|
+
puts ('@words_missing: ' + @words_missing.join(', ') ).warn
|
447
|
+
puts "suggestion: try adding the following:".info
|
448
|
+
puts add_sugg.join("\n")
|
449
|
+
puts
|
450
|
+
|
451
|
+
end
|
452
|
+
|
453
|
+
# ----
|
454
|
+
|
410
455
|
node.root.each_recursive do |e|
|
411
456
|
|
412
457
|
e.attributes[:id] = e.attributes[:title].downcase.gsub(/ +/,'-')
|
@@ -535,3 +580,99 @@ EOF
|
|
535
580
|
end
|
536
581
|
|
537
582
|
end
|
583
|
+
|
584
|
+
class MindWordsPlus
|
585
|
+
|
586
|
+
attr_reader :to_px
|
587
|
+
|
588
|
+
def initialize(s, fields: %w(title content), debug: false)
|
589
|
+
|
590
|
+
lt = LineTree.new(s)
|
591
|
+
h = lt.to_h
|
592
|
+
|
593
|
+
mw = MindWords.new(h.keys.join("\n"))
|
594
|
+
outline = mw.to_outline
|
595
|
+
|
596
|
+
out = outline.lines.map do |line|
|
597
|
+
|
598
|
+
word = line[/\w[^$]+/]
|
599
|
+
|
600
|
+
found = h.keys.find do |key, value|
|
601
|
+
|
602
|
+
if debug then
|
603
|
+
puts 'key2: ' + key[/^[^#]+(?= #)/].inspect
|
604
|
+
puts 'word: ' + word.chomp.inspect
|
605
|
+
end
|
606
|
+
|
607
|
+
word.chomp == key[/^[^#]+(?= #)/]
|
608
|
+
end
|
609
|
+
|
610
|
+
puts 'found: ' + found.inspect if debug
|
611
|
+
|
612
|
+
if found and h[found][:body] then
|
613
|
+
puts '***' + h[found][:body].keys.inspect if debug
|
614
|
+
line.chomp + ' # ' + h[found][:body].keys.join('<br/>') + "\n"
|
615
|
+
else
|
616
|
+
line
|
617
|
+
end
|
618
|
+
|
619
|
+
end
|
620
|
+
|
621
|
+
puts out.join if debug
|
622
|
+
|
623
|
+
px = Polyrex.new(schema: "entries[title]/entry[#{fields.join(', ')}]",
|
624
|
+
delimiter: ' # ')
|
625
|
+
px.import out.join
|
626
|
+
@px = px
|
627
|
+
|
628
|
+
end
|
629
|
+
|
630
|
+
def to_ph()
|
631
|
+
|
632
|
+
lines = []
|
633
|
+
|
634
|
+
@px.each_recursive do |x, parent, level|
|
635
|
+
|
636
|
+
if level.to_i < 3 then
|
637
|
+
line = ("\n" + '#' * (level.to_i + 1)) + ' ' + x.title + "\n\n"
|
638
|
+
else
|
639
|
+
line = '*' + ' ' + x.title + "\n"
|
640
|
+
end
|
641
|
+
|
642
|
+
if x.content.length >= 1 then
|
643
|
+
txt = '- ' + x.content.gsub('<','<').gsub('>','>')
|
644
|
+
line += "\n" + txt.gsub('<br/>',"\n- ") + "\n"
|
645
|
+
end
|
646
|
+
|
647
|
+
lines << line
|
648
|
+
|
649
|
+
end
|
650
|
+
|
651
|
+
lines.join.gsub(/\n\n\n/,"\n\n")
|
652
|
+
end
|
653
|
+
|
654
|
+
def to_px()
|
655
|
+
@px
|
656
|
+
end
|
657
|
+
|
658
|
+
def to_tree()
|
659
|
+
|
660
|
+
lines = []
|
661
|
+
@px.each_recursive do |x, parent, level|
|
662
|
+
|
663
|
+
line = (' ' * level) + x.title
|
664
|
+
|
665
|
+
if x.content.length >= 1 then
|
666
|
+
txt = x.content.gsub('<','<').gsub('>','>')
|
667
|
+
indent = ' ' * (level+1) + '* '
|
668
|
+
line += "\n" + indent + txt.gsub('<br/>',"\n" + indent)
|
669
|
+
end
|
670
|
+
|
671
|
+
lines << line
|
672
|
+
end
|
673
|
+
|
674
|
+
lines.join("\n")
|
675
|
+
|
676
|
+
end
|
677
|
+
|
678
|
+
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.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -11,72 +11,52 @@ cert_chain:
|
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMTI3MTQ1NDM4WhcN
|
15
|
+
MjMwMTI3MTQ1NDM4WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC5j1vd
|
17
|
+
M1N+azakESYbM6MEesfRhcOCklUmUNk5LlHcrtoySInNFd9ky7EMilTg8hRPrf5m
|
18
|
+
YgEx9+6V4iAGhRrkmyPdjGbNvgjyGqPjzouwtElA1SIh6geIaiDr3GAQQ4Amez/g
|
19
|
+
jM0bh1xybLIhBxUJ+QDB/MCyWX7c6Lf2mmbWpKJJi9DxdgZT19nD5VrjLE989UwN
|
20
|
+
XOt/jc8s9zc3RFNadSTqVAWXXUb8F9Uh0zrkNwJD0jhmpHEyg7uZ6cHrxD9zZbLf
|
21
|
+
YLJFU+QgPCSUkJX3KUcLbpwHJbmwVbaRwHz16AanbyvBa3jHBOTLoRywpvjPQuec
|
22
|
+
vr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ed3Q1tXowsbLGCT9QwqbaZ5MZ7zks92mIWeJvsA
|
36
|
+
JdpabIXfcOANNKd0ha4NO+Yu
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2022-
|
38
|
+
date: 2022-03-16 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.1'
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 1.1.3
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - "~>"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '1.1'
|
77
|
-
- - ">="
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: 1.1.3
|
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
Binary file
|