ProductOpener::ImportConvert - help to convert product data files from producers to the Open Food Facts format.
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/;
..
..
Look for a quantity in a field like a product name. Assign it to the quantity and remove it from the field.
Look for the quantity in a field like a product name. If found, remove it from the field.
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()
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.
The language the text is in.
The text that contains the nutrition facts.
Reference to a hash that will be used to return structured data for the nutrition facts found in the text.
Reference to a scalar that will be set to the serving size if the nutrition facts are indicated per serving.
Reference to a scalar that will be set to the serving size if the nutrition facts are indicated per serving.