4 ms·
I wrote an ingredient parser a few years ago (for a project I never finished/released); it mostly works. The way this works is by having a static list of units
by Beltalowda 5y ago
I wrote an ingredient parser a few years ago (for a project I never finished/released); it mostly works.
The way this works is by having a static list of units ("cup", "liter", "gram", "large", etc.) and ingredients ("egg", "eggs", "courgette", etc.) and a bit of logic to combine the two and extract reasonable things from a piece of text. From what I remember it assumes the ingredient name is last, and then tries to find a unit or quantity before this (which can just be "a", or "a large", "150 gram", etc.), but it's been 4 years since I worked on this.
It works mostly well, but it's not perfect. Looking at the list of ingredients it contains things like "guinness or other stout" or "rice vermicelli noodles". Adverbs and descriptions like that are an issue; I think I extracted that list from that NYT recipe parser thing (which isn't perfect, as it's only in American English – it doesn't know about courgettes for example). I think there were some other issues as well, but I forgot. It's 128 lines of Go code, and this includes a bit of code to modify the text to mark things. It's not very complex, and I didn't spend that much time fine-tuning it. However, I agree that you probably don't need ML for this, and can probably get equal or better results without it.
I don't know exactly how well it works compared to other solutions; from what I remember I tried zestful a bit with their online demo, and it worked better than that, but I only ever tested it on some of my own recipes. I never got very good results with that NYT thing at all. It doesn't attempt to split out the quantity with the ingredient name.
The thing doesn't run at the moment so I can't compare it with the demos in here right now. I should probably finish this some day...