Parse recipe ingredients into structured data (name, quantity, units, preparation notes)
Project description
Ingredient Parser (Zestful Client)
Installation
From pip
pip install parse-ingredient
From source
git clone https://github.com/mtlynch/zestful-client.git
cd zestful-client
pip install .
Examples
Parse a single ingredient
import parse_ingredient
ingredient = parse_ingredient.parse('2 1/2 tablespoons finely chopped parsley')
print(json.dumps(ingredient.as_dict()))
{
"quantity": 2.5,
"unit": "tablespoon",
"product": "parsley",
"productSizeModifier": null,
"preparationNotes": "finely chopped",
"usdaInfo": {
"category": "Vegetables and Vegetable Products",
"description": "Parsley, fresh",
"fdcId": "170416",
"matchMethod": "exact"
},
"confidence": 0.9858154,
}
Parse multiple ingredients
import parse_ingredient
ingredients = parse_ingredient.parse_multiple([
'2 1/2 tablespoons finely chopped parsley',
'3 large Granny Smith apples'
)
print(json.dumps(ingredients.as_dict()))
[
{
"ingredientRaw": "3 large Granny Smith apples",
"ingredientParsed": {
"preparationNotes": "finely chopped",
"product": "parsley",
"productSizeModifier": null,
"quantity": 2.5,
"unit": "tablespoon",
"usdaInfo": {
"category": "Vegetables and Vegetable Products",
"description": "Parsley, fresh",
"fdcId": "170416",
"matchMethod": "exact"
},
"confidence": 0.9858154,
},
"error": null,
},
{
"ingredientRaw": "3 large Granny Smith apples",
"ingredientParsed": {
"preparationNotes": null,
"product": "Granny Smith apples",
"productSizeModifier": "large",
"quantity": 3.0,
"unit": null,
"usdaInfo": {
"category": "Fruits and Fruit Juices",
"description": "Apples, raw, granny smith, with skin (Includes foods for USDA's Food Distribution Program)",
"fdcId": "168203",
"matchMethod": "exact"
},
"confidence": 0.9741028,
},
"error": null,
}
]
Parse ingredients using RapidAPI
If you have a RapidAPI subscription to Zestful, you can use your API key as follows:
import parse_ingredient
# Replace this with your key from RapidAPI
# https://rapidapi.com/zestfuldata/api/recipe-and-ingredient-analysis
RAPID_API_KEY = 'your-rapid-api-key'
client = parse_ingredient.client(rapid_api_key=RAPID_API_KEY)
ingredient = client.parse_ingredient('2 1/2 tablespoons finely chopped parsley')
print(ingredient.as_json())
Use private Zestful server
If you have a private Zestful ingredient parsing server as part of an Enterprise plan, you can use the library as follows:
import parse_ingredient
ENDPOINT_URL = 'https://zestful.yourdomain.com'
client = parse_ingredient.client(endpoint_url=ENDPOINT_URL)
ingredient = client.parse_ingredient('2 1/2 tablespoons finely chopped parsley')
print(ingredient.as_json())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for zestful-parse-ingredient-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ed1c20c9f79488012deabab0d0da7c246a26b25f1ac81b511fa32705a9080e9 |
|
MD5 | cdc0a462833eb35e4d58949550a7416c |
|
BLAKE2b-256 | 957f9c05a0c550d77b162e5ead0603d83686a10fc0d38e8cc181f7f0ac8b6dcc |
Close
Hashes for zestful_parse_ingredient-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22f9603bd120a5df9da09049d15c3efb42082324456a3d36bba8c5bcf3fdaa29 |
|
MD5 | 1a3ea900859df229dd00a907d1b1c4d5 |
|
BLAKE2b-256 | 2d00e9ea345bce32a3e36c8fefb532d5e7376b960489e6a7128f06ae4963161b |