Open kohaugustine opened 7 years ago
Hey @kohaugustine. The problem I have here is in switching things from regular lists to, well, anything else (except for OrderedDict; but does YAML support that?). I wrote a number of articles some years ago about writing recipes, which I believe discuss this, but the short version is: ingredients should be listed in the order in which they are to be used.
I realize that most non-professional cooks don't care, as is heavily evidenced by, well, almost every recipe site ever. But professionals care. Somebody working in a production kitchen/bakery will read a recipe all the way first, and then start collecting ingredients in the order in which they are listed, often adding them to the bowl/pot/etc in said order, as the instructions dictate.
These users will need ingredients to reliably be listed in exactly the same order as they are entered. Even in YAML supports ordered dictionaries, there is no guarantee that users will make use of them. I believe that forcing a list format will help here.
@kohaugustine please see #10 for links to the articles. These should explain a lot of the reasoning why I've tried to do things the way I have. I'll see if I can compile them into ORF documentation later.
Hi @techhat , following on our discussion in an earlier post #5 , I've given some more thought to the format and have experimented with different structures. I think I've arrived at one which might be worth considering. Here I thought I would just share some ideas using a concrete example of a recipe taken from this website.
An example YAML file that encodes this recipe, with some modifications from the original ORF:
Modifications and their rationale:
ingredients
key. The names themselves are going to contain information like amounts and notes; I've made sure to nest these under each respective ingredient name. In this way, I've made it possible to make a generator object of ingredient names, immediately after parsing the YAML file for the flavor formula, by just calling thekeys()
method on theingredients
dictionary that I index out of the main data structure. More concretely the code involved would simply be:In [10]: fn["ingredients"].keys() Out[10]: dict_keys(['DRIED MUSHROOMS', 'DRIED SHRIMPS', 'MUSTARD GREENS', 'SOYA SAUCE LIGHT', 'PORK BELLY', 'RICE', 'SESAME OIL', 'GINGER', 'GARLIC'])