phrase_lookup 0.1.6 → 0.1.7
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/phrase_lookup.rb +10 -5
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 445e3b08f2b2a4152aad4dffa8290256a1782210
|
4
|
+
data.tar.gz: '0956745dcb6bc0d9689528dd483eb5a079dd5d3d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f4a339a1e7e2164479edfd87d3858d640d8a1e8a43329d974c23f087158c3e1560b877000da58ca496f9e814902685ea07942aefa27b4deebc1684469eeb23a
|
7
|
+
data.tar.gz: 65022771885abe43116f52021d2e16f9e0654ac6761f1bb145ba53a8ce8596c0958dcfb6075444d4ce740cceafade9977d7fa09ac931c51ee829dfa8200f2665
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/phrase_lookup.rb
CHANGED
@@ -104,19 +104,24 @@ class PhraseLookup
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
def lookup(s, limit: 10)
|
107
|
+
def lookup(s, limit: 10, search_tags: false)
|
108
108
|
|
109
109
|
return [] if s.empty?
|
110
110
|
|
111
111
|
h = @master.to_h
|
112
112
|
a = h.keys
|
113
113
|
|
114
|
-
|
115
|
-
a.
|
114
|
+
a3 = if search_tags then
|
115
|
+
a.grep /\].*(?:\b#{s}\b|\b#{s}).*\|.*(?:\b#{s}\b|\b#{s})/i
|
116
|
+
else
|
117
|
+
a1, a2 = [/^#{s}/i, /\b#{s}/i].map do |regex|
|
118
|
+
a.select {|x| x.gsub(/\[[^\]]*\]/,'').gsub(/\([^\)]*\)/,'') =~ regex}
|
119
|
+
end
|
120
|
+
(a1 + a2)
|
116
121
|
end
|
117
122
|
|
118
|
-
return
|
119
|
-
.
|
123
|
+
return a3.sort_by {|word| -h[word]}.map {|x| x.sub(/ +\|.*$/,'')}\
|
124
|
+
.uniq.take(limit)
|
120
125
|
|
121
126
|
end
|
122
127
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phrase_lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
m1kU5vbLTlJYenStfwtXDnHL7ul9y7MaPO+5UyjWWUuz8iRexmjB/HymNMK7NwPv
|
32
32
|
YzZJ2MWOCulgfw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2017-12-
|
34
|
+
date: 2017-12-26 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rxfhelper
|
metadata.gz.sig
CHANGED
Binary file
|