Products quantities: Difference between revisions

From Open Food Facts wiki
No edit summary
 
(34 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Fields]]
== Quantities ==
Collecting quantity isn't so simple:
* we can see various units
* we can see various ways of dealing with net weight and drained weight
* sometimes portions are well specified and sometimes not
* we can see many ways of ordering printed data on the packages
* ...
=== Units ===
...
=== e sign ===
The ℮ sign (for "[https://en.wikipedia.org/wiki/Estimated_sign estimated sign]") is used in Europe and other countries, at least Australia: https://www.industry.gov.au/sites/default/files/2019-04/guide-to-the-average-quantity-system.pdf (p. 12)
It seems to refer to the Average Quantity System (AQS) which is in use in Australia, Canada, European Union, India, Japan, New Zealand, South Africa and Switzerland -- source: https://www.sfa.gov.sg/docs/default-source/tools-and-resources/resources-for-businesses/avabriefingonaqsslides1 (slide 3).
== How to enter the data ==
For the moment, the best is to enter the data as it is printed on the product.
== How to handle it ==
== How to handle it ==
=== Logic to handle it ===
=== Logic to handle it ===
...
=== Existing libraries to parse weights and quantities ===
=== Existing libraries to parse weights and quantities ===
* https://github.com/iancanderson/ingreedy
* https://github.com/iancanderson/ingreedy
Line 21: Line 46:
**Useful to fix calorie calculation for some products
**Useful to fix calorie calculation for some products
* Calculate packaging weight by making the difference between actual weight and advertised weight
* Calculate packaging weight by making the difference between actual weight and advertised weight
* Calculate weight per volume for products (1dL of water is 1kg, but this changes for various products that also have a mention of their volume)
* Calculate weight per volume for products (1dL of water is 1kg, but this changes for various products that also have a mention of their volume, e.g. milk)
* Some products will have multilingual weights
* Some products will have multilingual weights
** we can check that the conversion is well done if we have both values
** we can check that the conversion is well done if we have both values
** we can display the value in several metrics if we have a sanitized value in one metric
** we can display the value in several metrics if we have a sanitized value in one metric


=== Generic approach ===
=== Canonical approach ===
The real-world quantities for products as used by the users us a far from ideal. However it is possible to find some common approach. (At least we try here)
The real-world quantities for products as used by the user (and printed on the packages) is not ideal. It is often impossible to parse the quantities and understand what is indicated.
* to indicate times, either a "*" or a "x" can be used;
However it is possible to find some common approach. This is a first attempt.
* the generic formula is: multiplier * quantity size_unit for units
 
* multiple formulas are distinguished by a ";"
Some remarks:
* product central - any quantity that is indicated is about the product and not the packaging;
* product unit - reference may be made to a product unit, eg a cookie, a chocolate egg, etc.
* equivalents - one or more equivalents might be available, i.e. in grams, oz or liters, 24 cookies / 6 cookies in 4 packages;
* containers - the generic toplevel package is a container;
* subcontainers - a container might comprise multiple subcontainers (or even subsubcontainers) [hierarchy?/taxonomy?]
* (sub-)container synonyms - a user might container other words to describe a container, such as bottle, can, bag, etc.  [hierarchy?/taxonomy?]
* defaults - in indicating the quantity some parts are assumed to be understood. If it states 33cl it is assumed to be about the container (the bottle) and the product (beer);
* components - a product might consist of multiple components, which must be combined to get the product. Cf Creme brulee = vanilla cream + caramel flakes (to be heated).
* subproduct - sometimes a subproduct quantity is indicated (net/brut, egoutté/drained);
* verbosity - the language used in specifying quantity must be translated to a parsable format;
* scattered - all information necessary to fill the entire quantity formula might be scattered over the package.
* detail quantities - sometimes a detailed quantity might be present (1 biscuit weighs 23g) and a multiplier is needed to get the total weight of the package;
* marketing - some quantities are added for marketing purposes, extra 25g;
* subsubcontainers - an extra subdivision, eg 1 carton of yoghurt with 2 layers and 8 pots per layer;
* servings - a quantity might contain a number of servings
 
=== Generic formula ===
Any generic quantity formula should reference the product(-name), the container and a volume or weight measure. The productname and container should (?) reference the corresponding fields.
 
The quantity formula is:<br \><br \>
 
<big>container_multiplier x container_name x product_multiplier x (sub_)product_name x quantity_value x quantity_unit</big>
 
This formula should be valid for each container/subcontainer/subsubcontainer level, but should reflect the entire package. So one has to add multipliers and brackets where appropriate.
 
For example:
* 1 bottle of red wine comprising 70 cl (on the bottle indicated as "70 cl");
* 1 package of granola cookies with a total weight of 276 g (just printed as 276g), which is equivalent to:
** 1 package of 12 biscuits with a total weight of 276g, which is equivalent to:
** 1 package of 12 biscuits with an individual weight of 23g per biscuit.
 
=== Practical usage ===
In practice however other indications are used by users. There is no best practice defined.
 
* to indicate times, either a "*" or a "x" is used;
* equivalent formulas are distinguished by a ";" or brackets "(,)"
** multiplier indicates how often a quantity unit is used, i.e. 6 (25 cl bottles). This is a number.
** multiplier indicates how often a quantity unit is used, i.e. 6 (25 cl bottles). This is a number.
** quantity the size of the units in size_units, i.e. 25 (size) cl (size_unit) bottles (units). This is a number.
** quantity the size of the units in size_units, i.e. 25 (size) cl (size_unit) bottles (units). This is a number.
Line 36: Line 97:
** unit is the element the numbers and sizes refer to, i.e. pot, bottle, sack, etc.
** unit is the element the numbers and sizes refer to, i.e. pot, bottle, sack, etc.


Some remarks:
=== Test approach ===
* not all 4 elements are always specified, eg 250 g means 1*250 g for the entire product
* sometimes more than one quantity is specified, e.g. 250 g (5x50 g) might mean 1x250g for the entire product OR 5 50g pots
* there are exceptions, such as multiple multipliers.
* naturally users do not use this formal approach, but most quantities can be translated to this approach.
 
Test:
To test this approach the examples found in France have translated to this formal approach:
To test this approach the examples found in France have translated to this formal approach:
{| class="wikitable sortable"
{| class="wikitable sortable"
|-
|-
! Quantity as stated by user !! Multiplier !! Quantity !! Size_unit !! Units
! Quantity as stated by user !! Container multiplier !! Container name !! Product multiplier !! Product name !! Quantity value !! Quantity unit
|-
| 1 kg (8 pots) - [2 x (4 x 125 g)] || 8 || pots || - || - || 1 || kg
|-
| or || 2 x 4 || pots || - || - || 125 || g
|-
| 275 g [250 g + 25 g (10 %) gratuit] || - || - || - || - || 275 || g
|-
| or || - || - || - || - || 275 + 25 || g
|-
| 2 * 400 g (800 g) ||  2 || - || - || - || 400 || g
|-
| or || - || - || - || - || 800 || g
|-
| 4X100g || 4 || - || - || - || 100 || g
|-
| 2*25g || 2 || - || - || - || 25 || g
|-
| 200 g [160 g (2 x 8 pièces) mini-nems + 40 g sauce nuoc mâm] || - || - || - || - || 200 || g
|-
| or || - || - || 2x8 || mini-nems || 160 || g
|-
| + || - || - || - || sauce nuoc mâm || 40 || g
|-
|-
| 1 kg (8 pots) - [2 x (4 x 125 g)] || - || 1 || kg || -
| 211,5 g (9x23,5g) || - || - || - || - || 211,5 || g
|-
|-
| or || 8 || - || - || pots
| or || 9 || - || - || - || 23,5 || g
|-
|-
| or || 2x4 || 125 || g || -
| 220g (2 unités, 2 x (60 g + 50 g)) || - || - || || - || 220 || g
|-
|-
| 275 g [250 g + 25 g (10 %) gratuit] ||  
| or || - || - || 2  || unités || 60 + 50 || g
|-
|-
| 2 * 400 g (800 g) ||  
| 2 x 21.5 g = 43 g || - || - || -  || - || 43 || g
|-
|-
| 4X100g || 4 || 100 || g || -
| or || 2 || - || || - || 21.5 || g
|-
|-
| 2*25g || 2 || 25 || g || -
| 300 g (15 biscuits de 20 g) || - || - || || - || 300 || g
|-
|-
| 200 g [160 g (2 x 8 pièces) mini-nems + 40 g sauce nuoc mâm] ||
| or || - || - || 15  || biscuits || 20 || g
|-
|-
| 211,5 g (9x23,5g) || - || 211,5 || g || -
| 1 Litre || - || - || || - || 1 || litre
|-
|-
| or || 9 || 23,5 || g || -
| 18tranche || - || - || 18 || tranches || - || -
|-
|-
| 220g (2 unités, 2 x (60 g + 50 g)) ||  
| 375 g, 30 pièces || - || - || - || - || 375 || g
|-
|-
| 2 x 21.5 g = 43 g ||  
| or || - || - || 30 || pièces || - || -
|-
|-
| 300 g (15 biscuits de 20 g) ||  
| 240 g (12 Portions) || -  || - || - || - || 240 || g
|-
|-
| 1 Litre || - || 1 || litre || -
| or || - || - || 12 || portions|| - || -
|-
|-
| 18tranche || 18 || - || - || tranches
| 400 g (12 à 18 bouchées )|| -  || - || - || - || 400 || g
|-
|-
| 375 g, 30 pièces || - || 375 || g || -
| or || - || - || 12 à 18 || bouchées || - || -
|-
|-
| or || 30 || - || - || pièces
| Poids net 190 g, poids net égoutté 140 g || || - || - || net || 190 || g
|-
|-
| 240 g (12 Portions) || - || 240 || g || -
| Poids net 190 g, poids net égoutté 140 g || -  || - || - || net égoutté || 140 || g
|-
|-
| or || 12 || - || - || portions
| contenance : 4250ml, poids net total : 4000g, poids net égoutté : 2210g ||-  || - || - || - || 4250 || ml
|-
|-
| 400 g (12 à 18 bouchées) ||  
| or ||-  || - || - || net || 4000 || g
|-
|-
| Poids net 190 g, poids net égoutté 140 g ||
| or  ||-  || - || - || net égoutté || 2210 || g
|-
|-
| contenance : 4250ml, poids net total : 4000g, poids net égoutté : 2210g ||
| 3 x [200 g (130 g net égoutté), 212 ml] || 3 || - || - || - || 200 || g
|-
|-
| 3 x [200 g (130 g net égoutté), 212 ml] ||
| or || 3 || - || - || - || 212 || ml
|-
|-
| 330 g (dont 180 g net), 370 mL ||
| or || 3 || - || - || net egoutté || 130 || g
|-
|-
| 28 g - 20 dragées || - || 28 || g || -
| 330 g (dont 180 g net), 370 mL ||-  || - || - || - || 330 || g
|-
|-
| or || 20 || - || - || dragées
| or ||-  || - || - || - || 370 || mL
|-
|-
| 260 g (26 portions de 10 g)
|         or ||-  || - || - || net || 180 || g
|-
|-
| 130 g pour 20 galettes || - || 130 || g || -
| 28 g - 20 dragées || - || - || 20 || dragées || 28 || g
|-
|-
| or || 20 || - || - || galettes
| 260 g (26 portions de 10 g) || -  || - || - || - || 260 || g
|-
|-
| 280 ml - 310 g || - || 280 || ml || -
| 130 g pour 20 galettes || - || - || 20 || galettes || 130 || g
|-
|-
| || - || 310 || g || -
| 280 ml - 310 g || - || - || - ||- || 280 || ml
|-
|-
| 25 sachets || 25 || - || - || sachets
| or || - -  || - || - ||- || 310 || g
|-
|-
| 220 g (1 personne) || - || 220 || g || -
| 25 sachets || 25 || sachets || - || - || - || -
|-
|-
| 128 g (16 bâtonnets de 2 cubes) || - || 128 || g || -
| 220 g (1 personne) || - || - || - || - || 220 || g
|-
|-
|  || 16 || - || - || bâtonnets
| 128 g (16 bâtonnets de 2 cubes) || - || - || 16 || bâtonnets || 128 || g
|-
|-
| || 16x4 || - || - || cubes
| or || - || - || 16x2 || cubes || 128 || g
|-
|-
| 12 (calibre Moyen => 53 à 63 g) || 12 || - || - || calibre moyen
| 12 (calibre Moyen => 53 à 63 g) || - || - || 12 || calibre moyen || 53 à 63 || g
|-
|-
| 8 sachets de 4 || 8 || - || - || sachets
| 8 sachets de 4 || 8 || sachets || 4 || - || - || -
|-
|-
| || 8x4 || - || - || -
| 400 g, 425 ml (3 douzaines) || - || - || 3x12 || - || 400 || g
|-
|-
| 400 g, 425 ml (3 douzaines)
| 400 g, 425 ml (3 douzaines) || - || - || 3x12 || - || 425 || ml
|-
|-
| 228g (4x57g) / 48 cl (4x12cl)
| 228g (4x57g) / 48 cl (4x12cl)
Line 200: Line 277:
| nestle || 228g (4x57g) / 48 cl (4x12cl) || [http://fr.openfoodfacts.org/produit/2000000003897 (link)]
| nestle || 228g (4x57g) / 48 cl (4x12cl) || [http://fr.openfoodfacts.org/produit/2000000003897 (link)]
|}
|}
 
[[Category:OCR]]
[[Category:ProductOpener]]
[[Category:ProductOpener]]

Latest revision as of 07:34, 7 August 2024

Quantities

Collecting quantity isn't so simple:

  • we can see various units
  • we can see various ways of dealing with net weight and drained weight
  • sometimes portions are well specified and sometimes not
  • we can see many ways of ordering printed data on the packages
  • ...

Units

...

e sign

The ℮ sign (for "estimated sign") is used in Europe and other countries, at least Australia: https://www.industry.gov.au/sites/default/files/2019-04/guide-to-the-average-quantity-system.pdf (p. 12)

It seems to refer to the Average Quantity System (AQS) which is in use in Australia, Canada, European Union, India, Japan, New Zealand, South Africa and Switzerland -- source: https://www.sfa.gov.sg/docs/default-source/tools-and-resources/resources-for-businesses/avabriefingonaqsslides1 (slide 3).


How to enter the data

For the moment, the best is to enter the data as it is printed on the product.


How to handle it

Logic to handle it

...

Existing libraries to parse weights and quantities

Using Wikidata

Possible calculations

  • Weight per item
    • Is the same item always the same weight (ham slices)
    • Useful if you eat one of the cakes in the packaging, and want to know how many calories you ate without having to weight the cake
  • Percentage of water
    • Useful to calculate actual cost if we know the price
    • Useful to fix calorie calculation for some products
  • Calculate packaging weight by making the difference between actual weight and advertised weight
  • Calculate weight per volume for products (1dL of water is 1kg, but this changes for various products that also have a mention of their volume, e.g. milk)
  • Some products will have multilingual weights
    • we can check that the conversion is well done if we have both values
    • we can display the value in several metrics if we have a sanitized value in one metric

Canonical approach

The real-world quantities for products as used by the user (and printed on the packages) is not ideal. It is often impossible to parse the quantities and understand what is indicated. However it is possible to find some common approach. This is a first attempt.

Some remarks:

  • product central - any quantity that is indicated is about the product and not the packaging;
  • product unit - reference may be made to a product unit, eg a cookie, a chocolate egg, etc.
  • equivalents - one or more equivalents might be available, i.e. in grams, oz or liters, 24 cookies / 6 cookies in 4 packages;
  • containers - the generic toplevel package is a container;
  • subcontainers - a container might comprise multiple subcontainers (or even subsubcontainers) [hierarchy?/taxonomy?]
  • (sub-)container synonyms - a user might container other words to describe a container, such as bottle, can, bag, etc. [hierarchy?/taxonomy?]
  • defaults - in indicating the quantity some parts are assumed to be understood. If it states 33cl it is assumed to be about the container (the bottle) and the product (beer);
  • components - a product might consist of multiple components, which must be combined to get the product. Cf Creme brulee = vanilla cream + caramel flakes (to be heated).
  • subproduct - sometimes a subproduct quantity is indicated (net/brut, egoutté/drained);
  • verbosity - the language used in specifying quantity must be translated to a parsable format;
  • scattered - all information necessary to fill the entire quantity formula might be scattered over the package.
  • detail quantities - sometimes a detailed quantity might be present (1 biscuit weighs 23g) and a multiplier is needed to get the total weight of the package;
  • marketing - some quantities are added for marketing purposes, extra 25g;
  • subsubcontainers - an extra subdivision, eg 1 carton of yoghurt with 2 layers and 8 pots per layer;
  • servings - a quantity might contain a number of servings

Generic formula

Any generic quantity formula should reference the product(-name), the container and a volume or weight measure. The productname and container should (?) reference the corresponding fields.

The quantity formula is:

container_multiplier x container_name x product_multiplier x (sub_)product_name x quantity_value x quantity_unit

This formula should be valid for each container/subcontainer/subsubcontainer level, but should reflect the entire package. So one has to add multipliers and brackets where appropriate.

For example:

  • 1 bottle of red wine comprising 70 cl (on the bottle indicated as "70 cl");
  • 1 package of granola cookies with a total weight of 276 g (just printed as 276g), which is equivalent to:
    • 1 package of 12 biscuits with a total weight of 276g, which is equivalent to:
    • 1 package of 12 biscuits with an individual weight of 23g per biscuit.

Practical usage

In practice however other indications are used by users. There is no best practice defined.

  • to indicate times, either a "*" or a "x" is used;
  • equivalent formulas are distinguished by a ";" or brackets "(,)"
    • multiplier indicates how often a quantity unit is used, i.e. 6 (25 cl bottles). This is a number.
    • quantity the size of the units in size_units, i.e. 25 (size) cl (size_unit) bottles (units). This is a number.
    • size_units is the unit for the size parameter, i.e. kg, ml or cl. This is an enumerated?
    • unit is the element the numbers and sizes refer to, i.e. pot, bottle, sack, etc.

Test approach

To test this approach the examples found in France have translated to this formal approach:

Quantity as stated by user Container multiplier Container name Product multiplier Product name Quantity value Quantity unit
1 kg (8 pots) - [2 x (4 x 125 g)] 8 pots - - 1 kg
or 2 x 4 pots - - 125 g
275 g [250 g + 25 g (10 %) gratuit] - - - - 275 g
or - - - - 275 + 25 g
2 * 400 g (800 g) 2 - - - 400 g
or - - - - 800 g
4X100g 4 - - - 100 g
2*25g 2 - - - 25 g
200 g [160 g (2 x 8 pièces) mini-nems + 40 g sauce nuoc mâm] - - - - 200 g
or - - 2x8 mini-nems 160 g
+ - - - sauce nuoc mâm 40 g
211,5 g (9x23,5g) - - - - 211,5 g
or 9 - - - 23,5 g
220g (2 unités, 2 x (60 g + 50 g)) - - - - 220 g
or - - 2 unités 60 + 50 g
2 x 21.5 g = 43 g - - - - 43 g
or 2 - - - 21.5 g
300 g (15 biscuits de 20 g) - - - - 300 g
or - - 15 biscuits 20 g
1 Litre - - - - 1 litre
18tranche - - 18 tranches - -
375 g, 30 pièces - - - - 375 g
or - - 30 pièces - -
240 g (12 Portions) - - - - 240 g
or - - 12 portions - -
400 g (12 à 18 bouchées ) - - - - 400 g
or - - 12 à 18 bouchées - -
Poids net 190 g, poids net égoutté 140 g - - - net 190 g
Poids net 190 g, poids net égoutté 140 g - - - net égoutté 140 g
contenance : 4250ml, poids net total : 4000g, poids net égoutté : 2210g - - - - 4250 ml
or - - - net 4000 g
or - - - net égoutté 2210 g
3 x [200 g (130 g net égoutté), 212 ml] 3 - - - 200 g
or 3 - - - 212 ml
or 3 - - net egoutté 130 g
330 g (dont 180 g net), 370 mL - - - - 330 g
or - - - - 370 mL
or - - - net 180 g
28 g - 20 dragées - - 20 dragées 28 g
260 g (26 portions de 10 g) - - - - 260 g
130 g pour 20 galettes - - 20 galettes 130 g
280 ml - 310 g - - - - 280 ml
or - - - - - 310 g
25 sachets 25 sachets - - - -
220 g (1 personne) - - - - 220 g
128 g (16 bâtonnets de 2 cubes) - - 16 bâtonnets 128 g
or - - 16x2 cubes 128 g
12 (calibre Moyen => 53 à 63 g) - - 12 calibre moyen 53 à 63 g
8 sachets de 4 8 sachets 4 - - -
400 g, 425 ml (3 douzaines) - - 3x12 - 400 g
400 g, 425 ml (3 douzaines) - - 3x12 - 425 ml
228g (4x57g) / 48 cl (4x12cl)

Countries

France

Product name Quantity as stated by user Product page URL
Brassé nature 1 kg (8 pots) - [2 x (4 x 125 g)] (link)
Emmental Coeur de Meule (28 % MG) 275 g [250 g + 25 g (10 %) gratuit] (link)
Basilico 2 * 400 g (800 g) (link)
Frais Malo Sucré 4X100g (link)
Twix 2*25g (link)
16 mini-nems Poulet, menthe, Légumes, coriandre - Précuits - Surgelés 200 g [160 g (2 x 8 pièces) mini-nems + 40 g sauce nuoc mâm] (link)
9 barres au chocolat au lait et aux céréales 211,5 g (9x23,5g) (link)
Fondant au chocolat 220g (2 unités, 2 x (60 g + 50 g)) (link)
Kinder Bueno 2 x 21.5 g = 43 g (link)
Prince Goût Chocolat 300 g (15 biscuits de 20 g) (link)
Eau minérale Contrex 1 Litre (link)
Brioche Harrys Tranchée la recette Originale 18tranche (link)
FERRERO ROCHER Boîte de 30 375 g, 30 pièces (link)
Kiri® (32 % MG) à la crème de lait 240 g (12 Portions) (link)
Bouchées de Poulet à la provençale 400 g (12 à 18 bouchées) (link)
Thon entier au naturel Poids net 190 g, poids net égoutté 140 g (link)
Haricots beurre très fins contenance : 4250ml, poids net total : 4000g, poids net égoutté : 2210g (link)
Lentilles (Lot de 3 boîtes) 3 x [200 g (130 g net égoutté), 212 ml] (link)
Délices du Potager - Mini poireaux 330 g (dont 180 g net), 370 mL (link)
Chewing Gum Hollywood 28 g - 20 dragées (link)
Fruit d'Or pro-activ® (35% MG) Tartine 260 g - Unilever 260 g (26 portions de 10 g) (link)
Galettes, tout au beurre 130 g pour 20 galettes (link)
Ketchup P'tits Heinz 280 ml - 310 g (link)
Original Earl Grey 25 sachets (link)
Cappellettis Tofu, Epinards Bio - 220 g - Céréal Bio 220 g (1 personne) (link)
KUB ® Or 128 g (16 bâtonnets de 2 cubes) (link)
Oeufs de poules Elevées en Plein Air (x 12) calibre Moyen - Carrefour 12 (calibre Moyen => 53 à 63 g) (link)
Belvita sablé lait 8 sachets de 4 (link)
Escargots de Bourgogne Extra Gros - 400 g - E 400 g, 425 ml (3 douzaines) (link)
nestle 228g (4x57g) / 48 cl (4x12cl) (link)