dxtitle_search 0.2.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/dxtitle_search.rb +58 -59
- metadata +34 -32
- 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: e227dc645595c967bf03dd213ea6846c7c9c438a26ee7db3fd059f464493f370
|
4
|
+
data.tar.gz: eccff27f864a56f00f0952d8ddd47a70eaeb2fca6eca24d961cf4c91d54f7387
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db771d09b581573be92de6c65b79c3f635dbcb6187e0bc1d6a00c5d4042a3f13f4838696588d65cc9856be56ed5666047221204e5910fbe38e8aec42f075ee70
|
7
|
+
data.tar.gz: f39cbbb2ca067cfb4c307787b94dab70c7c0d34255037e24e9228b32f284ebbe6361523456d078659aa11e5e3e694ef6dfae3890b18b87ce90d2a707d618a14d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dxtitle_search.rb
CHANGED
@@ -2,96 +2,95 @@
|
|
2
2
|
|
3
3
|
# file: dxtitle_search.rb
|
4
4
|
|
5
|
-
require '
|
5
|
+
require 'indexer101'
|
6
6
|
|
7
7
|
|
8
8
|
class DxTitleSearch
|
9
9
|
|
10
|
-
def initialize(obj=nil, sources: nil, debug: false)
|
10
|
+
def initialize(obj=nil, sources: nil, level: 1, debug: false)
|
11
11
|
|
12
12
|
@debug = debug
|
13
|
+
@indexer = Indexer101.new debug: debug
|
14
|
+
@level = level
|
13
15
|
|
14
16
|
s = if sources then
|
15
17
|
|
16
|
-
dx = Dynarex.new(sources)
|
17
|
-
|
18
|
+
dx = Dynarex.new(sources)
|
19
|
+
puts 'before scan_dxindex' if @debug
|
20
|
+
a = dx.all.map(&:uri)
|
21
|
+
puts 'a: ' + a.inspect if @debug
|
22
|
+
@indexer.scan_dxindex a, level: level
|
18
23
|
|
19
|
-
elsif obj
|
20
|
-
|
21
|
-
# is it a Dynarex file location?
|
22
|
-
if obj.lines.length < 2 then
|
23
|
-
|
24
|
-
read obj
|
24
|
+
elsif obj and (obj.is_a?(DxLite) or obj.is_a?(Dynarex)) or obj.lines.length < 2
|
25
25
|
|
26
|
-
|
26
|
+
@indexer.scan_dxindex obj, level: level
|
27
27
|
|
28
|
-
obj
|
29
|
-
|
30
|
-
end
|
31
28
|
end
|
32
29
|
|
33
|
-
@
|
34
|
-
key, value = x.split(/\s+(?=[^\s]+$)/,2)
|
35
|
-
r.merge(key.rstrip => value)
|
36
|
-
end
|
37
|
-
|
38
|
-
@a = h.keys
|
30
|
+
#jr230620 @indexer.build
|
39
31
|
|
40
32
|
end
|
41
33
|
|
42
|
-
def search(keywords)
|
43
|
-
|
44
|
-
phrases = @a.grep /#{keywords}/i
|
34
|
+
def search(keywords, minchars: 3)
|
45
35
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
a = a0.uniq.map do |entry|
|
53
|
-
[entry, entry.scan(/#{keywords.split.join('|')}/).uniq.count]
|
54
|
-
end
|
36
|
+
a2 = @indexer.search keywords.split(/[\s:"!\?\(\)£]+(?=[\w#_'-]+)/), \
|
37
|
+
minchars: minchars
|
38
|
+
# format each result as a Hash object
|
39
|
+
a3 = a2.map do |date, title, url|
|
55
40
|
|
56
|
-
|
57
|
-
#a2 = (phrases + a).uniq.sort do |x, x2|
|
58
|
-
a2 = a.sort do |x, x2|
|
59
|
-
-([x.last, x.first[/^\d+/], ] <=> [x2.last, x2.first[/^\d+/]])
|
60
|
-
end
|
41
|
+
{title: title, url: url, date: date}
|
61
42
|
|
62
|
-
|
63
|
-
a3 = (phrases + a2).map do |x|
|
43
|
+
end
|
64
44
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
45
|
+
puts 'a3: ' + a3.inspect if @debug
|
46
|
+
|
47
|
+
@dx = Dynarex.new('results/result(title, url, date)').import(a3)
|
48
|
+
|
49
|
+
def a3.to_dx()
|
50
|
+
Dynarex.new('results/result(title, url, date)').import(self)
|
51
|
+
end
|
52
|
+
|
53
|
+
def a3.to_tags()
|
54
|
+
a = self.map {|x| x[:title].scan(/(?<=#)(\w+)/)}.flatten
|
55
|
+
a.uniq.sort.map {|x| [x, a.count(x)]}
|
56
|
+
end
|
57
|
+
|
58
|
+
def a3.search(keywords)
|
70
59
|
|
71
|
-
|
72
|
-
|
73
|
-
rawtime, title = line.split(/ +/,2)
|
74
|
-
puts 'title: ' + title.inspect if @debug
|
75
|
-
|
76
|
-
{title: title, url: @h[line], date: Time.at(rawtime.to_i)}
|
60
|
+
dx = Dynarex.new('results/result(title, url, date)').import(self)
|
77
61
|
|
62
|
+
level = keywords[0] == '#' ? 0 : 1
|
63
|
+
dts = DxTitleSearch.new dx, level: level
|
64
|
+
dts.search keywords
|
65
|
+
|
78
66
|
end
|
67
|
+
|
68
|
+
def a3.tag_search(keywords)
|
69
|
+
|
70
|
+
dx = Dynarex.new('results/result(title, url, date)').import(self)
|
79
71
|
|
80
|
-
|
72
|
+
level = keywords[0] == '#' ? 0 : 1
|
73
|
+
dts = DxTitleSearch.new dx, level: level
|
74
|
+
dts.tag_search keywords
|
75
|
+
|
76
|
+
end
|
81
77
|
|
82
78
|
return a3
|
83
79
|
|
84
80
|
end
|
85
81
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
dx = Dynarex.new(source)
|
82
|
+
def tag_search(keywords)
|
83
|
+
r = @indexer.lookup *keywords.split(/[\W]+(?=[\w]+)/).map {|x| "#" + x}
|
84
|
+
r.map {|x| x.to_s[1..-1]}
|
85
|
+
end
|
91
86
|
|
92
|
-
|
93
|
-
|
94
|
-
|
87
|
+
def to_tags()
|
88
|
+
|
89
|
+
a = @indexer.index.map do |key, value|
|
90
|
+
[key.to_s[1..-1], value.length]
|
91
|
+
end
|
92
|
+
|
93
|
+
a.sort_by(&:first)
|
95
94
|
|
96
95
|
end
|
97
96
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dxtitle_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -11,54 +11,54 @@ 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
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwMjIyMDAxMTU0WhcN
|
15
|
+
MjIwMjIyMDAxMTU0WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDxwG7T
|
17
|
+
/9FLpGJct6ptTTRa2UnYj9qeRp2KmjnMpONFP7Owl1yjh2auzyIfDChG7G2W9kZ4
|
18
|
+
eOPno39R2GJOxt5IVTxmjgBpAUl8xW3n629b2jE7al1GJZ89Jm3Fqs1rBeUaC0wB
|
19
|
+
DIX4SVwHqfzxvZTVLVZ5LPIKqxNiJe8eUIRRzzc0/XzyFTh3Sg4SH1ncm04vvxWg
|
20
|
+
piQyL6iUeUuirHjotch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b
|
34
|
+
aZJQ2A0sZWHF9u5v9gda8mq21CID3YMPRzQ1u5o4jjyNhcVyjW29GvfD8+8D4s46
|
35
|
+
g10O6gIBUztpsNHwbBTi9fHgtis4E5dAPAo4uzo4MCKVwi72iZQ3E92ACYb9zlxA
|
36
|
+
g6CsTY0vUjhgfh9taSRj3qxd
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
|
-
name:
|
41
|
+
name: indexer101
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '0.2'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: 0.2.5
|
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: '0.2'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
59
|
+
version: 0.2.5
|
60
60
|
description:
|
61
|
-
email:
|
61
|
+
email: digital.robertson@gmail.com
|
62
62
|
executables: []
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
@@ -83,8 +83,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.7.10
|
87
88
|
signing_key:
|
88
89
|
specification_version: 4
|
89
|
-
summary:
|
90
|
+
summary: Originally intended to search title entries from plain text (derived from
|
91
|
+
a Dynarex document).
|
90
92
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|