ingredient-slicer


Nameingredient-slicer JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryParses unstructured recipe ingredient text into standardized quantities, units, and foods
upload_time2024-05-18 16:17:42
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License
keywords ingredient parser recipe text processing food cooking grocery shopping
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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/6c/74/c6efdcb6bb1e97773717fdf93b5de66c3c4d2206716514914bcf726de8d6/ingredient_slicer-1.0.2.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.0.2",
    "project_urls": null,
    "split_keywords": [
        "ingredient",
        " parser",
        " recipe",
        " text processing",
        " food",
        " cooking",
        " grocery",
        " shopping"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "197dac98e23bc6431897f436db69852a499924222479e233e4817a0a6cc88037",
                "md5": "d535e5578f66e57b1ece27c25302cee5",
                "sha256": "bb89d7cc920c4711bf27fba30d41f10c9d954f3b1ba8ef254b4826ba8c06df77"
            },
            "downloads": -1,
            "filename": "ingredient_slicer-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d535e5578f66e57b1ece27c25302cee5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 84689,
            "upload_time": "2024-05-18T16:17:40",
            "upload_time_iso_8601": "2024-05-18T16:17:40.290286Z",
            "url": "https://files.pythonhosted.org/packages/19/7d/ac98e23bc6431897f436db69852a499924222479e233e4817a0a6cc88037/ingredient_slicer-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c74c6efdcb6bb1e97773717fdf93b5de66c3c4d2206716514914bcf726de8d6",
                "md5": "e26dbb162f0bab5abb95644394d92de4",
                "sha256": "169e2fd624f4af7e2765af04a738628f3b8f3a05eb75643dd97c6e0c2c5a25c3"
            },
            "downloads": -1,
            "filename": "ingredient_slicer-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "e26dbb162f0bab5abb95644394d92de4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 127112,
            "upload_time": "2024-05-18T16:17:42",
            "upload_time_iso_8601": "2024-05-18T16:17:42.029601Z",
            "url": "https://files.pythonhosted.org/packages/6c/74/c6efdcb6bb1e97773717fdf93b5de66c3c4d2206716514914bcf726de8d6/ingredient_slicer-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-18 16:17:42",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "ingredient-slicer"
}
        
Elapsed time: 0.23544s