Skip to main content

Parses ingredient names into Name, Unit and Quantity

Project description

PyIng - Ingredient parser

This is a python package for parsing ingredient strings. There is only one function parse_ingredients. It takes in a single string or list of strings and returns a dictionary containing the name, quantity and unit in that recipe string.

Get Started

First install the package using pip:

pip install pying

Then you can use it like follows:

from PyIng import parse_ingredients

ingredients = ["3 large melons", "5 1/2 cups water", "2 cups flour"]

parsed_ingredients = parse_ingredients(ingredients)

the output parsed_ingredients should look like so:

parsed_ingredients = [
    {
        "name": "melons",
        "unit": None,
        "qty": 3.0
    },
    {
        "name": "water",
        "unit": "cups",
        "qty": 5.5
    },
    {
        "name": "flour",
        "unit": "cups",
        "qty": 2
    }
]

Training the model

The ingredient parser uses a LSTM model written in tensorflow. It is trained on a publically available dataset produced by the new york times:

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwjowpyb9uj2AhWNiFwKHcFQBC8QFnoECAgQAQ&url=https%3A%2F%2Fgithub.com%2Fnytimes%2Fingredient-phrase-tagger&usg=AOvVaw1AHIgZ0BfSe8ddG7E8alYt

The entire model is trained using the train_model.ipynb and the model is saved in tflite format. Please try and improve on my model, it is far from optimal, I wanted to get something that works without spending too long.

THere are more details on training the model in the jupyter notebook.

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

PyIng-0.1.15.tar.gz (74.4 MB view details)

Uploaded Source

File details

Details for the file PyIng-0.1.15.tar.gz.

File metadata

  • Download URL: PyIng-0.1.15.tar.gz
  • Upload date:
  • Size: 74.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.4

File hashes

Hashes for PyIng-0.1.15.tar.gz
Algorithm Hash digest
SHA256 aa72aec39ad16e1b56b9ea5ddac4d16e25ce2477b0b9073bd423c40fcd2a0f5a
MD5 3e8d4be8b6c344ae7bb1025d85215850
BLAKE2b-256 291f3e292ce54c9fbe40957b23cb4cf2b5d7cc604d17831846c54de0b749652a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page