Class: Suggestor::Engine
- Inherits:
-
Object
- Object
- Suggestor::Engine
- Defined in:
- lib/suggestor/engine.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
Instance Method Summary collapse
-
#initialize ⇒ Engine
constructor
A new instance of Engine.
- #load_data(input) ⇒ Object
- #recommented_related_items_for(item, opts = {}) ⇒ Object
- #similar_items_to(item, opts = {}) ⇒ Object
- #similarity_score_for(first, second, opts = {}) ⇒ Object
Constructor Details
#initialize ⇒ Engine
Returns a new instance of Engine.
13 14 15 |
# File 'lib/suggestor/engine.rb', line 13 def initialize @collection = {} end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
11 12 13 |
# File 'lib/suggestor/engine.rb', line 11 def collection @collection end |
Instance Method Details
#load_data(input) ⇒ Object
17 18 19 |
# File 'lib/suggestor/engine.rb', line 17 def load_data(input) add_to_collection(input) end |
#recommented_related_items_for(item, opts = {}) ⇒ Object
31 32 33 34 |
# File 'lib/suggestor/engine.rb', line 31 def (item, opts={}) opts[:algorithm] ||= :euclidean_distance strategy_for(opts[:algorithm]).(item) end |
#similar_items_to(item, opts = {}) ⇒ Object
26 27 28 29 |
# File 'lib/suggestor/engine.rb', line 26 def similar_items_to(item, opts={}) opts[:algorithm] ||= :euclidean_distance strategy_for(opts[:algorithm]).similar_items_to(item) end |
#similarity_score_for(first, second, opts = {}) ⇒ Object
21 22 23 24 |
# File 'lib/suggestor/engine.rb', line 21 def similarity_score_for(first, second, opts={}) opts[:algorithm] ||= :euclidean_distance strategy_for(opts[:algorithm]).similarity_score_between(first, second) end |