From 9e50ce0b5c00ea317e2cb67801b3ef64ca8f921d Mon Sep 17 00:00:00 2001 From: Steven Griffin <anaxaganous@gmail.com> Date: Wed, 27 Nov 2024 09:47:28 -0500 Subject: [PATCH] Added new string variants for a variety of units with tests. --- ingreedypy.py | 69 +++++- ingreedytest.py | 592 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 660 insertions(+), 1 deletion(-) diff --git a/ingreedypy.py b/ingreedypy.py index 1e4ca04..8d1e98c 100644 --- a/ingreedypy.py +++ b/ingreedypy.py @@ -190,7 +190,10 @@ class Ingreedy(NodeVisitor): cup = "cups" + / "cup(s)" / "cup" + / "C." + / "C" / "c." / "c" @@ -203,7 +206,10 @@ class Ingreedy(NodeVisitor): / "fl" gallon - = "gallons" + = "gallons." + / "gallons" + / "gallon(s)" + / "gallon." / "gallon" / "gal." / "gal" @@ -219,26 +225,35 @@ class Ingreedy(NodeVisitor): ounce = "ounces" + / "ounce(s)" + / "ounce." / "ounce" / "oz." / "oz" pint = "pints" + / "pint(s)" + / "pint." / "pint" / "pt." / "pt" pound = "pounds" + / "pound(s)" + / "pound." / "pound" / "lbs." / "lbs" / "lb." / "lb" + / "#" quart = "quarts" + / "quart(s)" + / "quart." / "quart" / "qts." / "qts" @@ -247,9 +262,19 @@ class Ingreedy(NodeVisitor): tablespoon = "tablespoons" + / "tablespoon(s)" + / "tablespoon." / "tablespoon" + / "tbspns." + / "tbspns" + / "Tbsp." + / "Tbsp" / "tbsp." / "tbsp" + / "TBS." + / "TBS" + / "Tbs." + / "Tbs" / "tbs." / "tbs" / "T." @@ -257,7 +282,12 @@ class Ingreedy(NodeVisitor): teaspoon = "teaspoons" + / "teaspoon(s)" / "teaspoon" + / "teasps." + / "teasps" + / "teasp." + / "teasp" / "tsp." / "tsp" / "t." @@ -274,44 +304,63 @@ class Ingreedy(NodeVisitor): gram = "grams" + / "gram(s)" / "gram" / "gr." / "gr" + / "G." + / "G" / "g." / "g" joule = "joules" + / "joule(s)" / "joule" / "j" kilogram = "kilograms" + / "kilogram(s)" / "kilogram" + / "KG." + / "KG" + / "Kg." + / "Kg" / "kg." / "kg" kilojoule = "kilojoules" + / "kilojoule(s)" / "kilojoule" / "kJ" / "kj" liter = "liters" + / "liter(s)" / "liter" + / "L." + / "L" / "l." / "l" milligram = "milligrams" + / "milligram(s)" / "milligram" + / "mgs." + / "mgs" / "mg." / "mg" milliliter = "milliliters" + / "milliliter(s)" / "milliliter" + / "mls." + / "mls" / "ml." / "ml" @@ -320,6 +369,13 @@ class Ingreedy(NodeVisitor): / handful / pinch / touch + / stick + / punnet + / head + + head + = "heads" + / "head" abbreviated_unit = letter letter letter? @@ -340,6 +396,17 @@ class Ingreedy(NodeVisitor): = "touches" / "touch" + stick + = "sticks" + / "stick(s)" + / "stick" + + punnet + = "punnetts" + / "punnett" + / "punnets" + / "punnet" + number = written_number break written_number diff --git a/ingreedytest.py b/ingreedytest.py index f8f137f..5288fa9 100644 --- a/ingreedytest.py +++ b/ingreedytest.py @@ -46,6 +46,30 @@ }], 'ingredient': 'flour', }, + '1 2/3 cup(s) flour': { + 'quantity': [{ + 'amount': round(float(5.0/3), 3), + 'unit': 'cup', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '1 2/3 C flour': { + 'quantity': [{ + 'amount': round(float(5.0/3), 3), + 'unit': 'cup', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '1 2/3 C. flour': { + 'quantity': [{ + 'amount': round(float(5.0/3), 3), + 'unit': 'cup', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, '12 (6-ounce) boneless skinless chicken breasts': { 'quantity': [{ 'amount': 72, @@ -78,6 +102,38 @@ }], 'ingredient': 'potatoes', }, + '12 gram(s) potatoes': { + 'quantity': [{ + 'amount': 12, + 'unit': 'gram', + 'unit_type': 'metric', + }], + 'ingredient': 'potatoes', + }, + '12gram(s) potatoes': { + 'quantity': [{ + 'amount': 12, + 'unit': 'gram', + 'unit_type': 'metric', + }], + 'ingredient': 'potatoes', + }, + '12G. potatoes': { + 'quantity': [{ + 'amount': 12, + 'unit': 'gram', + 'unit_type': 'metric', + }], + 'ingredient': 'potatoes', + }, + '12G potatoes': { + 'quantity': [{ + 'amount': 12, + 'unit': 'gram', + 'unit_type': 'metric', + }], + 'ingredient': 'potatoes', + }, '12oz potatoes': { 'quantity': [{ 'amount': 12, @@ -134,6 +190,198 @@ }], 'ingredient': 'flour', }, + '6 tablespoons flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 tablespoon(s) flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 tablespoons flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 tbspns. flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 tbspns flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 Tbsp. flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 Tbsp flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 tbsp. flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 tbsp flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 TBS. flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 TBS flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 Tbs. flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 Tbs flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'tablespoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 teaspoons flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'teaspoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 teaspoon(s) flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'teaspoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 teaspoon flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'teaspoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 teasps. flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'teaspoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 teasps flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'teaspoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 teasp. flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'teaspoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 teasp flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'teaspoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 tsp. flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'teaspoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 tsp flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'teaspoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 t. flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'teaspoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, + '6 t flour': { + 'quantity': [{ + 'amount': 6, + 'unit': 'teaspoon', + 'unit_type': 'english', + }], + 'ingredient': 'flour', + }, '1 garlic clove, sliced in 1/2': { 'quantity': [{ 'amount': 1, @@ -266,6 +514,46 @@ }], 'ingredient': 'potatoes', }, + '1 kilogram(s) / 2lb 4oz potatoes': { + 'quantity': [{ + 'amount': 1, + 'unit': 'kilogram', + 'unit_type': 'metric', + }], + 'ingredient': 'potatoes', + }, + '1KG. / 2lb 4oz potatoes': { + 'quantity': [{ + 'amount': 1, + 'unit': 'kilogram', + 'unit_type': 'metric', + }], + 'ingredient': 'potatoes', + }, + '1KG / 2lb 4oz potatoes': { + 'quantity': [{ + 'amount': 1, + 'unit': 'kilogram', + 'unit_type': 'metric', + }], + 'ingredient': 'potatoes', + }, + '1Kg. / 2lb 4oz potatoes': { + 'quantity': [{ + 'amount': 1, + 'unit': 'kilogram', + 'unit_type': 'metric', + }], + 'ingredient': 'potatoes', + }, + '1Kg / 2lb 4oz potatoes': { + 'quantity': [{ + 'amount': 1, + 'unit': 'kilogram', + 'unit_type': 'metric', + }], + 'ingredient': 'potatoes', + }, '2lb 4oz potatoes': { 'quantity': [{ 'amount': 2, @@ -278,6 +566,30 @@ }], 'ingredient': 'potatoes', }, + '2 pound(s) potatoes': { + 'quantity': [{ + 'amount': 2, + 'unit': 'pound', + 'unit_type': 'english', + }], + 'ingredient': 'potatoes', + }, + '2 # potatoes': { + 'quantity': [{ + 'amount': 2, + 'unit': 'pound', + 'unit_type': 'english', + }], + 'ingredient': 'potatoes', + }, + '2 pound. potatoes': { + 'quantity': [{ + 'amount': 2, + 'unit': 'pound', + 'unit_type': 'english', + }], + 'ingredient': 'potatoes', + }, '2lb 4oz (1kg) potatoes': { 'quantity': [{ 'amount': 2, @@ -298,6 +610,22 @@ }], 'ingredient': 'vanilla ice cream', }, + '1-1/2 ounce(s) vanilla ice cream': { + 'quantity': [{ + 'amount': 1.5, + 'unit': 'ounce', + 'unit_type': 'english', + }], + 'ingredient': 'vanilla ice cream', + }, + '1-1/2 ounce. vanilla ice cream': { + 'quantity': [{ + 'amount': 1.5, + 'unit': 'ounce', + 'unit_type': 'english', + }], + 'ingredient': 'vanilla ice cream', + }, '1-½ ounce vanilla ice cream': { 'quantity': [{ 'amount': 1.5, @@ -334,6 +662,118 @@ }], 'ingredient': 'hot vegetable stock', }, + '750 milliliters/1 pint 7fl oz hot vegetable stock': { + 'quantity': [{ + 'amount': 750, + 'unit': 'milliliter', + 'unit_type': 'metric', + }], + 'ingredient': 'hot vegetable stock', + }, + '750 milliliter(s)/1 pint 7fl oz hot vegetable stock': { + 'quantity': [{ + 'amount': 750, + 'unit': 'milliliter', + 'unit_type': 'metric', + }], + 'ingredient': 'hot vegetable stock', + }, + '750mls./1 pint 7fl oz hot vegetable stock': { + 'quantity': [{ + 'amount': 750, + 'unit': 'milliliter', + 'unit_type': 'metric', + }], + 'ingredient': 'hot vegetable stock', + }, + '750mls/1 pint 7fl oz hot vegetable stock': { + 'quantity': [{ + 'amount': 750, + 'unit': 'milliliter', + 'unit_type': 'metric', + }], + 'ingredient': 'hot vegetable stock', + }, + '3 liters hot vegetable stock': { + 'quantity': [{ + 'amount': 3, + 'unit': 'liter', + 'unit_type': 'metric', + }], + 'ingredient': 'hot vegetable stock', + }, + '3 liter(s) hot vegetable stock': { + 'quantity': [{ + 'amount': 3, + 'unit': 'liter', + 'unit_type': 'metric', + }], + 'ingredient': 'hot vegetable stock', + }, + '3 L. hot vegetable stock': { + 'quantity': [{ + 'amount': 3, + 'unit': 'liter', + 'unit_type': 'metric', + }], + 'ingredient': 'hot vegetable stock', + }, + '3 L hot vegetable stock': { + 'quantity': [{ + 'amount': 3, + 'unit': 'liter', + 'unit_type': 'metric', + }], + 'ingredient': 'hot vegetable stock', + }, + '3 pint hot vegetable stock': { + 'quantity': [{ + 'amount': 3, + 'unit': 'pint', + 'unit_type': 'english', + }], + 'ingredient': 'hot vegetable stock', + }, + '3 pint(s) hot vegetable stock': { + 'quantity': [{ + 'amount': 3, + 'unit': 'pint', + 'unit_type': 'english', + }], + 'ingredient': 'hot vegetable stock', + }, + '3 pint. hot vegetable stock': { + 'quantity': [{ + 'amount': 3, + 'unit': 'pint', + 'unit_type': 'english', + }], + 'ingredient': 'hot vegetable stock', + }, + '3 quarts hot vegetable stock': { + 'quantity': [{ + 'amount': 3, + 'unit': 'quart', + 'unit_type': 'english', + }], + 'ingredient': 'hot vegetable stock', + }, + '3 quart(s) hot vegetable stock': { + 'quantity': [{ + 'amount': 3, + 'unit': 'quart', + 'unit_type': 'english', + }], + 'ingredient': 'hot vegetable stock', + }, + '3 quart. hot vegetable stock': { + 'quantity': [{ + 'amount': 3, + 'unit': 'quart', + 'unit_type': 'english', + }], + 'ingredient': 'hot vegetable stock', + }, 'pinch salt': { 'quantity': [{ 'amount': 1, @@ -342,6 +782,78 @@ }], 'ingredient': 'salt', }, + 'stick cinnamon': { + 'quantity': [{ + 'amount': 1, + 'unit': 'stick', + 'unit_type': 'imprecise', + }], + 'ingredient': 'cinnamon', + }, + '3 sticks cinnamon': { + 'quantity': [{ + 'amount': 3, + 'unit': 'stick', + 'unit_type': 'imprecise', + }], + 'ingredient': 'cinnamon', + }, + 'head lettuce': { + 'quantity': [{ + 'amount': 1, + 'unit': 'head', + 'unit_type': 'imprecise', + }], + 'ingredient': 'lettuce', + }, + '4 heads lettuce': { + 'quantity': [{ + 'amount': 4, + 'unit': 'head', + 'unit_type': 'imprecise', + }], + 'ingredient': 'lettuce', + }, + 'punnet raspberries': { + 'quantity': [{ + 'amount': 1, + 'unit': 'punnet', + 'unit_type': 'imprecise', + }], + 'ingredient': 'raspberries', + }, + '2 punnets raspberries': { + 'quantity': [{ + 'amount': 2, + 'unit': 'punnet', + 'unit_type': 'imprecise', + }], + 'ingredient': 'raspberries', + }, + '3 punnetts raspberries': { + 'quantity': [{ + 'amount': 3, + 'unit': 'punnet', + 'unit_type': 'imprecise', + }], + 'ingredient': 'raspberries', + }, + '4 punnett raspberries': { + 'quantity': [{ + 'amount': 4, + 'unit': 'punnet', + 'unit_type': 'imprecise', + }], + 'ingredient': 'raspberries', + }, + '4 heads lettuce': { + 'quantity': [{ + 'amount': 4, + 'unit': 'head', + 'unit_type': 'imprecise', + }], + 'ingredient': 'lettuce', + }, '4 (16 ounce) t-bone steaks, at room temperature': { 'quantity': [{ 'amount': 64, @@ -358,6 +870,38 @@ }], 'ingredient': None, }, + '5 milligrams': { + 'quantity': [{ + 'amount': 5, + 'unit': 'milligram', + 'unit_type': 'metric', + }], + 'ingredient': None, + }, + '5 milligram(s)': { + 'quantity': [{ + 'amount': 5, + 'unit': 'milligram', + 'unit_type': 'metric', + }], + 'ingredient': None, + }, + '5 mgs.': { + 'quantity': [{ + 'amount': 5, + 'unit': 'milligram', + 'unit_type': 'metric', + }], + 'ingredient': None, + }, + '5 mgs': { + 'quantity': [{ + 'amount': 5, + 'unit': 'milligram', + 'unit_type': 'metric', + }], + 'ingredient': None, + }, '30 cal': { 'quantity': [{ 'amount': 30, @@ -382,6 +926,14 @@ }], 'ingredient': None, }, + '50 joule(s)': { + 'quantity': [{ + 'amount': 50, + 'unit': 'joule', + 'unit_type': 'metric', + }], + 'ingredient': None, + }, '1 kJ': { 'quantity': [{ 'amount': 1, @@ -390,6 +942,14 @@ }], 'ingredient': None, }, + '3 kilojoule(s)': { + 'quantity': [{ + 'amount': 3, + 'unit': 'kilojoule', + 'unit_type': 'metric', + }], + 'ingredient': None, + }, '20 gallons.': { 'quantity': [{ 'amount': 20, @@ -398,6 +958,38 @@ }], 'ingredient': None, }, + '20 gallons. bananas': { + 'quantity': [{ + 'amount': 20, + 'unit': 'gallon', + 'unit_type': 'english', + }], + 'ingredient': 'bananas', + }, + '20 gallon bananas': { + 'quantity': [{ + 'amount': 20, + 'unit': 'gallon', + 'unit_type': 'english', + }], + 'ingredient': 'bananas', + }, + '20 gallon. bananas': { + 'quantity': [{ + 'amount': 20, + 'unit': 'gallon', + 'unit_type': 'english', + }], + 'ingredient': 'bananas', + }, + '20 gallon(s) bananas': { + 'quantity': [{ + 'amount': 20, + 'unit': 'gallon', + 'unit_type': 'english', + }], + 'ingredient': 'bananas', + }, '6 (thinly sliced) bananas': { 'quantity': [{ 'amount': 6,