Parses unstructured recipe ingredient text into standardized quantities, units, and foods
Project description
ingredient-slicer
Python 📦 package for extracting quantities, units, and food words from unstructured recipe ingredients text.
ingredient-slicer
works by standardizing the input text and then applying a set of rules and heuristic methods to parse out quantities, units, and food words from unstructured recipe ingredients text.
ingredient-slicer
was designed to provide a robust and lightweight method for parsing recipe ingredients
text without relying on any external dependencies or NLP/ML models.
That being said, it is not perfect and can always be improved upon.
Table of Contents:
Installation:
ingredient_slicer
can be downloaded from PyPI via pip
like so:
pip install ingredient-slicer
Usage:
Provide a string to the IngredientSlicer
class and thats it. Invoke the to_json()
method to return the parsed ingredient.
import ingredient_slicer
slicer = ingredient_slicer.IngredientSlicer("2 (15-ounces) cans chickpeas, rinsed and drained")
slicer.to_json()
{
'ingredient': '2 (15-ounces) cans chickpeas, rinsed and drained',
'standardized_ingredient': '2 cans chickpeas, rinsed and drained',
'food': 'chickpeas',
# primary quantity and units
'quantity': '30',
'unit': 'ounces',
'standardized_unit': 'ounce',
# any other secondary quantity and units found in the string
'secondary_quantity': '2',
'secondary_unit': 'cans',
'standardized_secondary_unit': 'can',
'gram_weight': '850.49',
'prep': ['drained', 'rinsed'],
'size_modifiers': [],
'dimensions': [],
'is_required': True,
'parenthesis_content': ['15 ounce']
}
Individual ingredient components can also be found using methods like food()
, quantity()
, or unit()
import ingredient_slicer
slicer = ingredient_slicer.IngredientSlicer("3 tbsp unsalted butter, softened at room temperature")
slicer.food()
>>> 'unsalted butter'
slicer.quantity()
>>> '3'
slicer.unit()
>>> 'tbsp'
slicer.standardized_unit()
>>> 'tablespoon'
slicer.prep()
>>> ['room temperature', 'softened']
Contributing/Issues:
If you find a bug or have an idea for a new feature, please open an issue or submit a pull request.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file ingredient_slicer-1.1.15.tar.gz
.
File metadata
- Download URL: ingredient_slicer-1.1.15.tar.gz
- Upload date:
- Size: 122.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62151bb113f1d8fe11c11f7d7d908cae01ecc78957e029dd91637257263e3077 |
|
MD5 | cc4cde67946fcb4fff407dc54067f25f |
|
BLAKE2b-256 | 7aa3c54f6251730e34886d593eab5bf7ef8256642e4c0c16186bc56355b8d151 |
File details
Details for the file ingredient_slicer-1.1.15-py3-none-any.whl
.
File metadata
- Download URL: ingredient_slicer-1.1.15-py3-none-any.whl
- Upload date:
- Size: 75.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 861441471552f6467408f481c3ac8d377ca6d58e0e94a270d852ca535228fa4e |
|
MD5 | 6ea121c1219a684da0101ade04739e3c |
|
BLAKE2b-256 | 9458856e48f3e71521815090d7322d18ee0c08fd76dcc4416b786818589bb15f |