<<

NAME

ProductOpener::ImportConvert - help to convert product data files from producers to the Open Food Facts format.

SYNOPSIS

ProductOpener::ImportConvert provides functions to load and process CSV and XML files to convert the product data they contain to a format that can be imported on Open Food Facts.

    use ProductOpener::ImportConvert qw/:all/;

..

DESCRIPTION

..

FUNCTIONS

assign_quantity_from_field ( $product_ref, $field )

Look for a quantity in a field like a product name. Assign it to the quantity and remove it from the field.

remove_quantity_from_field ( $product_ref, $field )

Look for the quantity in a field like a product name. If found, remove it from the field.

clean_fields ( $imported_product_ref )

This function: - extracts values from some fields to populate other fields (e.g. the quantity can be passed in the product name) - split some field values (e.g. remove the brand from the product name) - cleans the fields

Warning: this function is intended to be applied only to imported product data. It should not be used on general products, as some of the cleaning may be too aggressive in the general case. e.g. if the ingredients field is of the form "something Ingredients: list of ingredients", then "something" is assigned to the generic name of the product.

extract_nutrition_facts_from_text ( LC, TEXT, NUTRIENTS_REF )

extract_nutrition_facts_from_text() extract nutrition facts from a text blob and return a hash structure that maps Open Food Facts nutrient ids to the value, unit and modifier.

Arguments

LC - Language code

The language the text is in.

TEXT - Language code

The text that contains the nutrition facts.

NUTRIENTS_REF

Reference to a hash that will be used to return structured data for the nutrition facts found in the text.

NUTRITION_DATA_PER_REF - Per 100g or per serving

Reference to a scalar that will be set to the serving size if the nutrition facts are indicated per serving.

SERVING_SIZE_REF - Serving size

Reference to a scalar that will be set to the serving size if the nutrition facts are indicated per serving.

<<