shivanis14 commited on
Commit
493a205
1 Parent(s): 9d84e1a

Update nutrient_analyzer.py

Browse files
Files changed (1) hide show
  1. nutrient_analyzer.py +3 -3
nutrient_analyzer.py CHANGED
@@ -41,7 +41,7 @@ def analyze_nutrients(product_type, calories, sugar, salt, serving_size):
41
  'percentageDiff': calculate_percentage_difference(scaled_calories, threshold_data['calories'])
42
  }})
43
  if nutrient_analysis['calories']['percentageDiff'] > 0:
44
- nutrient_analysis_str += f"Calories exceed the ICMR-defined threshold by {nutrient_analysis['calories']['percentageDiff']}."
45
 
46
  if scaled_sugar is not None:
47
  nutrient_analysis.update({'sugar': {
@@ -51,7 +51,7 @@ def analyze_nutrients(product_type, calories, sugar, salt, serving_size):
51
  'percentageDiff': calculate_percentage_difference(scaled_sugar, threshold_data['sugar'])
52
  }})
53
  if nutrient_analysis['sugar']['percentageDiff'] > 0:
54
- nutrient_analysis_str += f" Sugar exceeds the ICMR-defined threshold by {nutrient_analysis['sugar']['percentageDiff']}."
55
 
56
  if scaled_salt is not None:
57
  nutrient_analysis.update({'salt': {
@@ -61,7 +61,7 @@ def analyze_nutrients(product_type, calories, sugar, salt, serving_size):
61
  'percentageDiff': calculate_percentage_difference(scaled_salt, threshold_data['salt'])
62
  }})
63
  if nutrient_analysis['salt']['percentageDiff'] > 0:
64
- nutrient_analysis_str += f" Salt exceeds the ICMR-defined threshold by {nutrient_analysis['salt']['percentageDiff']}."
65
 
66
  return nutrient_analysis_str
67
 
 
41
  'percentageDiff': calculate_percentage_difference(scaled_calories, threshold_data['calories'])
42
  }})
43
  if nutrient_analysis['calories']['percentageDiff'] > 0:
44
+ nutrient_analysis_str += f"Calories exceed the ICMR-defined threshold by {nutrient_analysis['calories']['percentageDiff']}%."
45
 
46
  if scaled_sugar is not None:
47
  nutrient_analysis.update({'sugar': {
 
51
  'percentageDiff': calculate_percentage_difference(scaled_sugar, threshold_data['sugar'])
52
  }})
53
  if nutrient_analysis['sugar']['percentageDiff'] > 0:
54
+ nutrient_analysis_str += f" Sugar exceeds the ICMR-defined threshold by {nutrient_analysis['sugar']['percentageDiff']}%."
55
 
56
  if scaled_salt is not None:
57
  nutrient_analysis.update({'salt': {
 
61
  'percentageDiff': calculate_percentage_difference(scaled_salt, threshold_data['salt'])
62
  }})
63
  if nutrient_analysis['salt']['percentageDiff'] > 0:
64
+ nutrient_analysis_str += f" Salt exceeds the ICMR-defined threshold by {nutrient_analysis['salt']['percentageDiff']}%."
65
 
66
  return nutrient_analysis_str
67