-
Notifications
You must be signed in to change notification settings - Fork 1
/
word_transformations.py
641 lines (619 loc) · 44.8 KB
/
word_transformations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
import json
from copy import deepcopy
import random
import re
class Transformer:
def __init__(self):
self.words_file_name = 'word_list.json'
with open(self.words_file_name, 'r') as words_file:
self.words_json = json.load(words_file)
self.transformation_mapping = {
1: self.to_non_vegetarian,
2: self.to_vegetarian,
3: self.to_non_healthy,
4: self.to_healthy,
5: self.to_chinese_cuisine,
6: self.to_gluten_free,
7: self.to_non_gluten_free,
8: self.to_thai_cuisine
}
def __getitem__(self, category):
return self.words_json.get(category, [])
def to_vegetarian(self, original_recipe):
'''Returns a new vegetarian recipe using to the recipe dictionary representation in recipeFetcher.py'''
new_recipe = deepcopy(original_recipe)
replacements = {} # Mapping meaty ingredient -> new vegetarian ingredient
for i, ingredient in enumerate(new_recipe['ingredients']):
tokens = ingredient.split()
if any(token in self['containsMeat'] for token in tokens):
# We've found a meaty ingredient! Replace it with a random veg protein
old_ingredient_t = next(iter(token for token in tokens if token in self['containsMeat']))
new_ingredient_t = replacements.get(old_ingredient_t, random.choice(self['vegetarianProteins'])) # use existing or choose new replacement
replacements[old_ingredient_t] = new_ingredient_t
new_recipe['ingredients'][i] = ingredient.replace(old_ingredient_t, new_ingredient_t) # Put the replacement into new ingredient list
# Loop through directions and stupidly replace tokens that are the old ingredient
for i, direction in enumerate(new_recipe['directions']):
direction = direction.replace("Watch Now", "") #remove "Watch Now" substring
tokens = direction.split()
for j, token in enumerate(tokens):
if token in replacements:
tokens[j] = replacements[token]
new_direction = ' '.join(tokens)
new_recipe['directions'][i] = new_direction
return new_recipe
def to_non_vegetarian(self, original_recipe):
'''Returns a new non-vegetarian recipe using to the recipe dictionary representation in recipeFetcher.py'''
new_recipe = deepcopy(original_recipe)
replacements = {} # Mapping meaty ingredient -> new vegetarian ingredient
for i, ingredient in enumerate(new_recipe['ingredients']):
tokens = ingredient.split()
if any(token in self['vegetarianProteins'] for token in tokens):
# We've found a meaty ingredient! Replace it with a random veg protein
old_ingredient_t = next(iter(token for token in tokens if token in self['vegetarianProteins']))
new_ingredient_t = replacements.get(old_ingredient_t, random.choice(self['containsMeat'])) # use existing or choose new replacement
replacements[old_ingredient_t] = new_ingredient_t
new_recipe['ingredients'][i] = ingredient.replace(old_ingredient_t, new_ingredient_t) # Put the replacement into new ingredient list
# Loop through directions and stupidly replace tokens that are the old ingredient
for i, direction in enumerate(new_recipe['directions']):
direction = direction.replace("Watch Now", "") #remove "Watch Now" substring
tokens = direction.split()
for j, token in enumerate(tokens):
if token in replacements:
tokens[j] = replacements[token]
new_direction = ' '.join(tokens)
new_recipe['directions'][i] = new_direction
return new_recipe
def to_healthy(self, original_recipe):
'''Returns a new vegetarian recipe using to the recipe dictionary representation in recipeFetcher.py'''
new_recipe = deepcopy(original_recipe)
replacements = {} # Mapping unhealthy ingredient -> new healthy ingredient
for i, ingredient in enumerate(new_recipe['ingredients']):
tokens = ingredient.split()
for unhealthy_ingredient in self['healthyReplacements'].keys():
if unhealthy_ingredient in ingredient:
# We've found an unhealthy ingredient! Replace it
old_ingredient_t = unhealthy_ingredient
new_ingredient_t = replacements.get(old_ingredient_t, self['healthyReplacements'][old_ingredient_t]) # use existing or choose new replacement
replacements[old_ingredient_t] = new_ingredient_t
new_recipe['ingredients'][i] = ingredient.replace(old_ingredient_t, new_ingredient_t) # Put the replacement into new ingredient list
break
if any(token == 'sugar' or token == 'salt' for token in tokens):
# Halves sugar and salt
quantity_pattern = re.compile('(?<!/)[\\d\\.]+(?!/)') # looks for a number that isn't a fraction
match = quantity_pattern.search(ingredient)
if not match: continue
new_quantity = float(match[0]) / 2
the_range = match.span()
new_ingredient = ingredient[:the_range[0]] + str(new_quantity) + ingredient[the_range[1]:]
new_recipe['ingredients'][i] = new_ingredient
# Loop through directions and stupidly replace tokens that are the old ingredient
for i, direction in enumerate(new_recipe['directions']):
direction = direction.replace("Watch Now", "") # remove "Watch Now" substring
for original, replacement in replacements.items():
if original in direction:
new_direction = direction.replace(original, replacement)
new_recipe['directions'][i] = new_direction
return new_recipe
def to_non_healthy(self, original_recipe):
'''Returns a new vegetarian recipe using to the recipe dictionary representation in recipeFetcher.py'''
new_recipe = deepcopy(original_recipe)
replacements = {} # Mapping unhealthy ingredient -> new healthy ingredient
for i, ingredient in enumerate(new_recipe['ingredients']):
tokens = ingredient.split()
for unhealthy_ingredient in self['unhealthyReplacements'].keys():
if unhealthy_ingredient in ingredient:
# We've found a healthy ingredient! Replace it
old_ingredient_t = unhealthy_ingredient
new_ingredient_t = replacements.get(old_ingredient_t, self['unhealthyReplacements'][old_ingredient_t]) # use existing or choose new replacement
replacements[old_ingredient_t] = new_ingredient_t
new_recipe['ingredients'][i] = ingredient.replace(old_ingredient_t, new_ingredient_t) # Put the replacement into new ingredient list
break
if any(token == 'sugar' or token == 'oil' or token == 'butter' for token in tokens):
# Doubles sugar and oil
quantity_pattern = re.compile('(?<!/)[\\d\\.]+(?!/)') # looks for a number that isn't a fraction
match = quantity_pattern.search(ingredient)
if not match: continue
new_quantity = float(match[0]) * 2
the_range = match.span()
new_ingredient = ingredient[:the_range[0]] + str(new_quantity) + ingredient[the_range[1]:]
new_recipe['ingredients'][i] = new_ingredient
# Loop through directions and stupidly replace tokens that are the old ingredient
for i, direction in enumerate(new_recipe['directions']):
direction = direction.replace("Watch Now", "") # remove "Watch Now" substring
for original, replacement in replacements.items():
if original in direction:
new_direction = direction.replace(original, replacement)
new_recipe['directions'][i] = new_direction
return new_recipe
def to_chinese_cuisine(self, original_recipe):
'''Returns a new chinese recipe'''
new_recipe = deepcopy(original_recipe)
replacements = {} # Mapping unhealthy ingredient -> new healthy ingredient
for category in self['chinese'].keys():
for i, ingredient in enumerate(new_recipe['ingredients']):
tokens = ingredient.split()
for non_chinese_ingredient in self[category]:
if non_chinese_ingredient in ingredient:
# We've found a healthy ingredient! Replace it
old_ingredient_t = non_chinese_ingredient
new_ingredient_t = replacements.get(old_ingredient_t, random.choice(self['chinese'][category])) # use existing or choose new replacement
replacements[old_ingredient_t] = new_ingredient_t
new_recipe['ingredients'][i] = ingredient.replace(old_ingredient_t, new_ingredient_t) # Put the replacement into new ingredient list
break
# Loop through directions and stupidly replace tokens that are the old ingredient
for i, direction in enumerate(new_recipe['directions']):
direction = direction.replace("Watch Now", "") # remove "Watch Now" substring
for original, replacement in replacements.items():
if original in direction:
new_direction = direction.replace(original, replacement)
new_recipe['directions'][i] = new_direction
return new_recipe
def to_gluten_free(self, original_recipe):
'''Returns a new non gluten-free recipe using to the recipe dictionary representation in recipeFetcher.py'''
new_recipe = deepcopy(original_recipe)
replacements = {} # Mapping gluten-free ingredient -> new non gluten-free ingredient
for i, ingredient in enumerate(new_recipe['ingredients']):
tokens = ingredient.split()
for gluten_ingredient in self['glutenfreeReplacements'].keys():
if gluten_ingredient in ingredient:
# We've found a gluten-containing ingredient! Replace it
old_ingredient_t = gluten_ingredient
new_ingredient_t = replacements.get(old_ingredient_t, self['glutenfreeReplacements'][old_ingredient_t]) # use existing or choose new replacement
replacements[old_ingredient_t] = new_ingredient_t
new_recipe['ingredients'][i] = ingredient.replace(old_ingredient_t, new_ingredient_t) # Put the replacement into new ingredient list
break
# Loop through directions and stupidly replace tokens that are the old ingredient
for i, direction in enumerate(new_recipe['directions']):
direction = direction.replace("Watch Now", "") # remove "Watch Now" substring
for original, replacement in replacements.items():
if original in direction:
new_direction = direction.replace(original, replacement)
new_recipe['directions'][i] = new_direction
return new_recipe
def to_non_gluten_free(self, original_recipe):
'''Returns a new non gluten-free recipe using to the recipe dictionary representation in recipeFetcher.py'''
new_recipe = deepcopy(original_recipe)
replacements = {} # Mapping gluten-free ingredient -> new non gluten-free ingredient
for i, ingredient in enumerate(new_recipe['ingredients']):
tokens = ingredient.split()
for gluten_free_ingredient in self['glutenReplacements'].keys():
if gluten_free_ingredient in ingredient:
# We've found a gluten-containing ingredient! Replace it
old_ingredient_t = gluten_free_ingredient
new_ingredient_t = replacements.get(old_ingredient_t, self['glutenReplacements'][old_ingredient_t]) # use existing or choose new replacement
replacements[old_ingredient_t] = new_ingredient_t
new_recipe['ingredients'][i] = ingredient.replace(old_ingredient_t, new_ingredient_t) # Put the replacement into new ingredient list
break
# Loop through directions and stupidly replace tokens that are the old ingredient
for i, direction in enumerate(new_recipe['directions']):
direction = direction.replace("Watch Now", "") # remove "Watch Now" substring
for original, replacement in replacements.items():
if original in direction:
new_direction = direction.replace(original, replacement)
new_recipe['directions'][i] = new_direction
return new_recipe
def to_thai_cuisine(self, original_recipe):
'''Returns a new chinese recipe'''
new_recipe = deepcopy(original_recipe)
replacements = {} # Mapping unhealthy ingredient -> new healthy ingredient
for category in self['thai'].keys():
for i, ingredient in enumerate(new_recipe['ingredients']):
tokens = ingredient.split()
for non_thai_ingredient in self[category]:
if non_thai_ingredient in ingredient:
# We've found a healthy ingredient! Replace it
old_ingredient_t = non_thai_ingredient
new_ingredient_t = replacements.get(old_ingredient_t, random.choice(self['thai'][category])) # use existing or choose new replacement
replacements[old_ingredient_t] = new_ingredient_t
new_recipe['ingredients'][i] = ingredient.replace(old_ingredient_t, new_ingredient_t) # Put the replacement into new ingredient list
break
# Loop through directions and stupidly replace tokens that are the old ingredient
for i, direction in enumerate(new_recipe['directions']):
direction = direction.replace("Watch Now", "") # remove "Watch Now" substring
for original, replacement in replacements.items():
if original in direction:
new_direction = direction.replace(original, replacement)
new_recipe['directions'][i] = new_direction
return new_recipe
if __name__ == '__main__':
testClass = Transformer()
old_recipe = {
'ingredients': ['12 whole wheat lasagna noodles',
'1 pound lean ground beef',
'2 cloves garlic, chopped',
'1/2 teaspoon garlic powder',
'1 teaspoon dried oregano, or to taste',
'salt and ground black pepper to taste',
'1 (16 ounce) package cottage cheese',
'2 eggs',
'1/2 cup shredded Parmesan cheese',
'1 1/2 (25 ounce) jars tomato-basil pasta sauce',
'2 cups shredded mozzarella cheese'],
'directions': ['Preheat oven to 350 degrees F (175 degrees C).\n Watch Now',
'Fill a large pot with lightly salted water and bring to a rolling boil over high heat. Once the water is boiling, add the lasagna noodles a few at a time, and return to a boil. Cook the pasta uncovered, stirring occasionally, until the pasta has cooked through, but is still firm to the bite, about 10 minutes. Remove the noodles to a plate.\n Watch Now',
'Place the ground beef into a skillet over medium heat, add the garlic, garlic powder, oregano, salt, and black pepper to the skillet. Cook the meat, chopping it into small chunks as it cooks, until no longer pink, about 10 minutes. Drain excess grease.\n Watch Now',
'In a bowl, mix the cottage cheese, eggs, and Parmesan cheese until thoroughly combined.\n Watch Now',
'Place 4 noodles side by side into the bottom of a 9x13-inch baking pan; top with a layer of the tomato-basil sauce, a layer of ground beef mixture, and a layer of the cottage cheese mixture. Repeat layers twice more, ending with a layer of sauce; sprinkle top with the mozzarella cheese. Cover the dish with aluminum foil.\n Watch Now',
'Bake in the preheated oven until the casserole is bubbling and the cheese has melted, about 30 minutes. Remove foil and bake until cheese has begun to brown, about 10 more minutes. Allow to stand at least 10 minutes before serving.\n Watch Now'],
'nutrition': [{'name': 'Total Fat',
'amount': '19.3',
'unit': 'g',
'daily_value': '30 %'},
{'name': 'Saturated Fat', 'amount': '9.0', 'unit': 'g', 'daily_value': None},
{'name': 'Cholesterol',
'amount': '115',
'unit': 'mg',
'daily_value': '38 %'},
{'name': 'Sodium', 'amount': '999', 'unit': 'mg', 'daily_value': '40 %'},
{'name': 'Potassium', 'amount': '717', 'unit': 'mg', 'daily_value': '20 %'},
{'name': 'Total Carbohydrates',
'amount': '47.1',
'unit': 'g',
'daily_value': '15 %'},
{'name': 'Dietary Fiber',
'amount': '6.3',
'unit': 'g',
'daily_value': '25 %'},
{'name': 'Protein', 'amount': '35.6', 'unit': 'g', 'daily_value': '71 %'},
{'name': 'Sugars', 'amount': '12', 'unit': 'g', 'daily_value': None},
{'name': 'Vitamin A', 'amount': '855', 'unit': 'IU', 'daily_value': None},
{'name': 'Vitamin C', 'amount': '2', 'unit': 'mg', 'daily_value': None},
{'name': 'Calcium', 'amount': '361', 'unit': 'mg', 'daily_value': None},
{'name': 'Iron', 'amount': '4', 'unit': 'mg', 'daily_value': None},
{'name': 'Thiamin', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Niacin', 'amount': '11', 'unit': 'mg', 'daily_value': None},
{'name': 'Vitamin B6', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Magnesium', 'amount': '74', 'unit': 'mg', 'daily_value': None},
{'name': 'Folate', 'amount': '41', 'unit': 'mcg', 'daily_value': None}]
}
print(json.dumps(testClass.to_vegetarian(old_recipe), indent=2))
'''
Should return (if beef -> tofu)
{
"ingredients": [
"12 whole wheat lasagna noodles",
"1 pound lean ground tofu",
"2 cloves garlic, chopped",
"1/2 teaspoon garlic powder",
"1 teaspoon dried oregano, or to taste",
"salt and ground black pepper to taste",
"1 (16 ounce) package cottage cheese",
"2 eggs",
"1/2 cup shredded Parmesan cheese",
"1 1/2 (25 ounce) jars tomato-basil pasta sauce",
"2 cups shredded mozzarella cheese"
],
"directions": [
"Preheat oven to 350 degrees F (175 degrees C). Watch Now",
"Fill a large pot with lightly salted water and bring to a rolling boil over high heat. Once the water is boiling, add the lasagna noodles a few at a time, and return to a boil. Cook the pasta uncovered, stirring occasionally, until the pasta has cooked through, but is still firm to the bite, about 10 minutes. Remove the noodles to a plate. Watch Now",
"Place the ground tofu into a skillet over medium heat, add the garlic, garlic powder, oregano, salt, and black pepper to the skillet. Cook the meat, chopping it into small chunks as it cooks, until no longer pink, about 10 minutes. Drain excess grease. Watch Now",
"In a bowl, mix the cottage cheese, eggs, and Parmesan cheese until thoroughly combined. Watch Now",
"Place 4 noodles side by side into the bottom of a 9x13-inch baking pan; top with a layer of the tomato-basil sauce, a layer of ground tofu mixture, and a layer of the cottage cheese mixture. Repeat layers twice more, ending with a layer of sauce; sprinkle top with the mozzarella cheese. Cover the dish with aluminum foil. Watch Now",
"Bake in the preheated oven until the casserole is bubbling and the cheese has melted, about 30 minutes. Remove foil and bake until cheese has begun to brown, about 10 more minutes. Allow to stand at least 10 minutes before serving. Watch Now"
],
...
}
'''
print("non-vegetarian recipe", json.dumps(testClass.to_non_vegetarian(old_recipe), indent=2))
old_unhealthy_recipe = { # just made this up
'ingredients': ['12 loaves of brioche',
'1 pound pork belly',
'2 cloves garlic, chopped',
'1/2 teaspoon garlic powder',
'1 teaspoon dried oregano, or to taste',
'3 tablespoons of butter',
'salt to taste',
'1 (16 ounce) package cottage cheese',
'2 eggs',
'1/2 cup shredded Parmesan cheese',
'1 1/2 (25 ounce) jars tomato-basil pasta sauce',
'2 cups shredded mozzarella cheese'],
'directions': ['Preheat oven to 350 degrees F (175 degrees C).\n Watch Now',
'Fill a large pot with lightly salted water and bring to a rolling boil over high heat. Once the water is boiling, add the loaves of bread a few at a time, and return to a boil. Cook the pasta uncovered, stirring occasionally, until the pasta has cooked through, but is still firm to the bite, about 10 minutes. Remove the noodles to a plate.\n Watch Now',
'Place the chopped pork belly into a skillet over medium heat, add the garlic, garlic powder, oregano, salt, and black pepper to the skillet. Cook the meat, chopping it into small chunks as it cooks, until no longer pink, about 10 minutes. Drain excess grease.\n Watch Now',
'In a bowl, mix the cottage cheese, eggs, and Parmesan cheese until thoroughly combined.\n Watch Now',
'Place 4 noodles side by side into the bottom of a 9x13-inch baking pan; top with a layer of the tomato-basil sauce, a layer of ground beef mixture, and a layer of the cottage cheese mixture. Repeat layers twice more, ending with a layer of sauce; sprinkle top with the mozzarella cheese. Cover the dish with aluminum foil.\n Watch Now',
'Bake in the preheated oven until the casserole is bubbling and the cheese has melted, about 30 minutes. Remove foil and bake until cheese has begun to brown, about 10 more minutes. Allow to stand at least 10 minutes before serving.\n Watch Now'],
'nutrition': [{'name': 'Total Fat',
'amount': '19.3',
'unit': 'g',
'daily_value': '30 %'},
{'name': 'Saturated Fat', 'amount': '9.0', 'unit': 'g', 'daily_value': None},
{'name': 'Cholesterol',
'amount': '115',
'unit': 'mg',
'daily_value': '38 %'},
{'name': 'Sodium', 'amount': '999', 'unit': 'mg', 'daily_value': '40 %'},
{'name': 'Potassium', 'amount': '717', 'unit': 'mg', 'daily_value': '20 %'},
{'name': 'Total Carbohydrates',
'amount': '47.1',
'unit': 'g',
'daily_value': '15 %'},
{'name': 'Dietary Fiber',
'amount': '6.3',
'unit': 'g',
'daily_value': '25 %'},
{'name': 'Protein', 'amount': '35.6', 'unit': 'g', 'daily_value': '71 %'},
{'name': 'Sugars', 'amount': '12', 'unit': 'g', 'daily_value': None},
{'name': 'Vitamin A', 'amount': '855', 'unit': 'IU', 'daily_value': None},
{'name': 'Vitamin C', 'amount': '2', 'unit': 'mg', 'daily_value': None},
{'name': 'Calcium', 'amount': '361', 'unit': 'mg', 'daily_value': None},
{'name': 'Iron', 'amount': '4', 'unit': 'mg', 'daily_value': None},
{'name': 'Thiamin', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Niacin', 'amount': '11', 'unit': 'mg', 'daily_value': None},
{'name': 'Vitamin B6', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Magnesium', 'amount': '74', 'unit': 'mg', 'daily_value': None},
{'name': 'Folate', 'amount': '41', 'unit': 'mcg', 'daily_value': None}]
}
print("unhealthy recipe", json.dumps(testClass.to_healthy(old_unhealthy_recipe), indent=2))
'''
should:
- replace pork belly with tofu
- halve the sugar content
- leave salt ingredient unchanged with no error
- replace bread with gluten free bread
'''
old_healthy_recipe = { # just made this up
'ingredients': ['1 cup of brown rice',
'1 pound of turkey bacon',
'2 cloves garlic, chopped',
'1/2 teaspoon garlic powder',
'1 teaspoon dried oregano, or to taste',
'3 tablespoons of butter',
'salt to taste',
'1 (16 ounce) package cottage cheese',
'2 eggs',
'1/2 cup shredded Parmesan cheese',
'1 1/2 (25 ounce) jars tomato-basil pasta sauce'],
'directions': ['Preheat oven to 350 degrees F (175 degrees C).\n Watch Now',
'Fill a large pot with lightly salted water and bring to a rolling boil over high heat. Once the water is boiling, add the brown rice a cup at a time, and return to a boil. Cook the pasta uncovered, stirring occasionally, until the pasta has cooked through, but is still firm to the bite, about 10 minutes. Remove the noodles to a plate.\n Watch Now',
'Place the chopped turkey bacon into a skillet over medium heat, add the garlic, garlic powder, oregano, salt, and black pepper to the skillet. Cook the meat, chopping it into small chunks as it cooks, until no longer pink, about 10 minutes. Drain excess grease.\n Watch Now',
'In a bowl, mix the cottage cheese, eggs, and Parmesan cheese until thoroughly combined.\n Watch Now',
'Place 4 noodles side by side into the bottom of a 9x13-inch baking pan; top with a layer of the tomato-basil sauce, a layer of ground beef mixture, and a layer of the cottage cheese mixture. Repeat layers twice more, ending with a layer of sauce; sprinkle top with the mozzarella cheese. Cover the dish with aluminum foil.\n Watch Now',
'Bake in the preheated oven until the casserole is bubbling and the cheese has melted, about 30 minutes. Remove foil and bake until cheese has begun to brown, about 10 more minutes. Allow to stand at least 10 minutes before serving.\n Watch Now'],
'nutrition': [{'name': 'Total Fat',
'amount': '19.3',
'unit': 'g',
'daily_value': '30 %'},
{'name': 'Saturated Fat', 'amount': '9.0', 'unit': 'g', 'daily_value': None},
{'name': 'Cholesterol',
'amount': '115',
'unit': 'mg',
'daily_value': '38 %'},
{'name': 'Sodium', 'amount': '999', 'unit': 'mg', 'daily_value': '40 %'},
{'name': 'Potassium', 'amount': '717', 'unit': 'mg', 'daily_value': '20 %'},
{'name': 'Total Carbohydrates',
'amount': '47.1',
'unit': 'g',
'daily_value': '15 %'},
{'name': 'Dietary Fiber',
'amount': '6.3',
'unit': 'g',
'daily_value': '25 %'},
{'name': 'Protein', 'amount': '35.6', 'unit': 'g', 'daily_value': '71 %'},
{'name': 'Sugars', 'amount': '12', 'unit': 'g', 'daily_value': None},
{'name': 'Vitamin A', 'amount': '855', 'unit': 'IU', 'daily_value': None},
{'name': 'Vitamin C', 'amount': '2', 'unit': 'mg', 'daily_value': None},
{'name': 'Calcium', 'amount': '361', 'unit': 'mg', 'daily_value': None},
{'name': 'Iron', 'amount': '4', 'unit': 'mg', 'daily_value': None},
{'name': 'Thiamin', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Niacin', 'amount': '11', 'unit': 'mg', 'daily_value': None},
{'name': 'Vitamin B6', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Magnesium', 'amount': '74', 'unit': 'mg', 'daily_value': None},
{'name': 'Folate', 'amount': '41', 'unit': 'mcg', 'daily_value': None}]
}
print("healthy recipe", json.dumps(testClass.to_non_healthy(old_healthy_recipe), indent=2))
'''
should:
- replace brown rice with white rice
- double the butter content
- leave salt ingredient unchanged with no error
- replace cottage cheese with mozzarella
'''
old_non_chinese_recipe = { # just made this up
'ingredients': ['1 pack of fresh pappardelle',
'1 zucchini',
'2 cloves garlic, chopped',
'1/2 teaspoon garlic powder',
'1 teaspoon dried oregano, or to taste',
'3 tablespoons of butter',
'salt to taste',
'1 (16 ounce) package cottage cheese',
'2 eggs',
'1/2 cup shredded Parmesan cheese',
'1 1/2 (25 ounce) jars tomato-basil pasta sauce'],
'directions': ['Preheat oven to 350 degrees F (175 degrees C).\n Watch Now',
'Fill a large pot with lightly salted water and bring to a rolling boil over high heat. Once the water is boiling, add the pappardelle a cup at a time, and return to a boil. Cook the noodles uncovered, stirring occasionally, until the noodles have cooked through, but is still firm to the bite, about 10 minutes. Remove the noodles to a plate.\n Watch Now',
'Place the chopped zucchini into a skillet over medium heat, add the garlic, garlic powder, oregano, salt, and black pepper to the skillet. Cook the meat, chopping it into small chunks as it cooks, until no longer pink, about 10 minutes. Drain excess grease.\n Watch Now',
'In a bowl, mix the cottage cheese, eggs, and Parmesan cheese until thoroughly combined.\n Watch Now',
'Place 4 noodles side by side into the bottom of a 9x13-inch baking pan; top with a layer of the tomato-basil sauce, a layer of ground beef mixture, and a layer of the cottage cheese mixture. Repeat layers twice more, ending with a layer of sauce; sprinkle top with the mozzarella cheese. Cover the dish with aluminum foil.\n Watch Now',
'Bake in the preheated oven until the casserole is bubbling and the cheese has melted, about 30 minutes. Remove foil and bake until cheese has begun to brown, about 10 more minutes. Allow to stand at least 10 minutes before serving.\n Watch Now'],
'nutrition': [{'name': 'Total Fat',
'amount': '19.3',
'unit': 'g',
'daily_value': '30 %'},
{'name': 'Saturated Fat', 'amount': '9.0', 'unit': 'g', 'daily_value': None},
{'name': 'Cholesterol',
'amount': '115',
'unit': 'mg',
'daily_value': '38 %'},
{'name': 'Sodium', 'amount': '999', 'unit': 'mg', 'daily_value': '40 %'},
{'name': 'Potassium', 'amount': '717', 'unit': 'mg', 'daily_value': '20 %'},
{'name': 'Total Carbohydrates',
'amount': '47.1',
'unit': 'g',
'daily_value': '15 %'},
{'name': 'Dietary Fiber',
'amount': '6.3',
'unit': 'g',
'daily_value': '25 %'},
{'name': 'Protein', 'amount': '35.6', 'unit': 'g', 'daily_value': '71 %'},
{'name': 'Sugars', 'amount': '12', 'unit': 'g', 'daily_value': None},
{'name': 'Vitamin A', 'amount': '855', 'unit': 'IU', 'daily_value': None},
{'name': 'Vitamin C', 'amount': '2', 'unit': 'mg', 'daily_value': None},
{'name': 'Calcium', 'amount': '361', 'unit': 'mg', 'daily_value': None},
{'name': 'Iron', 'amount': '4', 'unit': 'mg', 'daily_value': None},
{'name': 'Thiamin', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Niacin', 'amount': '11', 'unit': 'mg', 'daily_value': None},
{'name': 'Vitamin B6', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Magnesium', 'amount': '74', 'unit': 'mg', 'daily_value': None},
{'name': 'Folate', 'amount': '41', 'unit': 'mcg', 'daily_value': None}]
}
print("chinese recipe", json.dumps(testClass.to_chinese_cuisine(old_non_chinese_recipe), indent=2))
'''
should:
- replace pappardelle with an asian noodle
- replace butter with another asian condiment
- replace oregano,basil with an asian spice
- replace cottage cheese with an asian cheese-like
'''
old_non_gluten_free_recipe = { # just made this up
'ingredients': ['1 pack of fresh pappardelle',
'1 zucchini',
'2 cloves garlic, chopped',
'1/2 teaspoon garlic powder',
'1 teaspoon dried oregano, or to taste',
'3 tablespoons of butter',
'salt to taste',
'1 (16 ounce) package cottage cheese',
'2 eggs',
'1/2 cup shredded Parmesan cheese',
'1 1/2 (25 ounce) jars tomato-basil pasta sauce'],
'directions': ['Preheat oven to 350 degrees F (175 degrees C).\n Watch Now',
'Fill a large pot with lightly salted water and bring to a rolling boil over high heat. Once the water is boiling, add the pappardelle a cup at a time, and return to a boil. Cook the noodles uncovered, stirring occasionally, until the noodles have cooked through, but is still firm to the bite, about 10 minutes. Remove the noodles to a plate.\n Watch Now',
'Place the chopped zucchini into a skillet over medium heat, add the garlic, garlic powder, oregano, salt, and black pepper to the skillet. Cook the meat, chopping it into small chunks as it cooks, until no longer pink, about 10 minutes. Drain excess grease.\n Watch Now',
'In a bowl, mix the cottage cheese, eggs, and Parmesan cheese until thoroughly combined.\n Watch Now',
'Place 4 noodles side by side into the bottom of a 9x13-inch baking pan; top with a layer of the tomato-basil sauce, a layer of ground beef mixture, and a layer of the cottage cheese mixture. Repeat layers twice more, ending with a layer of sauce; sprinkle top with the mozzarella cheese. Cover the dish with aluminum foil.\n Watch Now',
'Bake in the preheated oven until the casserole is bubbling and the cheese has melted, about 30 minutes. Remove foil and bake until cheese has begun to brown, about 10 more minutes. Allow to stand at least 10 minutes before serving.\n Watch Now'],
'nutrition': [{'name': 'Total Fat',
'amount': '19.3',
'unit': 'g',
'daily_value': '30 %'},
{'name': 'Saturated Fat', 'amount': '9.0', 'unit': 'g', 'daily_value': None},
{'name': 'Cholesterol',
'amount': '115',
'unit': 'mg',
'daily_value': '38 %'},
{'name': 'Sodium', 'amount': '999', 'unit': 'mg', 'daily_value': '40 %'},
{'name': 'Potassium', 'amount': '717', 'unit': 'mg', 'daily_value': '20 %'},
{'name': 'Total Carbohydrates',
'amount': '47.1',
'unit': 'g',
'daily_value': '15 %'},
{'name': 'Dietary Fiber',
'amount': '6.3',
'unit': 'g',
'daily_value': '25 %'},
{'name': 'Protein', 'amount': '35.6', 'unit': 'g', 'daily_value': '71 %'},
{'name': 'Sugars', 'amount': '12', 'unit': 'g', 'daily_value': None},
{'name': 'Vitamin A', 'amount': '855', 'unit': 'IU', 'daily_value': None},
{'name': 'Vitamin C', 'amount': '2', 'unit': 'mg', 'daily_value': None},
{'name': 'Calcium', 'amount': '361', 'unit': 'mg', 'daily_value': None},
{'name': 'Iron', 'amount': '4', 'unit': 'mg', 'daily_value': None},
{'name': 'Thiamin', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Niacin', 'amount': '11', 'unit': 'mg', 'daily_value': None},
{'name': 'Vitamin B6', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Magnesium', 'amount': '74', 'unit': 'mg', 'daily_value': None},
{'name': 'Folate', 'amount': '41', 'unit': 'mcg', 'daily_value': None}]
}
print(json.dumps(testClass.to_gluten_free(old_recipe), indent=2))
old_non_gluten_free_recipe = { # just made this up
'ingredients': ['1 pack of fresh pappardelle',
'1 zucchini',
'2 cloves garlic, chopped',
'1/2 teaspoon garlic powder',
'1 teaspoon dried oregano, or to taste',
'3 tablespoons of butter',
'salt to taste',
'1 (16 ounce) package cottage cheese',
'2 eggs',
'1/2 cup shredded Parmesan cheese',
'1 1/2 (25 ounce) jars tomato-basil pasta sauce'],
'directions': ['Preheat oven to 350 degrees F (175 degrees C).\n Watch Now',
'Fill a large pot with lightly salted water and bring to a rolling boil over high heat. Once the water is boiling, add the pappardelle a cup at a time, and return to a boil. Cook the noodles uncovered, stirring occasionally, until the noodles have cooked through, but is still firm to the bite, about 10 minutes. Remove the noodles to a plate.\n Watch Now',
'Place the chopped zucchini into a skillet over medium heat, add the garlic, garlic powder, oregano, salt, and black pepper to the skillet. Cook the meat, chopping it into small chunks as it cooks, until no longer pink, about 10 minutes. Drain excess grease.\n Watch Now',
'In a bowl, mix the cottage cheese, eggs, and Parmesan cheese until thoroughly combined.\n Watch Now',
'Place 4 noodles side by side into the bottom of a 9x13-inch baking pan; top with a layer of the tomato-basil sauce, a layer of ground beef mixture, and a layer of the cottage cheese mixture. Repeat layers twice more, ending with a layer of sauce; sprinkle top with the mozzarella cheese. Cover the dish with aluminum foil.\n Watch Now',
'Bake in the preheated oven until the casserole is bubbling and the cheese has melted, about 30 minutes. Remove foil and bake until cheese has begun to brown, about 10 more minutes. Allow to stand at least 10 minutes before serving.\n Watch Now'],
'nutrition': [{'name': 'Total Fat',
'amount': '19.3',
'unit': 'g',
'daily_value': '30 %'},
{'name': 'Saturated Fat', 'amount': '9.0', 'unit': 'g', 'daily_value': None},
{'name': 'Cholesterol',
'amount': '115',
'unit': 'mg',
'daily_value': '38 %'},
{'name': 'Sodium', 'amount': '999', 'unit': 'mg', 'daily_value': '40 %'},
{'name': 'Potassium', 'amount': '717', 'unit': 'mg', 'daily_value': '20 %'},
{'name': 'Total Carbohydrates',
'amount': '47.1',
'unit': 'g',
'daily_value': '15 %'},
{'name': 'Dietary Fiber',
'amount': '6.3',
'unit': 'g',
'daily_value': '25 %'},
{'name': 'Protein', 'amount': '35.6', 'unit': 'g', 'daily_value': '71 %'},
{'name': 'Sugars', 'amount': '12', 'unit': 'g', 'daily_value': None},
{'name': 'Vitamin A', 'amount': '855', 'unit': 'IU', 'daily_value': None},
{'name': 'Vitamin C', 'amount': '2', 'unit': 'mg', 'daily_value': None},
{'name': 'Calcium', 'amount': '361', 'unit': 'mg', 'daily_value': None},
{'name': 'Iron', 'amount': '4', 'unit': 'mg', 'daily_value': None},
{'name': 'Thiamin', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Niacin', 'amount': '11', 'unit': 'mg', 'daily_value': None},
{'name': 'Vitamin B6', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Magnesium', 'amount': '74', 'unit': 'mg', 'daily_value': None},
{'name': 'Folate', 'amount': '41', 'unit': 'mcg', 'daily_value': None}]
}
print(json.dumps(testClass.to_non_gluten_free(old_recipe), indent=2))
old_non_thai_recipe = { # just made this up
'ingredients': ['1 pack of fresh pappardelle',
'1 zucchini',
'2 cloves garlic, chopped',
'1/2 teaspoon garlic powder',
'1 teaspoon dried oregano, or to taste',
'3 tablespoons of butter',
'salt to taste',
'1 (16 ounce) package cottage cheese',
'2 eggs',
'1/2 cup shredded Parmesan cheese',
'1 1/2 (25 ounce) jars tomato-basil pasta sauce'],
'directions': ['Preheat oven to 350 degrees F (175 degrees C).\n Watch Now',
'Fill a large pot with lightly salted water and bring to a rolling boil over high heat. Once the water is boiling, add the pappardelle a cup at a time, and return to a boil. Cook the noodles uncovered, stirring occasionally, until the noodles have cooked through, but is still firm to the bite, about 10 minutes. Remove the noodles to a plate.\n Watch Now',
'Place the chopped zucchini into a skillet over medium heat, add the garlic, garlic powder, oregano, salt, and black pepper to the skillet. Cook the meat, chopping it into small chunks as it cooks, until no longer pink, about 10 minutes. Drain excess grease.\n Watch Now',
'In a bowl, mix the cottage cheese, eggs, and Parmesan cheese until thoroughly combined.\n Watch Now',
'Place 4 noodles side by side into the bottom of a 9x13-inch baking pan; top with a layer of the tomato-basil sauce, a layer of ground beef mixture, and a layer of the cottage cheese mixture. Repeat layers twice more, ending with a layer of sauce; sprinkle top with the mozzarella cheese. Cover the dish with aluminum foil.\n Watch Now',
'Bake in the preheated oven until the casserole is bubbling and the cheese has melted, about 30 minutes. Remove foil and bake until cheese has begun to brown, about 10 more minutes. Allow to stand at least 10 minutes before serving.\n Watch Now'],
'nutrition': [{'name': 'Total Fat',
'amount': '19.3',
'unit': 'g',
'daily_value': '30 %'},
{'name': 'Saturated Fat', 'amount': '9.0', 'unit': 'g', 'daily_value': None},
{'name': 'Cholesterol',
'amount': '115',
'unit': 'mg',
'daily_value': '38 %'},
{'name': 'Sodium', 'amount': '999', 'unit': 'mg', 'daily_value': '40 %'},
{'name': 'Potassium', 'amount': '717', 'unit': 'mg', 'daily_value': '20 %'},
{'name': 'Total Carbohydrates',
'amount': '47.1',
'unit': 'g',
'daily_value': '15 %'},
{'name': 'Dietary Fiber',
'amount': '6.3',
'unit': 'g',
'daily_value': '25 %'},
{'name': 'Protein', 'amount': '35.6', 'unit': 'g', 'daily_value': '71 %'},
{'name': 'Sugars', 'amount': '12', 'unit': 'g', 'daily_value': None},
{'name': 'Vitamin A', 'amount': '855', 'unit': 'IU', 'daily_value': None},
{'name': 'Vitamin C', 'amount': '2', 'unit': 'mg', 'daily_value': None},
{'name': 'Calcium', 'amount': '361', 'unit': 'mg', 'daily_value': None},
{'name': 'Iron', 'amount': '4', 'unit': 'mg', 'daily_value': None},
{'name': 'Thiamin', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Niacin', 'amount': '11', 'unit': 'mg', 'daily_value': None},
{'name': 'Vitamin B6', 'amount': '0', 'unit': 'mg', 'daily_value': None},
{'name': 'Magnesium', 'amount': '74', 'unit': 'mg', 'daily_value': None},
{'name': 'Folate', 'amount': '41', 'unit': 'mcg', 'daily_value': None}]
}
print(json.dumps(testClass.to_thai_cuisine(old_recipe), indent=2))