lib/tasks/try.rake in picky-2.0.0.pre1 vs lib/tasks/try.rake in picky-2.0.0.pre2
- old
+ new
@@ -4,11 +4,11 @@
# desc "Try how a given word would be tokenized when indexing (type:category optional)."
task :index, [:text, :index, :category] => :application do |_, options|
text, index, category = options.text, options.index, options.category
- tokenizer = index && category ? Indexes.find(index, category).tokenizer : Internals::Tokenizers::Index.default
+ tokenizer = category ? Indexes.find(index, category).tokenizer : Internals::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."
@@ -19,9 +19,12 @@
end
# desc "Try the given text with both the index and the query (type:category optional)."
task :both, [:text, :index, :category] => :application do |_, options|
text, index, category = options.text, options.index, options.category
+
+ puts
+ fail "\x1b[31mrake try needs a text to try indexing and query preparation\x1b[m, e.g. rake 'try[yourtext]'." unless text
Rake::Task[:"try:index"].invoke text, index, category
Rake::Task[:"try:query"].invoke text
end
\ No newline at end of file