Skip to main content

A Python package to parse structured information from recipe ingredient sentences

Project description

Ingredient Parser

The Ingredient Parser package is a Python package for parsing structured information out of recipe ingredient sentences.

Documentation

Documentation on using the package and training the model can be found at https://ingredient-parser.readthedocs.io/.

Quick Start

Install the package using pip

$ python -m pip install ingredient-parser-nlp

Import the parse_ingredient function and pass it an ingredient sentence.

>>> from ingredient_parser import parse_ingredient
>>> parse_ingredient("3 pounds pork shoulder, cut into 2-inch chunks")
ParsedIngredient(
    name=IngredientText(text='pork shoulder', confidence=0.999193),
    size=None,
    amount=[IngredientAmount(quantity='3',
                             unit=<Unit('pound')>,
                             text='3 pounds',
                             confidence=0.999906,,
                             APPROXIMATE=False,
                             SINGULAR=False)],
    preparation=IngredientText(text='cut into 2 inch chunks', confidence=0.999193),
    comment=None,
    sentence='3 pounds pork shoulder, cut into 2-inch chunks'
)

Model accuracy

The model used for labelling tokens in sentences, provided in the ingredient-parser/ directory, has the following accuracy on a test data set of 25% of the total data used:

Sentence-level results:
	Accuracy: 94.24%

Word-level results:
	Accuracy 97.73%
	Precision (micro) 97.72%
	Recall (micro) 97.73%
	F1 score (micro) 97.72%

Development

The development dependencies are in the requirements-dev.txt file. Details on the training process can be found in the Model Guide documentation.

Before committing anything, install pre-commit and run

pre-commit install

to install the pre-commit hooks.

There is a simple web app for testing the parser with ingredient sentences and showing the parsed output. To run the web app, run the command

$ flask --app webapp run

Screen shot of web app

This requires the development dependencies to be installed.

The dependencies for building the documentation are in the requirements-doc.txt file.

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

ingredient_parser_nlp-0.1.0b9.tar.gz (763.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ingredient_parser_nlp-0.1.0b9-py3-none-any.whl (762.8 kB view details)

Uploaded Python 3

File details

Details for the file ingredient_parser_nlp-0.1.0b9.tar.gz.

File metadata

  • Download URL: ingredient_parser_nlp-0.1.0b9.tar.gz
  • Upload date:
  • Size: 763.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.0

File hashes

Hashes for ingredient_parser_nlp-0.1.0b9.tar.gz
Algorithm Hash digest
SHA256 13508533ea301d3a901ad9e4a73353e6fcd401bfebd9d4b4df191fb96d2c1911
MD5 ad27be31b1bf06dcba32b9bad327b9f4
BLAKE2b-256 a2b2ae053a29dd122e6419a1102b0c52329de38b4ac22d88a282f7f0b8d577f0

See more details on using hashes here.

File details

Details for the file ingredient_parser_nlp-0.1.0b9-py3-none-any.whl.

File metadata

File hashes

Hashes for ingredient_parser_nlp-0.1.0b9-py3-none-any.whl
Algorithm Hash digest
SHA256 ab1d35b3e3c8e5c2791e6c9a661b818e48ba52c4a47182a33845609ad87349e4
MD5 2607de52abe8abcf2203a1a8d28a8cf2
BLAKE2b-256 1452a2129547688ad491bebc5f049d2c433d59a6de2e9010355d45fcd090111d

See more details on using hashes here.

Supported by

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