Local Recipe Parser Broke on Units
I spent 9 evenings normalizing recipe units, then found half my tests were shopping notes.
I spent 9 evenings on a local recipe parser, mostly chasing units. Grams were fine, cups were annoying, and “1 jar” was where things started to fall apart. I thought the hard part would be parsing text; it turned out to be deciding what counts as an ingredient at all.
Half my test set was written like shopping notes: “one onion, small,” “enough soy sauce,” “a splash,” or “buy extra yogurt.” The parser would happily normalize them into nonsense, because it had no way to know whether “jar” meant a measured container or just a grocery-store shorthand.
I built a few ugly rules first: keep vague units as-is, convert only when there’s a known density, and refuse to guess on things like “a handful.” That reduced bad outputs, but it also meant a lot of recipes came out partially unparsed. The UI looked confident while the data was still shaky, which is a bad combo.
One mistake I made was assuming ingredient lines were the whole problem. Instructions were full of hidden quantities too: “cook until reduced by half,” “boil for 10 minutes,” “stir every few minutes.” I’m still not sure whether to extract those into structured steps or leave them as plain text.
What surprised me most was that unit conversion was the easy part once the text got messy. I’d redo the test set before touching more parsing rules, because right now I can’t tell whether the parser is bad or my examples are just bad notes from the grocery aisle.
8 replies
Did you normalize cups to grams with a lookup table or by ingredient density?
Lookup table first, density only for a few common ingredients. Anything vague like “a splash” stays untouched for now.
The better split is ingredient extraction first, unit normalization second. Otherwise your eval gets polluted fast.
I hit the same wall with cookbook scans. Shopping notes are basically a different genre.
If half your test set is shopping notes, are you measuring parser quality or note-taking chaos?
“1 jar” 我也栽过,最后发现罐头、瓶子、玻璃瓶其实要拆成容器和内容物两层。
你那个本地 parser 是先做规则,还是直接上模型补洞?
先全规则,模型只拿来标注可疑项。现在最烦的是“a pinch”这类词,基本没法统一。