ingredient-parser-nlp


Nameingredient-parser-nlp JSON
Version 0.1.0b10 PyPI version JSON
download
home_pageNone
SummaryA Python package to parse structured information from recipe ingredient sentences
upload_time2024-04-12 16:48:45
maintainerNone
docs_urlNone
authorNone
requires_python<3.13,>=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 No requirements were recorded.
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,
    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](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.13,>=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/5d/69/3b172af53d467ba1ca66a1747f6d58bca76f08d84dd1016ebff2e4eba673/ingredient_parser_nlp-0.1b10.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    sentence='3 pounds pork shoulder, cut into 2-inch chunks'\n)\n```\n\n## Model accuracy\n\nThe 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:\n\n```\nSentence-level results:\n\tAccuracy: 94.24%\n\nWord-level results:\n\tAccuracy 97.73%\n\tPrecision (micro) 97.72%\n\tRecall (micro) 97.73%\n\tF1 score (micro) 97.72%\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": "0.1.0b10",
    "project_urls": {
        "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": "f7a8086cdfe8f3015c4087974adf88a890efa31fce5bc1b0aa4d1be1b4b78d4e",
                "md5": "f23c0986b97866d3899aa24be7df2c8b",
                "sha256": "9179d72534fc0523a8d5c9bf6a78fb3f04f7687d745e4abe292bc4ac7f088d91"
            },
            "downloads": -1,
            "filename": "ingredient_parser_nlp-0.1.0b10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f23c0986b97866d3899aa24be7df2c8b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.10",
            "size": 762852,
            "upload_time": "2024-04-12T16:48:42",
            "upload_time_iso_8601": "2024-04-12T16:48:42.402359Z",
            "url": "https://files.pythonhosted.org/packages/f7/a8/086cdfe8f3015c4087974adf88a890efa31fce5bc1b0aa4d1be1b4b78d4e/ingredient_parser_nlp-0.1.0b10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5d693b172af53d467ba1ca66a1747f6d58bca76f08d84dd1016ebff2e4eba673",
                "md5": "21c4f1b7979aefc854bedccc4ec85c40",
                "sha256": "1bda83e17f8fcf0798fb39c1c4af9f2b59629bae4ca1b41bb4438335748560f1"
            },
            "downloads": -1,
            "filename": "ingredient_parser_nlp-0.1b10.tar.gz",
            "has_sig": false,
            "md5_digest": "21c4f1b7979aefc854bedccc4ec85c40",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.10",
            "size": 763889,
            "upload_time": "2024-04-12T16:48:45",
            "upload_time_iso_8601": "2024-04-12T16:48:45.253401Z",
            "url": "https://files.pythonhosted.org/packages/5d/69/3b172af53d467ba1ca66a1747f6d58bca76f08d84dd1016ebff2e4eba673/ingredient_parser_nlp-0.1b10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-12 16:48:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "strangetom",
    "github_project": "ingredient-parser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "ingredient-parser-nlp"
}
        
Elapsed time: 0.25811s