A Python package to parse structured information from recipe ingredient sentences
Reason this release was yanked:
No upper limit on Python version set.
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/en/latest/.
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")
{'sentence': '3 pounds pork shoulder, cut into 2-inch chunks',
'quantity': '3',
'unit': 'pound',
'name': 'pork shoulder',
'comment': ', cut into 2-inch chunks',
'other': ''}
# Output confidence for each label
>>> parse_ingredient("3 pounds pork shoulder, cut into 2-inch chunks", confidence=True)
{'sentence': '3 pounds pork shoulder, cut into 2-inch chunks',
'quantity': '3',
'unit': 'pound',
'name': 'pork shoulder',
'comment': ', cut into 2-inch chunks',
'other': '',
'confidence': {'quantity': 0.9986,
'unit': 0.9967,
'name': 0.9535,
'comment': 0.9967,
'other': 0}}
The returned dictionary has the format
{
"sentence": str,
"quantity": str,
"unit": str,
"name": str,
"comment": Union[List[str], str],
"other": Union[List[str], str]
}
Model accuracy
The model provided in ingredient-parser/ directory has the following accuracy on a test data set of 25% of the total data used:
Sentence-level results:
Total: 9277
Correct: 7880
-> 84.94%
Word-level results:
Total: 53162
Correct: 50655
-> 95.28%
Development
The development dependencies are in the requirements-dev.txt file.
Note that development includes training the model.
-
Blackis used for code formatting. -
isortis used for import sorting. -
flake8is used for linting. Note the line length standard (E501) is ignored. -
pyrigtis used for type static analysis.
The documentation dependencies are in the requirement-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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ingredient_parser_nlp-0.1.0a2.tar.gz.
File metadata
- Download URL: ingredient_parser_nlp-0.1.0a2.tar.gz
- Upload date:
- Size: 720.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d62631c020cf833ccea9b32f042f1f317a7d6260a9acf1cd74b2927008a6c3e
|
|
| MD5 |
bd1fa9b90bcf857bb1a655d230aa8f07
|
|
| BLAKE2b-256 |
f8cf0f020601c5e6ba8f4f88d081df8f97c4418925183252938f8c4987116023
|
File details
Details for the file ingredient_parser_nlp-0.1.0a2-py3-none-any.whl.
File metadata
- Download URL: ingredient_parser_nlp-0.1.0a2-py3-none-any.whl
- Upload date:
- Size: 718.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8793b66ba1caef61ed716df5f18c12daa41fb542406bcceee3bba0d297a69a0
|
|
| MD5 |
708ade10725a4aae5a4a61a3c1ebb6b8
|
|
| BLAKE2b-256 |
ae6c154ffb517e7dc8f81f7a92fa58fb8136131f21e9bf11d0473363aa71b25d
|