Skip to content
This repository
tag: v4.5.8
Fetching contributors…

Cannot retrieve contributors at this time

file 98 lines (55 sloc) 2.576 kb

APIs in Picky

This is the reference document for all the APIs that can be used in Picky.

It denotes several areas where you can customize/plug into Picky.

Tokenizer (Picky::API::Tokenizer)

Has methods

  • tokenize(text) => [ [:token1, :token2, ...], ["Original1", "Original2", ...] ] (2-D array of the tokens and the original texts)

Accepted by

  • Sinatra::Application#indexing
  • Sinatra::Application#searching
  • Picky::Index#indexing
  • Picky::Search#searching
  • Picky::Category.new(indexing: tokenizer_instance)

CharacterSubstituter (Picky::API::Tokenizer::CharacterSubstituter)

Has methods

  • substitute(text) => substituted_text (with characters replaced)

Accepted as

  • option substitutes_characters_with for indexing and searching.

Backends (Not yet codified into a class)

Have methods

  1. TODO See examples in lib/picky/backends

Accepted by

  • Picky::Index#backend(backend_instance)

Sources (Picky::API::Source)

Has methods

  • each(&block) yields objects (that respond to methods listed in the categories, or in the categories’ from option)

Weight (Picky::API::Category::Weight)

Has methods

  • weight_for(amount_of_ids) => float (a weight)

Accepted as option weight for the category.

Partial (Picky::API::Category::Partial)

Has methods

  • each_partial(token, &block) yields each partialized token

Accepted as option partial for the category.

Similarity (Picky::API::Category::Similarity)

Has methods

  • encode(token) => encoded token
  • prioritize(similar_encoded_array, encoded) (Gives your similarity a chance to lop off superfluous similars and reorder the array)

Accepted as option similarity for the category.

Search

Has methods

  • Picky::Search#search(text, ids = 20, offset = 0) => Picky::Results (an instance)

Search option boost (Picky::API::Search::Boosts)

Has methods

  • boost_for(array_of_combinations) => float (A negative or positive weight)

Accepted as parameter for the boost method in a Search.new block.

Other

Results

Has methods

  • prepare! => unimportant (prepares the search results, called by the Picky search)
  • ids(amount = 20) => [id1, id2, id3, ...] (a list of ids in order of importance)
  • total => 1234 (the total number of – calculated – results)
  • duration => 1.234 (a float)
  • to_hash => {...} (a hash representation of the results)
  • to_json"{...}" (a json representation of the hash representation of the results)
  • to_s => log output (a string for log output)
Something went wrong with that request. Please try again.