picky-generators 3.0.1 → 3.1.0
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.
@@ -20,7 +20,7 @@ class BookSearch < Sinatra::Application
|
|
20
20
|
|
21
21
|
# Define an index.
|
22
22
|
#
|
23
|
-
books_index =
|
23
|
+
books_index = Index.new :books do
|
24
24
|
source Sources::CSV.new(:title, :author, :year, file: "data/#{PICKY_ENVIRONMENT}/library.csv")
|
25
25
|
indexing removes_characters: /[^a-zA-Z0-9\s\/\-\_\:\"\&\.]/i,
|
26
26
|
stopwords: /\b(and|the|of|it|in|for)\b/i,
|
@@ -41,11 +41,13 @@ class BookSearch < Sinatra::Application
|
|
41
41
|
# Define a search over the books index.
|
42
42
|
#
|
43
43
|
books = Search.new books_index do
|
44
|
-
searching
|
44
|
+
searching substitutes_characters_with: CharacterSubstituters::WestEuropean.new, # Normalizes special user input, Ä -> Ae, ñ -> n etc.
|
45
|
+
removes_characters: /[^a-zA-Z0-9\s\/\-\_\&\.\"\~\*\:\,]/i, # Picky needs control chars *"~:, to pass through.
|
45
46
|
stopwords: /\b(and|the|of|it|in|for)\b/i,
|
46
|
-
splits_text_on: /[\s\/\-\&]
|
47
|
-
|
48
|
-
boost [:title, :author] => +3,
|
47
|
+
splits_text_on: /[\s\/\-\&]+/
|
48
|
+
|
49
|
+
boost [:title, :author] => +3,
|
50
|
+
[:title] => +1
|
49
51
|
end
|
50
52
|
|
51
53
|
|
@@ -35,7 +35,9 @@
|
|
35
35
|
%code
|
36
36
|
%pre
|
37
37
|
:preserve
|
38
|
-
BookSearch = Picky::Client.new :host => 'localhost',
|
38
|
+
BookSearch = Picky::Client.new :host => 'localhost',
|
39
|
+
:port => 8080,
|
40
|
+
:path => '/books'
|
39
41
|
%p
|
40
42
|
Both clients offer the options:
|
41
43
|
%dl
|
@@ -54,7 +56,9 @@
|
|
54
56
|
%pre
|
55
57
|
:preserve
|
56
58
|
get '/search/full' do
|
57
|
-
results = BookSearch.search params[:query],
|
59
|
+
results = BookSearch.search params[:query],
|
60
|
+
:ids => params[:ids],
|
61
|
+
:offset => params[:offset]
|
58
62
|
results.extend Picky::Convenience
|
59
63
|
results.populate_with Book do |book|
|
60
64
|
book.to_s
|
@@ -66,13 +70,18 @@
|
|
66
70
|
%strong hash
|
67
71
|
with the results:
|
68
72
|
%code
|
69
|
-
%pre
|
73
|
+
%pre
|
74
|
+
:preserve
|
75
|
+
results = BookSearch.search params[:query],
|
76
|
+
:ids => params[:ids],
|
77
|
+
:offset => params[:offset]
|
70
78
|
%p
|
71
79
|
This part takes the
|
72
80
|
%strong hash
|
73
81
|
and extends it with a few useful and convenient methods:
|
74
82
|
%code
|
75
|
-
%pre
|
83
|
+
%pre
|
84
|
+
results.extend Picky::Convenience
|
76
85
|
%p
|
77
86
|
One of these methods is the
|
78
87
|
%strong populate_with
|
@@ -101,7 +110,10 @@
|
|
101
110
|
%pre
|
102
111
|
:preserve
|
103
112
|
results.entries do |book|
|
104
|
-
|
113
|
+
# Or use book.to_s, or however you like
|
114
|
+
# to render the book.
|
115
|
+
#
|
116
|
+
render book
|
105
117
|
end
|
106
118
|
%p
|
107
119
|
At the end, encode the hash in JSON:
|
@@ -114,10 +126,14 @@
|
|
114
126
|
%code
|
115
127
|
%pre
|
116
128
|
:preserve
|
117
|
-
BookSearch = Picky::Client.new :host => 'localhost',
|
129
|
+
BookSearch = Picky::Client.new :host => 'localhost',
|
130
|
+
:port => 8080,
|
131
|
+
:path => '/books'
|
118
132
|
|
119
133
|
get '/search/full' do
|
120
|
-
results = BookSearch.search params[:query],
|
134
|
+
results = BookSearch.search params[:query],
|
135
|
+
:ids => params[:ids],
|
136
|
+
:offset => params[:offset]
|
121
137
|
|
122
138
|
results.extend Picky::Convenience
|
123
139
|
results.populate_with Book do |book|
|
@@ -131,14 +147,23 @@
|
|
131
147
|
The view is even easier. Just add the line
|
132
148
|
%code
|
133
149
|
%pre
|
134
|
-
|
150
|
+
:preserve
|
151
|
+
= Picky::Helper.cached_interface
|
135
152
|
if you use just one language, or
|
136
153
|
%code
|
137
154
|
%pre
|
138
|
-
|
155
|
+
:preserve
|
156
|
+
= Picky::Helper.interface :button => 'search',
|
157
|
+
:no_results => 'No results!',
|
158
|
+
:more => 'more'
|
139
159
|
if you use multiple languages.
|
140
160
|
(You'd use the options
|
141
|
-
%
|
161
|
+
%code
|
162
|
+
%pre
|
163
|
+
:preserve
|
164
|
+
:button => t(:'search.button'),
|
165
|
+
:no_results => t(:'search.no_results'),
|
166
|
+
:more => t(:'search.more')
|
142
167
|
of course, with proper i18n)
|
143
168
|
The same options can be used for
|
144
169
|
%strong #cached_interface
|
@@ -157,6 +182,7 @@
|
|
157
182
|
full: '/search/full',
|
158
183
|
|
159
184
|
// etc.
|
185
|
+
//
|
160
186
|
Just take a look at the possible javascript client options in that file.
|
161
187
|
%p
|
162
188
|
%strong Good luck my friend! *waves several stubby pink tentacles*
|
@@ -35,7 +35,9 @@
|
|
35
35
|
%code
|
36
36
|
%pre
|
37
37
|
:preserve
|
38
|
-
BookSearch = Picky::Client.new :host => 'localhost',
|
38
|
+
BookSearch = Picky::Client.new :host => 'localhost',
|
39
|
+
:port => 8080,
|
40
|
+
:path => '/books'
|
39
41
|
%p
|
40
42
|
Both clients offer the options:
|
41
43
|
%dl
|
@@ -54,7 +56,9 @@
|
|
54
56
|
%pre
|
55
57
|
:preserve
|
56
58
|
get '/search/full' do
|
57
|
-
results = BookSearch.search params[:query],
|
59
|
+
results = BookSearch.search params[:query],
|
60
|
+
:ids => params[:ids],
|
61
|
+
:offset => params[:offset]
|
58
62
|
results.extend Picky::Convenience
|
59
63
|
results.populate_with Book do |book|
|
60
64
|
book.to_s
|
@@ -66,13 +70,18 @@
|
|
66
70
|
%strong hash
|
67
71
|
with the results:
|
68
72
|
%code
|
69
|
-
%pre
|
73
|
+
%pre
|
74
|
+
:preserve
|
75
|
+
results = BookSearch.search params[:query],
|
76
|
+
:ids => params[:ids],
|
77
|
+
:offset => params[:offset]
|
70
78
|
%p
|
71
79
|
This part takes the
|
72
80
|
%strong hash
|
73
81
|
and extends it with a few useful and convenient methods:
|
74
82
|
%code
|
75
|
-
%pre
|
83
|
+
%pre
|
84
|
+
results.extend Picky::Convenience
|
76
85
|
%p
|
77
86
|
One of these methods is the
|
78
87
|
%strong populate_with
|
@@ -101,7 +110,10 @@
|
|
101
110
|
%pre
|
102
111
|
:preserve
|
103
112
|
results.entries do |book|
|
104
|
-
|
113
|
+
# Or use book.to_s, or however you like
|
114
|
+
# to render the book.
|
115
|
+
#
|
116
|
+
render book
|
105
117
|
end
|
106
118
|
%p
|
107
119
|
At the end, encode the hash in JSON:
|
@@ -114,10 +126,14 @@
|
|
114
126
|
%code
|
115
127
|
%pre
|
116
128
|
:preserve
|
117
|
-
BookSearch = Picky::Client.new :host => 'localhost',
|
129
|
+
BookSearch = Picky::Client.new :host => 'localhost',
|
130
|
+
:port => 8080,
|
131
|
+
:path => '/books'
|
118
132
|
|
119
133
|
get '/search/full' do
|
120
|
-
results = BookSearch.search params[:query],
|
134
|
+
results = BookSearch.search params[:query],
|
135
|
+
:ids => params[:ids],
|
136
|
+
:offset => params[:offset]
|
121
137
|
|
122
138
|
results.extend Picky::Convenience
|
123
139
|
results.populate_with Book do |book|
|
@@ -131,14 +147,23 @@
|
|
131
147
|
The view is even easier. Just add the line
|
132
148
|
%code
|
133
149
|
%pre
|
134
|
-
|
150
|
+
:preserve
|
151
|
+
= Picky::Helper.cached_interface
|
135
152
|
if you use just one language, or
|
136
153
|
%code
|
137
154
|
%pre
|
138
|
-
|
155
|
+
:preserve
|
156
|
+
= Picky::Helper.interface :button => 'search',
|
157
|
+
:no_results => 'No results!',
|
158
|
+
:more => 'more'
|
139
159
|
if you use multiple languages.
|
140
160
|
(You'd use the options
|
141
|
-
%
|
161
|
+
%code
|
162
|
+
%pre
|
163
|
+
:preserve
|
164
|
+
:button => t(:'search.button'),
|
165
|
+
:no_results => t(:'search.no_results'),
|
166
|
+
:more => t(:'search.more')
|
142
167
|
of course, with proper i18n)
|
143
168
|
The same options can be used for
|
144
169
|
%strong #cached_interface
|
@@ -157,6 +182,7 @@
|
|
157
182
|
full: '/search/full',
|
158
183
|
|
159
184
|
// etc.
|
185
|
+
//
|
160
186
|
Just take a look at the possible javascript client options in that file.
|
161
187
|
%p
|
162
188
|
%strong Good luck my friend! *waves several stubby pink tentacles*
|
@@ -22,13 +22,13 @@ class BookSearch < Picky::Application
|
|
22
22
|
|
23
23
|
# How query text is preprocessed. Move to Search block to make it search specific.
|
24
24
|
#
|
25
|
-
searching
|
25
|
+
searching substitutes_characters_with: CharacterSubstituters::WestEuropean.new, # Normalizes special user input, Ä -> Ae, ñ -> n etc.
|
26
|
+
removes_characters: /[^a-zA-Z0-9\s\/\-\_\&\.\"\~\*\:\,]/i, # Picky needs control chars *"~:, to pass through.
|
26
27
|
stopwords: /\b(and|the|of|it|in|for)\b/i,
|
27
28
|
splits_text_on: /[\s\/\-\&]+/,
|
28
|
-
maximum_tokens: 5
|
29
|
-
substitutes_characters_with: CharacterSubstituters::WestEuropean.new # Normalizes special user input, Ä -> Ae, ñ -> n etc.
|
29
|
+
maximum_tokens: 5 # Amount of tokens maximally used in a search.
|
30
30
|
|
31
|
-
books_index =
|
31
|
+
books_index = Index.new :books do
|
32
32
|
source Sources::CSV.new(:title, :author, :year, file: "data/#{PICKY_ENVIRONMENT}/library.csv")
|
33
33
|
category :title,
|
34
34
|
similarity: Similarity::DoubleMetaphone.new(3), # Default is no similarity.
|
@@ -11,7 +11,7 @@ class BookSearch < Sinatra::Application
|
|
11
11
|
|
12
12
|
# Define an index.
|
13
13
|
#
|
14
|
-
books_index =
|
14
|
+
books_index = Index.new :books do
|
15
15
|
source Sources::CSV.new(:title, :author, :year, file: "data/#{PICKY_ENVIRONMENT}/library.csv")
|
16
16
|
indexing removes_characters: /[^a-zA-Z0-9\s\/\-\_\:\"\&\.]/i,
|
17
17
|
stopwords: /\b(and|the|of|it|in|for)\b/i,
|
@@ -32,11 +32,12 @@ class BookSearch < Sinatra::Application
|
|
32
32
|
# Define a search over the books index.
|
33
33
|
#
|
34
34
|
books = Search.new books_index do
|
35
|
-
searching
|
35
|
+
searching substitutes_characters_with: CharacterSubstituters::WestEuropean.new, # Normalizes special user input, Ä -> Ae, ñ -> n etc.
|
36
|
+
removes_characters: /[^a-zA-Z0-9\s\/\-\_\&\.\"\~\*\:\,]/i, # Picky needs control chars *"~:, to pass through.
|
36
37
|
stopwords: /\b(and|the|of|it|in|for)\b/i,
|
37
|
-
splits_text_on: /[\s\/\-\&]
|
38
|
-
|
39
|
-
|
38
|
+
splits_text_on: /[\s\/\-\&]+/
|
39
|
+
boost [:title, :author] => +3,
|
40
|
+
[:title] => +1
|
40
41
|
end
|
41
42
|
|
42
43
|
# Route /books to the books search and log when searching.
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: picky-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 3.0
|
5
|
+
version: 3.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Florian Hanke
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-26 00:00:00 +10:00
|
14
14
|
default_executable: picky-generate
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - ~>
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 3.0
|
35
|
+
version: 3.1.0
|
36
36
|
type: :runtime
|
37
37
|
version_requirements: *id002
|
38
38
|
- !ruby/object:Gem::Dependency
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 3.0
|
46
|
+
version: 3.1.0
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id003
|
49
49
|
description: Generators for Picky.
|