Package: text2struct
text2structCurrently it is using OpenAI provider to do the extraction, so you need
to register and retrieve an API KEY from their website athttps://beta.openai.com/account/api-keysInstallpipinstalltext2structand optinally set environmental variableOPENAI_API_KEYHow to userecipie="""STEP 1Put a large saucepan of water on to boil.STEP 2Finely chop the 100g pancetta, having first removed any rind. Finely grate 50g pecorino cheese and 50g parmesan and mix them together.STEP 3Beat the 3 large eggs in a medium bowl and season with a little freshly grated black pepper. Set everything aside.STEP 4Add 1 tsp salt to the boiling water, add 350g spaghetti and when the water comes back to the boil, cook at a constant simmer, covered, for 10 minutes or until al dente (just cooked).STEP 5Squash 2 peeled plump garlic cloves with the blade of a knife, just to bruise it.STEP 6While the spaghetti is cooking, fry the pancetta with the garlic. Drop 50g unsalted butter into a large frying pan or wok and, as soon as the butter has melted, tip in the pancetta and garlic.STEP 7Leave to cook on a medium heat for about 5 minutes, stirring often, until the pancetta is golden and crisp. The garlic has now imparted its flavour, so take it out with a slotted spoon and discard.STEP 8Keep the heat under the pancetta on low. When the pasta is ready, lift it from the water with a pasta fork or tongs and put it in the frying pan with the pancetta. Don’t worry if a little water drops in the pan as well (you want this to happen) and don’t throw the pasta water away yet.STEP 9Mix most of the cheese in with the eggs, keeping a small handful back for sprinkling over later.STEP 10Take the pan of spaghetti and pancetta off the heat. Now quickly pour in the eggs and cheese. Using the tongs or a long fork, lift up the spaghetti so it mixes easily with the egg mixture, which thickens but doesn’t scramble, and everything is coated.STEP 11Add extra pasta cooking water to keep it saucy (several tablespoons should do it). You don’t want it wet, just moist. Season with a little salt, if needed.STEP 12Use a long-pronged fork to twist the pasta on to the serving plate or bowl. Serve immediately with a little sprinkling of the remaining cheese and a grating of black pepper. If the dish does get a little dry before serving, splash in some more hot pasta water and the glossy sauciness will be revived."""what_to_retrieve=['ingredient','quantity']you can retrieve either dictionary with valuesd=text2dict(recipie,what_to_retrieve,config={'openai_api_key':'your_api_key'})d[{'ingredient': 'pancetta', 'quantity': '100g'},
 {'ingredient': 'pecorino cheese', 'quantity': '50g'},
 {'ingredient': 'parmesan', 'quantity': '50g'},
 {'ingredient': 'eggs', 'quantity': '3'},
 {'ingredient': 'black pepper', 'quantity': 'to taste'},
 {'ingredient': 'spaghetti', 'quantity': '350g'},
 {'ingredient': 'garlic cloves', 'quantity': '2'},
 {'ingredient': 'unsalted butter', 'quantity': '50g'},
 {'ingredient': 'salt', 'quantity': 'to taste'}]… or a data framedf=text2df(recipie,what_to_retrieve,config={'openai_api_key':'your_api_key'})df<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>ingredientquantity0pancetta100g1pecorino cheese50g2parmesan50g3eggs34black pepperto taste5spaghetti350g6garlic cloves27unsalted butter50g8saltto taste