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,
purpose=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 20% of the total data used:
Sentence-level results:
Accuracy: 94.75%
Word-level results:
Accuracy 97.83%
Precision (micro) 97.82%
Recall (micro) 97.83%
F1 score (micro) 97.82%
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
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
Built Distribution
Hashes for ingredient_parser_nlp-0.1.0b11.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fe3777cae139a1e4da826543c519e5aab7a428a28b150b75c8ec2ffd67274f5 |
|
MD5 | 5d7f6907a5f8fff4650d860bed6156fb |
|
BLAKE2b-256 | 19240b7ebc6953e5263a95d1c53c74187a7928fc5142464668df4a15defdba05 |
Hashes for ingredient_parser_nlp-0.1.0b11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bc492109db7d81cbe17e116140a5e7bbf293ef39ae8aaa53175ff688ceffc8a |
|
MD5 | 1211ed61f3d472a515bcdf7782fb1647 |
|
BLAKE2b-256 | 4ad5216753b379d960b5f3840bac520a1d84c50482c365b4da1a7357b00f2dd7 |