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](#installation)
- [Usage](#usage)
<br>
Installation:
-----------------------
`ingredient_slicer` can be downloaded from PyPI via `pip` like so:
``` shell
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.
```pycon
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()`
```pycon
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 :)
Raw data
{
"_id": null,
"home_page": null,
"name": "ingredient-slicer",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "ingredient, parser, recipe, text processing, food, cooking, grocery, shopping",
"author": null,
"author_email": "Angus Watters <anguswatters@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/43/58/44fc9733ae53deffcacaaa04fe488733127eae54c3a93615ec00b098726c/ingredient_slicer-1.1.26.tar.gz",
"platform": null,
"description": "ingredient-slicer\n------\n\nPython \ud83d\udce6 package for extracting quantities, units, and food words from unstructured recipe ingredients text. \n\n`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.\n`ingredient-slicer` was designed to provide a robust and lightweight method for parsing recipe ingredients \ntext *without* relying on any external dependencies or NLP/ML models.\nThat being said, it is not perfect and can always be improved upon. \n\n\nTable of Contents:\n-----------------------\n- [Installation](#installation)\n- [Usage](#usage)\n\n<br>\n\nInstallation:\n-----------------------\n`ingredient_slicer` can be downloaded from PyPI via `pip` like so:\n\n``` shell\npip install ingredient-slicer\n```\n\nUsage:\n-----------------------\n\nProvide a string to the `IngredientSlicer` class and thats it. Invoke the `to_json()` method to return the parsed ingredient.\n\n```pycon\n\nimport ingredient_slicer\n\nslicer = ingredient_slicer.IngredientSlicer(\"2 (15-ounces) cans chickpeas, rinsed and drained\")\n\nslicer.to_json()\n\n{ \n 'ingredient': '2 (15-ounces) cans chickpeas, rinsed and drained', \n 'standardized_ingredient': '2 cans chickpeas, rinsed and drained', \n 'food': 'chickpeas', \n\n # primary quantity and units\n 'quantity': '30', \n 'unit': 'ounces', \n 'standardized_unit': 'ounce', \n\n # any other secondary quantity and units found in the string\n 'secondary_quantity': '2', \n 'secondary_unit': 'cans', \n 'standardized_secondary_unit': 'can', \n\n 'gram_weight': '850.49', \n 'prep': ['drained', 'rinsed'], \n 'size_modifiers': [], \n 'dimensions': [], \n 'is_required': True, \n 'parenthesis_content': ['15 ounce']\n}\n```\n\nIndividual ingredient components can also be found using methods like `food()`, `quantity()`, or `unit()`\n\n```pycon\n\nimport ingredient_slicer\n\nslicer = ingredient_slicer.IngredientSlicer(\"3 tbsp unsalted butter, softened at room temperature\")\n\nslicer.food() \n>>> 'unsalted butter'\n\nslicer.quantity() \n>>> '3' \n\nslicer.unit() \n>>> 'tbsp'\n\nslicer.standardized_unit() \n>>> 'tablespoon'\n\nslicer.prep() \n>>> ['room temperature', 'softened']\n```\n\nContributing/Issues:\n-----------------------\nIf you find a bug or have an idea for a new feature, please open an issue or submit a pull request :)\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Parses unstructured recipe ingredient text into standardized quantities, units, and foods",
"version": "1.1.26",
"project_urls": null,
"split_keywords": [
"ingredient",
" parser",
" recipe",
" text processing",
" food",
" cooking",
" grocery",
" shopping"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1dffd33954858ce6befaab44de00abed1596f5bee49cb4fb0cde2e9a0262154b",
"md5": "2e93ceab9119e76ba109edcb1c81947e",
"sha256": "aeeef94b72e187c85545bb55aec84e08c05102e4cf9e7c476407b9ac5fe56371"
},
"downloads": -1,
"filename": "ingredient_slicer-1.1.26-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2e93ceab9119e76ba109edcb1c81947e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 76328,
"upload_time": "2024-10-07T14:52:20",
"upload_time_iso_8601": "2024-10-07T14:52:20.290285Z",
"url": "https://files.pythonhosted.org/packages/1d/ff/d33954858ce6befaab44de00abed1596f5bee49cb4fb0cde2e9a0262154b/ingredient_slicer-1.1.26-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "435844fc9733ae53deffcacaaa04fe488733127eae54c3a93615ec00b098726c",
"md5": "5c652f4f0da7ea25c33f197abf5e67ad",
"sha256": "11b032c0b2e14f318386e605b18c9b07d08d3c105920d3079b1816565862da1a"
},
"downloads": -1,
"filename": "ingredient_slicer-1.1.26.tar.gz",
"has_sig": false,
"md5_digest": "5c652f4f0da7ea25c33f197abf5e67ad",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 124964,
"upload_time": "2024-10-07T14:52:23",
"upload_time_iso_8601": "2024-10-07T14:52:23.714800Z",
"url": "https://files.pythonhosted.org/packages/43/58/44fc9733ae53deffcacaaa04fe488733127eae54c3a93615ec00b098726c/ingredient_slicer-1.1.26.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-07 14:52:23",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "ingredient-slicer"
}