Menu

Parsing "2-3 cloves garlic, minced" is harder than it looks
📰

Parsing "2-3 cloves garlic, minced" is harder than it looks

DEV Community: nlp·Dani·13 days ago
#FL9ep8EI
#devtonlp#devto#dev#ingredient#onion
Reading 0:00
15s threshold

{ "original" : "2 1/2 cups chopped yellow onion" , "quantity" : 2.5 , "quantity_max" : null , "unit" : "cup" , "unit_type" : "volume" , "size" : null , "ingredient" : "yellow onion" , "prep" : "chopped" , "notes" : [], "metric" : { "quantity" : 591.5 , "unit" : "ml" } }

Enter fullscreen mode

Exit fullscreen mode

And the tricky ones come out clean too:

Line quantity unit ingredient extra

1 (14.5 oz) can diced tomatoes 1 can tomatoes size: 14.5 oz, prep: diced

2-3 cloves garlic, minced 2 (max 3) clove garlic prep: minced

Salt to taste null null Salt notes: to taste

It handles fractions ( 1/2 , ½ , 1½ ), ranges ( 2-3 , 2 to 3 ),

US and metric units, size words like large , and notes like optional

or for garnish .

Quick example (Python)

import requests

resp = requests .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.