Sha256: 301a9f2706e10342735ef33d71e66f690c83c82c4807e067b35abdb84e01c536

Contents?: true

Size: 1.18 KB

Versions: 23

Compression:

Stored size: 1.18 KB

Contents

# Tasks for manually testing your engine configuration.
#
namespace :try do
  
  # desc "Try how a given word would be tokenized when indexing (type:category optional)."
  task :index, [:text, :index_and_category] => :application do |_, options|
    text, index_and_category = options.text, options.index_and_category
    
    tokenizer = index_and_category ? Indexes.find(*index_and_category.split(':')).tokenizer : Tokenizers::Index.default
    
    puts "\"#{text}\" is saved in the index as             #{tokenizer.tokenize(text.dup).to_a}"
  end
  
  # desc "Try how a given word would be tokenized when querying."
  task :query, [:text] => :application do |_, options|
    text = options.text
    
    puts "\"#{text}\" as a query will be preprocessed into #{Tokenizers::Query.default.tokenize(text.dup).to_a.map(&:to_s).map(&:to_sym)}"
  end
  
  # desc "Try the given text with both the index and the query (type:category optional)."
  task :both, [:text, :index_and_category] => :application do |_, options|
    text, index_and_category = options.text, options.index_and_category
    
    Rake::Task[:"try:index"].invoke text, index_and_category
    Rake::Task[:"try:query"].invoke text
  end
  
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
picky-1.4.1 lib/tasks/try.rake
picky-1.4.0 lib/tasks/try.rake
picky-1.3.4 lib/tasks/try.rake
picky-1.3.3 lib/tasks/try.rake
picky-1.3.2 lib/tasks/try.rake
picky-1.3.1 lib/tasks/try.rake
picky-1.3.0 lib/tasks/try.rake
picky-1.2.4 lib/tasks/try.rake
picky-1.2.3 lib/tasks/try.rake
picky-1.2.2 lib/tasks/try.rake
picky-1.2.1 lib/tasks/try.rake
picky-1.2.0 lib/tasks/try.rake
picky-1.1.7 lib/tasks/try.rake
picky-1.1.6 lib/tasks/try.rake
picky-1.1.5 lib/tasks/try.rake
picky-1.1.4 lib/tasks/try.rake
picky-1.1.3 lib/tasks/try.rake
picky-1.1.2 lib/tasks/try.rake
picky-1.1.1 lib/tasks/try.rake
picky-1.1.0 lib/tasks/try.rake