# 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
```bash
$ python -m pip install ingredient-parser-nlp
```
Import the ```parse_ingredient``` function and pass it an ingredient sentence.
```python
>>> 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,
foundation_foods=[],
sentence='3 pounds pork shoulder, cut into 2-inch chunks'
)
```
Refer to the documentation [here](https://ingredient-parser.readthedocs.io/en/latest/start/index.html#optional-parameters) for the optional parameters that can be used with `parse_ingredient` .
## Model
The core of the library is a sequence labelling model that is used to label each token in the sentence with the part of the sentence it belongs to. A data set of 81,000 example sentences is used to train and evaluate the model. See the [Model Guide](https://ingredient-parser.readthedocs.io/en/latest/guide/index.html) in the documentation for mode details.
The model has the following accuracy on a test data set of 20% of the total data used:
```
Sentence-level results:
Accuracy: 94.94%
Word-level results:
Accuracy 97.90%
Precision (micro) 97.88%
Recall (micro) 97.90%
F1 score (micro) 97.88%
```
## Development
The development dependencies are in the ```requirements-dev.txt``` file. Details on the training process can be found in the [Model Guide](https://ingredient-parser.readthedocs.io/en/latest/guide/index.html) documentation.
Before committing anything, install [pre-commit](https://pre-commit.com/) and run
```
pre-commit install
```
to install the pre-commit hooks.
Please target the **develop** branch for pull requests. The main branch is used for stable releases and hotfixes only.
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
```bash
$ 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.
Raw data
{
"_id": null,
"home_page": null,
"name": "ingredient-parser-nlp",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.14,>=3.10",
"maintainer_email": null,
"keywords": "recipe, ingredient, ingredients, nlp, parsing",
"author": null,
"author_email": "Tom Strange <tpstrange@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/1e/57/15d420d94f661fc343160a28a91d8f7cf9802439365cb178fc9094081fc9/ingredient_parser_nlp-2.2.0.tar.gz",
"platform": null,
"description": "# Ingredient Parser\n\nThe Ingredient Parser package is a Python package for parsing structured information out of recipe ingredient sentences.\n\n\n\n## Documentation\n\nDocumentation on using the package and training the model can be found at https://ingredient-parser.readthedocs.io/.\n\n## Quick Start\n\nInstall the package using pip\n\n```bash\n$ python -m pip install ingredient-parser-nlp\n```\n\nImport the ```parse_ingredient``` function and pass it an ingredient sentence.\n\n```python\n>>> from ingredient_parser import parse_ingredient\n>>> parse_ingredient(\"3 pounds pork shoulder, cut into 2-inch chunks\")\nParsedIngredient(\n name=[IngredientText(text='pork shoulder', confidence=0.999193)],\n size=None,\n amount=[IngredientAmount(quantity='3',\n unit=<Unit('pound')>,\n text='3 pounds',\n confidence=0.999906,,\n APPROXIMATE=False,\n SINGULAR=False)],\n preparation=IngredientText(text='cut into 2 inch chunks', confidence=0.999193),\n comment=None,\n purpose=None,\n foundation_foods=[],\n sentence='3 pounds pork shoulder, cut into 2-inch chunks'\n)\n```\n\nRefer to the documentation [here](https://ingredient-parser.readthedocs.io/en/latest/start/index.html#optional-parameters) for the optional parameters that can be used with `parse_ingredient` .\n\n## Model\n\nThe core of the library is a sequence labelling model that is used to label each token in the sentence with the part of the sentence it belongs to. A data set of 81,000 example sentences is used to train and evaluate the model. See the [Model Guide](https://ingredient-parser.readthedocs.io/en/latest/guide/index.html) in the documentation for mode details.\n\nThe model has the following accuracy on a test data set of 20% of the total data used:\n\n```\nSentence-level results:\n\tAccuracy: 94.94%\n\nWord-level results:\n\tAccuracy 97.90%\n\tPrecision (micro) 97.88%\n\tRecall (micro) 97.90%\n\tF1 score (micro) 97.88%\n```\n\n## Development\n\nThe development dependencies are in the ```requirements-dev.txt``` file. Details on the training process can be found in the [Model Guide](https://ingredient-parser.readthedocs.io/en/latest/guide/index.html) documentation.\n\nBefore committing anything, install [pre-commit](https://pre-commit.com/) and run\n```\npre-commit install\n```\n\nto install the pre-commit hooks.\n\nPlease target the **develop** branch for pull requests. The main branch is used for stable releases and hotfixes only.\n\nThere 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\n\n```bash\n$ flask --app webapp run\n```\n\n\n\nThis requires the development dependencies to be installed.\n\nThe dependencies for building the documentation are in the ```requirements-doc.txt``` file.\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python package to parse structured information from recipe ingredient sentences",
"version": "2.2.0",
"project_urls": {
"Changelog": "https://github.com/strangetom/ingredient-parser/blob/master/CHANGELOG.md",
"Documentation": "https://ingredient-parser.readthedocs.io/en/latest/",
"Homepage": "https://github.com/strangetom/ingredient-parser/",
"Source": "https://github.com/strangetom/ingredient-parser"
},
"split_keywords": [
"recipe",
" ingredient",
" ingredients",
" nlp",
" parsing"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "b70ecbcaaef4a7dab88285184bf7c1b06af9375ec976dfd3d40f4848bc0c6540",
"md5": "832e071e699ba68aeaa88113f5737ebb",
"sha256": "b9be48c0a27eb972f8cfdc0f755cfa32fd16a598ff714b8f1a3b244c8622bed0"
},
"downloads": -1,
"filename": "ingredient_parser_nlp-2.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "832e071e699ba68aeaa88113f5737ebb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.14,>=3.10",
"size": 4543922,
"upload_time": "2025-08-15T17:51:29",
"upload_time_iso_8601": "2025-08-15T17:51:29.845182Z",
"url": "https://files.pythonhosted.org/packages/b7/0e/cbcaaef4a7dab88285184bf7c1b06af9375ec976dfd3d40f4848bc0c6540/ingredient_parser_nlp-2.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1e5715d420d94f661fc343160a28a91d8f7cf9802439365cb178fc9094081fc9",
"md5": "19734042df817d96b2d0f9a9faa2136b",
"sha256": "cabd12bd01a030b19f1859a968219c7f2cd68dd08d03484194245f7454d85d20"
},
"downloads": -1,
"filename": "ingredient_parser_nlp-2.2.0.tar.gz",
"has_sig": false,
"md5_digest": "19734042df817d96b2d0f9a9faa2136b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.14,>=3.10",
"size": 4542358,
"upload_time": "2025-08-15T17:51:32",
"upload_time_iso_8601": "2025-08-15T17:51:32.698791Z",
"url": "https://files.pythonhosted.org/packages/1e/57/15d420d94f661fc343160a28a91d8f7cf9802439365cb178fc9094081fc9/ingredient_parser_nlp-2.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-15 17:51:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "strangetom",
"github_project": "ingredient-parser",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "nltk",
"specs": [
[
">=",
"3.9.1"
]
]
},
{
"name": "python-crfsuite",
"specs": []
},
{
"name": "pint",
"specs": [
[
"==",
"0.24.4"
]
]
},
{
"name": "numpy",
"specs": []
}
],
"lcname": "ingredient-parser-nlp"
}