picky 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/picky +4 -4
- data/lib/picky/application.rb +1 -1
- data/lib/picky/cli.rb +58 -0
- data/lib/picky/extensions/array.rb +2 -0
- data/lib/picky/loader.rb +0 -4
- data/lib/picky/query/weigher.rb +2 -0
- data/lib/picky/query/weights.rb +1 -1
- data/lib/picky/sources/db.rb +9 -8
- data/lib/picky/tokenizers/base.rb +5 -4
- data/lib/picky/tokenizers/index.rb +9 -9
- data/lib/tasks/server.rake +0 -2
- data/spec/lib/rack/harakiri_spec.rb +1 -0
- data/spec/lib/sources/db_spec.rb +43 -49
- metadata +4 -17
- data/lib/picky/generator.rb +0 -198
- data/project_prototype/Gemfile +0 -30
- data/project_prototype/Rakefile +0 -11
- data/project_prototype/app/README +0 -5
- data/project_prototype/app/application.rb +0 -50
- data/project_prototype/app/db.yml +0 -13
- data/project_prototype/app/library.csv +0 -540
- data/project_prototype/app/logging.rb +0 -20
- data/project_prototype/config.ru +0 -35
- data/project_prototype/log/README +0 -1
- data/project_prototype/script/console +0 -34
- data/project_prototype/tmp/README +0 -0
- data/project_prototype/tmp/pids/README +0 -0
- data/project_prototype/unicorn.ru +0 -15
@@ -1,50 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# TODO Adapt the generated example
|
4
|
-
# (a library books finder) to what you need.
|
5
|
-
#
|
6
|
-
# Check the Wiki http://github.com/floere/picky/wiki for more options.
|
7
|
-
# Ask me or the google group if you have questions or specific requests.
|
8
|
-
#
|
9
|
-
class PickySearch < Application
|
10
|
-
|
11
|
-
# Indexing: How text is indexed.
|
12
|
-
#
|
13
|
-
default_indexing removes_characters: /[^a-zA-Z0-9\s\/\-\"\&\.]/,
|
14
|
-
stopwords: /\b(and|the|of|it|in|for)\b/,
|
15
|
-
splits_text_on: /[\s\/\-\"\&\.]/
|
16
|
-
|
17
|
-
# Querying: How query text is handled.
|
18
|
-
#
|
19
|
-
default_querying removes_characters: /[^a-zA-Z0-9\s\/\-\,\&\"\~\*\:]/, # Picky needs control chars *"~: to pass through.
|
20
|
-
stopwords: /\b(and|the|of|it|in|for)\b/,
|
21
|
-
splits_text_on: /[\s\/\-\,\&]+/,
|
22
|
-
|
23
|
-
maximum_tokens: 5, # Amount of tokens passing into a query (5 = default).
|
24
|
-
substitutes_characters_with: CharacterSubstituters::WestEuropean.new # Normalizes special user input, Ä -> Ae, ñ -> n etc.
|
25
|
-
|
26
|
-
# Define an index. Use a database etc. source?
|
27
|
-
# See http://github.com/floere/picky/wiki/Sources-Configuration#sources
|
28
|
-
#
|
29
|
-
books_index = index :books, Sources::CSV.new(:title, :author, :year, file: 'app/library.csv')
|
30
|
-
books_index.define_category :title,
|
31
|
-
similarity: Similarity::Phonetic.new(3), # Up to three similar title word indexed (default: No similarity).
|
32
|
-
partial: Partial::Substring.new(from: 1) # Indexes substrings upwards from character 1 (default: -3),
|
33
|
-
# You'll find "picky" even when entering just a "p".
|
34
|
-
books_index.define_category :author,
|
35
|
-
partial: Partial::Substring.new(from: 1)
|
36
|
-
books_index.define_category :year,
|
37
|
-
partial: Partial::None.new # Partial substring searching on the year does not make
|
38
|
-
# much sense, neither does similarity.
|
39
|
-
|
40
|
-
query_options = { :weights => { [:title, :author] => +3, [:title] => +1 } } # +/- points for ordered combinations.
|
41
|
-
|
42
|
-
full_books = Query::Full.new books_index, query_options # A Full query returns ids, combinations, and counts.
|
43
|
-
live_books = Query::Live.new books_index, query_options # A Live query does return all that Full returns, except ids.
|
44
|
-
|
45
|
-
route %r{\A/books/full\Z} => full_books # Routing is simple: url_path_regexp => query
|
46
|
-
route %r{\A/books/live\Z} => live_books #
|
47
|
-
|
48
|
-
# Note: You can pass a query multiple indexes and it will query in all of them.
|
49
|
-
|
50
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# Just an example, see application.rb on how this file is used.
|
2
|
-
#
|
3
|
-
# Note: ActiveRecord is used. Sorry.
|
4
|
-
#
|
5
|
-
# TODO Configure the database adapter
|
6
|
-
# or ignore and use a csv source.
|
7
|
-
#
|
8
|
-
adapter: mysql
|
9
|
-
host: localhost
|
10
|
-
username: root
|
11
|
-
password:
|
12
|
-
database: your_database # Load this configuration and use a DB source in app/application.rb.
|
13
|
-
encoding: utf8
|