Jump to content

Data fields: Difference between revisions

More on serving size
(Initial version)
 
(More on serving size)
Line 12: Line 12:


==== Serving size ====
==== Serving size ====
Serving size has specific goal: to let Open Food Facts app make a proportional calculation of each nutrient per serving size. If a candy's weight is 5 g, it can be chosen as the serving size: if these candies has 66 g of sugar per 100 g, it has about 3 g per candy.
Serving size has a specific goal: to let Open Food Facts app make a proportional calculation of each nutrient per serving size. If a candy's weight is 5 g, it can be chosen as the serving size: if these candies has 66 g of sugar per 100 g, it has about 3 g per candy. [https://github.com/openfoodfacts/openfoodfacts-server/blob/f25308b7d47255be83210f699f897cba87c9517f/lib/ProductOpener/Food.pm#L3835 Allowed units] are: <code>kg, g, mg, µg, oz, l, dl, cl, ml, fl.oz, fl oz, г, мг, кг, л, дл, кл, мл, 毫克, 公斤, 毫公升, 吨</code>.
 
<code>grammes</code>, <code>liter</code>, etc., are NOT recognized.
 
Decimals can be written with a comma (<code>,</code>) or a point (<code>.</code>).


Good:
Good:
* 60 g
* <code>60 g</code> (preferred, for readability reasons)
* 30g
* <code>30g</code>
* <code>35G</code>
* <code>90 ml</code>
* <code>1L</code>
 
Possible (while not recommanded):
* <code>cookie 25g</code>
* <code>One Slice (50g)</code>
* <code>97 g (0.5 cup)</code>


Bad:
Bad:
* 30 gr
* <code>30 gr</code> => <code>gr</code> is not a correct unit
* 9 candies and 2 biscuits
* <code>9 candies and 2 biscuits</code> => it's not possible to calculate a ratio because we don't know the weight of this portion
* 30
* <code>30</code> => there is no unit