Coder Social home page Coder Social logo

pkuaaron / pying Goto Github PK

View Code? Open in Web Editor NEW

This project forked from whitew1994ww/pying

0.0 0.0 0.0 74.19 MB

Python module to parse ingredient names. Splitting them into the ingredient, unit and quantity. It is trained on a publicly available dataset using Tensorflow.

License: MIT License

Python 3.16% Jupyter Notebook 96.84%

pying's Introduction

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.

pying's People

Contributors

whitew1994ww avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.