# 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 │ Word-level results │
╞══════════════════════════╪══════════════════════════╡
│ Accuracy: 95.27% │ Accuracy: 98.10% │
│ │ Precision (micro) 98.08% │
│ │ Recall (micro) 98.10% │
│ │ F1 score (micro) 98.09% │
╘══════════════════════════╧══════════════════════════╛
```
## Development
**Basic**
Train and fine-tune new ingredient datasets to expand beyond the existing trained model provided in the library. 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.
**Web App**
The ingredient parser library provides a convenient web interface that you can run locally to access most of the library's functionality, including using the parser, browsing the database, labelling entries, and training the model(s). View the [specific README](webtools/README.md) in webtools for a detailed overview.
| Parser | Labeller | Trainer |
| :------- | :------- | :------- |
|  |  |  |
**Documentation**
The dependencies for building the documentation are in the `requirements-doc.txt` file.
**Contribution**
Please target the **develop** branch for pull requests. The **main** branch is used for stable releases and hotfixes only.
Before committing anything, install [pre-commit](https://pre-commit.com/) and run the following to install the hooks:
```bash
$ pre-commit install
```
Pre-commit hooks cover both the main python library code and the web app (webtools) code.
Raw data
{
"_id": null,
"home_page": null,
"name": "ingredient-parser-nlp",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.15,>=3.11",
"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/5f/27/4c22f39fea51576abe43034bb4679ae4dec9d9204f0b7e92dedb1532465a/ingredient_parser_nlp-2.4.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```\n\u2552\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2555\n\u2502 Sentence-level results \u2502 Word-level results \u2502\n\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561\n\u2502 Accuracy: 95.27% \u2502 Accuracy: 98.10% \u2502\n\u2502 \u2502 Precision (micro) 98.08% \u2502\n\u2502 \u2502 Recall (micro) 98.10% \u2502\n\u2502 \u2502 F1 score (micro) 98.09% \u2502\n\u2558\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255b\n```\n\n## Development\n\n**Basic**\n\nTrain and fine-tune new ingredient datasets to expand beyond the existing trained model provided in the library. 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.\n\n**Web App**\n\nThe ingredient parser library provides a convenient web interface that you can run locally to access most of the library's functionality, including using the parser, browsing the database, labelling entries, and training the model(s). View the [specific README](webtools/README.md) in webtools for a detailed overview.\n\n| Parser | Labeller | Trainer |\n| :------- | :------- | :------- |\n|  |  |  |\n\n**Documentation**\n\nThe dependencies for building the documentation are in the `requirements-doc.txt` file.\n\n**Contribution**\n\nPlease target the **develop** branch for pull requests. The **main** branch is used for stable releases and hotfixes only.\n\nBefore committing anything, install [pre-commit](https://pre-commit.com/) and run the following to install the hooks:\n\n```bash\n$ pre-commit install\n```\n\nPre-commit hooks cover both the main python library code and the web app (webtools) code.\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python package to parse structured information from recipe ingredient sentences",
"version": "2.4.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": "be1c2869cc2c22bed70981186ec554eb8b3991940c0b07760b2c42d7027fff27",
"md5": "cce5d078507aefffcc3616ca0a908d0c",
"sha256": "022b7ae24fd4b5f3a51ca2b8b4de73f39bc2d9f9332b02128345fc72790764af"
},
"downloads": -1,
"filename": "ingredient_parser_nlp-2.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cce5d078507aefffcc3616ca0a908d0c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.15,>=3.11",
"size": 4543848,
"upload_time": "2025-10-27T13:03:32",
"upload_time_iso_8601": "2025-10-27T13:03:32.487024Z",
"url": "https://files.pythonhosted.org/packages/be/1c/2869cc2c22bed70981186ec554eb8b3991940c0b07760b2c42d7027fff27/ingredient_parser_nlp-2.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5f274c22f39fea51576abe43034bb4679ae4dec9d9204f0b7e92dedb1532465a",
"md5": "48c6b9a057a77efe9e6a9a38a3771d19",
"sha256": "73c48f229ec86afc07c8e52df5c60cea93dbbfd8fde4f9659ac1f89d1711306c"
},
"downloads": -1,
"filename": "ingredient_parser_nlp-2.4.0.tar.gz",
"has_sig": false,
"md5_digest": "48c6b9a057a77efe9e6a9a38a3771d19",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.15,>=3.11",
"size": 4541596,
"upload_time": "2025-10-27T13:03:35",
"upload_time_iso_8601": "2025-10-27T13:03:35.061270Z",
"url": "https://files.pythonhosted.org/packages/5f/27/4c22f39fea51576abe43034bb4679ae4dec9d9204f0b7e92dedb1532465a/ingredient_parser_nlp-2.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-27 13:03:35",
"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.25.0"
]
]
},
{
"name": "numpy",
"specs": []
}
],
"lcname": "ingredient-parser-nlp"
}