shivanis14 commited on
Commit
388893c
1 Parent(s): 49be9b4

Update nutrient_analyzer.py

Browse files
Files changed (1) hide show
  1. nutrient_analyzer.py +7 -1
nutrient_analyzer.py CHANGED
@@ -42,6 +42,8 @@ def analyze_nutrients(product_type, calories, sugar, salt, serving_size):
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': {
@@ -52,7 +54,9 @@ def analyze_nutrients(product_type, calories, sugar, salt, serving_size):
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': {
58
  'value': scaled_salt,
@@ -62,6 +66,8 @@ def analyze_nutrients(product_type, calories, sugar, salt, serving_size):
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
 
 
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
+ else:
46
+ nutrient_analysis_str += f"Calories are {nutrient_analysis['calories']['percentageDiff']}% below the ICMR-defined threshold."
47
 
48
  if scaled_sugar is not None:
49
  nutrient_analysis.update({'sugar': {
 
54
  }})
55
  if nutrient_analysis['sugar']['percentageDiff'] > 0:
56
  nutrient_analysis_str += f" Sugar exceeds the ICMR-defined threshold by {nutrient_analysis['sugar']['percentageDiff']}%."
57
+ else:
58
+ nutrient_analysis_str += f"Sugar is {nutrient_analysis['sugar']['percentageDiff']}% below the ICMR-defined threshold."
59
+
60
  if scaled_salt is not None:
61
  nutrient_analysis.update({'salt': {
62
  'value': scaled_salt,
 
66
  }})
67
  if nutrient_analysis['salt']['percentageDiff'] > 0:
68
  nutrient_analysis_str += f" Salt exceeds the ICMR-defined threshold by {nutrient_analysis['salt']['percentageDiff']}%."
69
+ else:
70
+ nutrient_analysis_str += f"Salt is {nutrient_analysis['salt']['percentageDiff']}% below the ICMR-defined threshold."
71
 
72
  return nutrient_analysis_str
73