Open danielcavanagh opened 1 year ago
Hi! I'd like to work on this, can I? @stephanegigandet
I'd be very grateful to get suggestions on how to start working with this one. I have been trying to understand how the different subroutines work to calculate percent_estimate
, percent_max
, etc. To work towards a resolution, we could add a condition to handle cases where min%
is specified, updating the logic to consider it while calculations and not set values equal to percent_min
.
Looking forward to suggestions and guidance to go ahead, thank you! @stephanegigandet @alexgarel
Hey @deveshidwivedi
When I first posted this issue I spent some time working out an algorithm that correctly estimates %s based on both min and max. It's in the attached Excel spreadsheet (lines 4-6 & 10 are what you need). At the time I was unable to make it produce invalid %s (unlike the current algorithm) so I think it's pretty robust. Hopefully you find it useful. It should be fairly straightforword to convert to code
The only other thing I would say that isn't in the spreadsheet is that if a min for an ingredient isn't set I think it should default to 0% and if a max isn't set then it should be equal to the previous ingredient's max. I can't remember if this is how it works already but I thought I should note it just in case
Good luck! š
Problem
If a minimum % is specified in the ingredients list on the label (eg. 'hazelnuts (min 36%)'), it is parsed without error but
percent
,percent_estimate
,percent_max
, andpercent_min
are all set to be exactly the % on the label with no account for the minimumProposed solution
Only
percent_min
should be set to the % on the label.percent
should indicate that a minimum was specified, andpercent_estimate
andpercent_max
should be estimated based on the min % and the other ingredientsAdditional context
Eg. https://en.openfoodfacts.org/api/v0/product/9346758004008/hazelnut-chocolate-spread-pana-organic
Currently:
Should be:
Number of products impacted
Minimal