ingredient-parser-nlp


Nameingredient-parser-nlp JSON
Version 1.3.2 PyPI version JSON
download
home_pageNone
SummaryA Python package to parse structured information from recipe ingredient sentences
upload_time2024-12-06 07:28:13
maintainerNone
docs_urlNone
authorNone
requires_python<3.14,>=3.10
licenseMIT License Copyright (c) 2021-2024 Tom Strange Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords recipe ingredient ingredients nlp parsing
VCS
bugtrack_url
requirements nltk python-crfsuite pint
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Ingredient Parser

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

![](docs/source/_static/logo.png)

## 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 75,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: 95.87%

Word-level results:
	Accuracy 98.29%
	Precision (micro) 98.29%
	Recall (micro) 98.29%
	F1 score (micro) 98.29%
```

## 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.

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
```

![Screen shot of web app](docs/source/_static/app-screenshot.png)

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/19/4e/4603b6e578252744df64ae10dbe3b0b525b5120ccb9507abee794ace241f/ingredient_parser_nlp-1.3.2.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![](docs/source/_static/logo.png)\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 75,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: 95.87%\n\nWord-level results:\n\tAccuracy 98.29%\n\tPrecision (micro) 98.29%\n\tRecall (micro) 98.29%\n\tF1 score (micro) 98.29%\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\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![Screen shot of web app](docs/source/_static/app-screenshot.png)\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": "MIT License  Copyright (c) 2021-2024 Tom Strange  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A Python package to parse structured information from recipe ingredient sentences",
    "version": "1.3.2",
    "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": "",
            "digests": {
                "blake2b_256": "34167a0a2310aa112f6a0878ec364fb1cacb417514b5388446aaf8b12888e732",
                "md5": "64d70c95e8b3e7d4b12a13d73113f682",
                "sha256": "4e9b18a977e6b93985edd5a2668e5bb4f1dd3c570374316fb7f811a21ca55523"
            },
            "downloads": -1,
            "filename": "ingredient_parser_nlp-1.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "64d70c95e8b3e7d4b12a13d73113f682",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.10",
            "size": 827779,
            "upload_time": "2024-12-06T07:28:10",
            "upload_time_iso_8601": "2024-12-06T07:28:10.443317Z",
            "url": "https://files.pythonhosted.org/packages/34/16/7a0a2310aa112f6a0878ec364fb1cacb417514b5388446aaf8b12888e732/ingredient_parser_nlp-1.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "194e4603b6e578252744df64ae10dbe3b0b525b5120ccb9507abee794ace241f",
                "md5": "1dcbce9c6311205aebe5519a459c6a6f",
                "sha256": "12f4d34717364881b828b476bd5b5f8a72c96474883b8cbe94911a39fd71e719"
            },
            "downloads": -1,
            "filename": "ingredient_parser_nlp-1.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1dcbce9c6311205aebe5519a459c6a6f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.14,>=3.10",
            "size": 828647,
            "upload_time": "2024-12-06T07:28:13",
            "upload_time_iso_8601": "2024-12-06T07:28:13.104995Z",
            "url": "https://files.pythonhosted.org/packages/19/4e/4603b6e578252744df64ae10dbe3b0b525b5120ccb9507abee794ace241f/ingredient_parser_nlp-1.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-06 07:28:13",
    "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"
                ]
            ]
        }
    ],
    "lcname": "ingredient-parser-nlp"
}
        
Elapsed time: 0.39553s