myceliatrix

myceliatrix / scrape-recipe.txt

Last active 3 months ago

Like 0

myceliatrix revised this gist 3 months ago · 5eaae30

2 files changed, 558 insertions

parse-recipe-ingredients.txt (file created)
@@ -0,0 +1,221 @@
1 + Parse each ingredient string into structured ingredient components.
2 +
3 + You will receive a list containing one or more ingredient strings.
4 +
5 + You must return exactly one parsed ingredient for every input ingredient, in the same order. Never merge, split, remove, reorder, or add ingredients.
6 +
7 + ## Core requirements
8 +
9 + * Preserve all meaningful information from the original ingredient string.
10 + * Every part of the input must either be represented in a structured field, included in the note field, or intentionally consumed by a documented normalization or conversion.
11 + * Do not invent missing quantities, units, foods, preparations, brands, or notes.
12 + * When part of an ingredient cannot be parsed confidently, preserve the uncertain text in the note field instead of discarding it.
13 + * If the entire ingredient is too ambiguous to parse reliably, place the complete original string in the note field and leave the other fields empty.
14 + * Return valid structured output only, with no explanations or commentary.
15 +
16 + ## Parsing rules
17 +
18 + Separate each ingredient into the available components, including:
19 +
20 + * quantity
21 + * unit
22 + * food or ingredient name
23 + * note or preparation text
24 +
25 + Examples:
26 +
27 + * `3 potatoes (roughly chopped)`
28 + quantity: `3`
29 + food: `potatoes`
30 + note: `roughly chopped`
31 +
32 + * `2 tbsp olive oil, plus more for frying`
33 + quantity: `2`
34 + unit: `tablespoon`
35 + food: `olive oil`
36 + note: `plus more for frying`
37 +
38 + * `1 large onion, finely diced`
39 + quantity: `1`
40 + food: `onion`
41 + note: `large; finely diced`
42 +
43 + ## Quantity rules
44 +
45 + * Parse integers, decimals, vulgar fractions, written fractions, and mixed numbers.
46 + * Normalize equivalent quantities where practical:
47 +
48 + * `½` → `0.5`
49 + * `1 1/2` → `1.5`
50 + * `one` → `1`
51 + * For quantity ranges, use the lower value:
52 +
53 + * `3–5` → `3`
54 + * `1 to 2` → `1`
55 + * `about 4–6` → `4`, with `about` preserved in the note when relevant
56 + * Preserve approximate wording such as `about`, `approximately`, `roughly`, or `around` in the note field.
57 + * Convert recognized grouped quantities when the conversion is unambiguous:
58 +
59 + * `2 dozen eggs` → quantity: `24`, food: `eggs`
60 + * Do not preserve the original grouped unit after it has been fully consumed by a conversion.
61 + * Do not calculate quantities that require assumptions about package size, ingredient density, or serving size.
62 +
63 + ## Unit rules
64 +
65 + Recognize common unit names, abbreviations, spelling variants, singular forms, plural forms, and multilingual variants.
66 +
67 + The parser may recognize many equivalent forms, but it must normalize the final output to the preferred forms below.
68 +
69 + ### Preferred output forms
70 +
71 + For metric units, always use these abbreviations in the final unit field:
72 +
73 + - `mg`
74 + - `g`
75 + - `kg`
76 + - `ml`
77 + - `l`
78 +
79 + For common kitchen units, use these abbreviations in the final unit field:
80 +
81 + - `tsp`
82 + - `tbsp`
83 +
84 + For other count-based or descriptive units, use a concise singular word:
85 +
86 + - `pinch`
87 + - `dash`
88 + - `sprig`
89 + - `clove`
90 + - `can`
91 + - `jar`
92 + - `bottle`
93 + - `package`
94 + - `packet`
95 + - `sachet`
96 + - `cube`
97 + - `bunch`
98 + - `bundle`
99 + - `slice`
100 + - `piece`
101 + - `stick`
102 + - `unit`
103 +
104 + Do not output long metric names such as:
105 +
106 + - `millilitre`
107 + - `millilitres`
108 + - `milliliter`
109 + - `gram`
110 + - `grams`
111 + - `kilogram`
112 + - `litre`
113 +
114 + Normalize them to their preferred abbreviations instead.
115 +
116 + Examples:
117 +
118 + - `200 millilitres whipping cream`
119 + quantity: `200`
120 + unit: `ml`
121 + food: `whipping cream`
122 +
123 + - `400 grams halloumi`
124 + quantity: `400`
125 + unit: `g`
126 + food: `halloumi`
127 +
128 + - `1 kilogram potatoes`
129 + quantity: `1`
130 + unit: `kg`
131 + food: `potatoes`
132 +
133 + - `2 tablespoons olive oil`
134 + quantity: `2`
135 + unit: `tbsp`
136 + food: `olive oil`
137 +
138 + - `1 teaspoon salt`
139 + quantity: `1`
140 + unit: `tsp`
141 + food: `salt`
142 +
143 + ### Recognition mappings
144 +
145 + Normalize common variants as follows:
146 +
147 + - `mg`, `milligram`, `milligrams` → `mg`
148 + - `g`, `gram`, `grams` → `g`
149 + - `kg`, `kilogram`, `kilograms` → `kg`
150 + - `ml`, `millilitre`, `millilitres`, `milliliter`, `milliliters` → `ml`
151 + - `l`, `litre`, `litres`, `liter`, `liters` → `l`
152 + - `tsp`, `teaspoon`, `teaspoons` → `tsp`
153 + - `tbsp`, `tbs`, `tablespoon`, `tablespoons` → `tbsp`
154 +
155 + Use lowercase abbreviations exactly as written above.
156 + Do not add periods to abbreviations.
157 + Do not pluralize abbreviated units.
158 + Do not include temperature units such as `°C` in ingredient unit fields unless the ingredient string itself genuinely represents a temperature value.
159 + Do not mistake ingredient names, package descriptions, or preparation words for units.
160 + If an unrecognized unit is present, preserve it only when it is clearly a unit. Otherwise place the uncertain text in the note field.
161 +
162 + ## Notes rules
163 +
164 + Place preparation instructions, condition, optionality, alternatives, and extra qualifiers in the note field.
165 +
166 + This includes text such as:
167 +
168 + * finely chopped
169 + * roughly chopped
170 + * divided
171 + * softened
172 + * melted
173 + * at room temperature
174 + * for serving
175 + * for garnish
176 + * plus extra
177 + * to taste
178 + * optional
179 + * drained
180 + * rinsed
181 + * peeled
182 + * seeded
183 + * crushed
184 +
185 + Text in parentheses should normally be placed in the note field unless it is clearly part of the ingredient name.
186 +
187 + Examples:
188 +
189 + * `400 g tomatoes (drained)` → note: `drained`
190 + * `1 can coconut milk (400 ml)` → keep `400 ml` in the note unless the schema has a dedicated package-size field
191 + * `1 tsp salt, or to taste` → note: `or to taste`
192 +
193 + Combine multiple note fragments clearly and without duplication.
194 +
195 + ## Multilingual rules
196 +
197 + * Respect the grammar, word order, inflection, singular and plural forms, and unit conventions of the source language.
198 + * Recognize grammatical variations and common abbreviations in multiple languages.
199 + * Do not force English grammar onto non-English ingredient strings.
200 + * Preserve the original language unless translation is explicitly requested.
201 + * Correct only clear typographical mistakes; do not rewrite wording merely because it is unfamiliar.
202 +
203 + ## Ambiguity and lossless handling
204 +
205 + * Prefer partial, lossless parsing over confident guessing.
206 + * If quantity is clear but unit is uncertain, preserve the uncertain unit text in notes.
207 + * If food is clear but preparation wording is ambiguous, keep the food and place the ambiguous remainder in notes.
208 + * If a token could reasonably belong to more than one field and context does not resolve it, preserve it in notes.
209 + * Never silently drop words, punctuation that carries meaning, package sizes, alternatives, or preparation details.
210 + * Never duplicate the same source text across multiple fields unless duplication is required by the output schema.
211 +
212 + ## Output integrity
213 +
214 + * Return the same number of ingredient objects as input strings.
215 + * Preserve the exact input order.
216 + * Do not combine repeated ingredients.
217 + * Do not split one ingredient string into multiple ingredient objects.
218 + * Do not add ingredients that are implied by instructions or recipe context.
219 + * Ensure every output object corresponds directly to exactly one input string.
220 + * Before returning the result, normalize every recognized unit to the exact preferred output form defined in the Unit rules.
221 + * The final unit field must not contain plural forms or long-form metric unit names when a preferred abbreviation exists.
scrape-recipe.txt (file created)

Diff is too large to be shown