ProductOpener::Recipes - Analyze the distribution of ingredients in a set of products
This module contains functions to compute the distribution of specific ingredients in a specified set of products.
For instance, one can compute the distribution of water, sugar and fruits for products in the fruit nectar category.
Functions in this module can be called through scripts for batch processing, and/or they could also be called for real time analysis through the API or web interface (for a small enough set of products).
The ingredients list is first analyzed with the Ingredients.pm module to identify each ingredient and estimate the percentage of each ingredient.
Then each ingredient is matched against the specified list of parents ingredients. (e.g. if we want the distribution of water, sugar and fruits, "apple" will be mapped to fruits.)
Given a list of parent ingredients, analyze the ingredients of the parent to compute the percentage of each parent ingredient.
Loaded from the MongoDB database, Storable files, or the OFF API.
Reference to an array of canonicalized ingredients.
Percentages are returned in a hash that contains the parent ingredients canonicalized ids as the key, and the percentage as a value.
2 extra keys are also returned:
- "unknown": for ingredients that are not known in the taxonomy - "other": for ingredients that are known but are not children of any of the specified parent ingredients.