<<

NAME

ProductOpener::Recipes - Analyze the distribution of ingredients in a set of products

SYNOPSIS

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).

DESCRIPTION

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.)

FUNCTIONS

compute_product_recipe( $product_ref, $parent_ingredients_ref )

Given a list of parent ingredients, analyze the ingredients of the parent to compute the percentage of each parent ingredient.

Arguments

product reference $product_ref

Loaded from the MongoDB database, Storable files, or the OFF API.

list of parent ingredients $parent_ingredients_ref

Reference to an array of canonicalized ingredients.

Return values

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.

add_product_recipe_to_set( $recipes_ref, $product_ref, $recipe_ref )

Arguments

Return value

analyze_recipes( $recipes_ref, $parent_ingredients_ref )

Arguments

Return value

<<