openfoodfacts / openfoodfacts-dart

Open Food Facts API Wrapper
https://pub.dev/packages/openfoodfacts
Apache License 2.0
161 stars 65 forks source link

Missing nutrients (e.g. Polyols) #862

Open monsieurtanuki opened 8 months ago

monsieurtanuki commented 8 months ago

Description

cf. @CharlesNepote's https://github.com/openfoodfacts/smooth-app/issues/4943 There are some nutrients in Food.pm and https://world.openfoodfacts.org/cgi/nutrients.pl?lc=fr&cc=fr that we don't deal with in off-dart: they are not in off-dart's Nutrient enum.

Expected behavior

We should be able to deal with all nutrients, at least most of them.

monsieurtanuki commented 8 months ago

@CharlesNepote There are 47 "nutrients" found in Food.pm that are currently not in off-dart. For each nutrient, we need to attach a Unit (KCAL, KJ, G, MILLI_G, MICRO_G, MILLI_L, L, PERCENT). Would you list the important nutrients you would like to see added, each with their unit?

  1. alpha-linolenic-acid
  2. arachidic-acid
  3. arachidonic-acid
  4. behenic-acid
  5. beta-carotene
  6. bicarbonate
  7. carbon-footprint
  8. carbon-footprint-from-meat-or-fish
  9. casein
  10. cerotic-acid
  11. chlorophyl
  12. cocoa
  13. collagen-meat-protein-ratio
  14. dihomo-gamma-linolenic-acid
  15. elaidic-acid
  16. energy-from-fat
  17. folates
  18. fructose
  19. fruits-vegetables-nuts
  20. fruits-vegetables-nuts-dried
  21. fruits-vegetables-nuts-estimate
  22. gamma-linolenic-acid
  23. glucose
  24. glycemic-index
  25. gondoic-acid
  26. insoluble-fiber
  27. lactose
  28. lignoceric-acid
  29. maltodextrins
  30. maltose
  31. mead-acid
  32. melissic-acid
  33. montanic-acid
  34. nervonic-acid
  35. nucleotides
  36. nutrition-score-fr
  37. nutrition-score-uk
  38. omega-9-fat
  39. ph
  40. polyols
  41. serum-proteins
  42. silica
  43. soluble-fiber
  44. starch
  45. sucrose
  46. taurine
  47. water-hardness
CharlesNepote commented 8 months ago

@monsieurtanuki, I have investigated a little bit and, yes, all your questions' answers are in the Perl code: https://github.com/openfoodfacts/openfoodfacts-server/blob/7d295d10fcc8939cccfd093810cb0edb8a3c9449/lib/ProductOpener/Food.pm#L400

We should ask ourselves if these data shouldn't be provided as data, and not as Perl code, to let any kind of apps reuse it more easily -- a YAML file as it allows comments? Should I open a bug @stephanegigandet ?

monsieurtanuki commented 8 months ago

@CharlesNepote Developers can already get a JSON version of it with https://world.openfoodfacts.org/cgi/nutrients.pl?lc=fr&cc=fr, easy to reuse, therefore I think we're already almost good here. Except that the unit is missing: that would be helpful for instance to know that vitamin b12 is rather given in µg. Where does the default unit come from?

stephanegigandet commented 8 months ago

@monsieurtanuki @CharlesNepote all the nutrients and their default unit are in the nutrients taxonomy: https://github.com/openfoodfacts/openfoodfacts-server/blob/main/taxonomies/nutrients.txt

I can add the units to the output of https://world.openfoodfacts.org/cgi/nutrients.pl?lc=fr&cc=fr

monsieurtanuki commented 8 months ago

I can add the units to the output of https://world.openfoodfacts.org/cgi/nutrients.pl?lc=fr&cc=fr

@stephanegigandet That would be nice, that's typically the unit:en: µg info that we need in the current issue.

CharlesNepote commented 7 months ago

@monsieurtanuki : FYI, @stephanegigandet has added the units into https://world.openfoodfacts.org/cgi/nutrients.pl?lc=fr&cc=fr

monsieurtanuki commented 7 months ago

Thank you @CharlesNepote @stephanegigandet! That means we can now add the unit into our OrderedNutrient object.

For the record, some stats about the lc=fr&cc=fr unit repartition:

monsieurtanuki commented 7 months ago

To be checked, added or edited in off-dart (data from lc=fr&cc=fr):