A Python package to parse structured information from recipe ingredient sentences
Reason this release was yanked:
Incorrectly marked as compatible with Python 3.9
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.9988,
'unit': 0.9969,
'name': 0.9698,
'comment': 0.9992,
'other': 0}}
The returned dictionary has the format
{
"sentence": str,
"quantity": str,
"unit": str,
"name": str,
"comment": str,
"other": 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: 9448
Correct: 8189
-> 86.67%
Word-level results:
Total: 54854
Correct: 52509
-> 95.73%
Development
The development dependencies are in the requirements-dev.txt
file.
Note that development includes training the model.
Black
is used for code formatting.ruff
is used for linting.pyright
is used for type static analysis.pytest
is used for tests, withcoverage
being used for test coverage.
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
Hashes for ingredient_parser_nlp-0.1.0b2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dcdade68405942bdc2371833f4281f64bfefb6790dc1c0f9848982bea8be718 |
|
MD5 | 209570963e0c73293e4ca630664e7859 |
|
BLAKE2b-256 | 44776e1b40de1ef4bddf2c20b62fb980df50f2cfb15780331e2e1e14481add0d |
Hashes for ingredient_parser_nlp-0.1.0b2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d0146edf6c4209bc53cfcf95da615dc732a9e5f9c964ad20c5019adde720461 |
|
MD5 | ae2644231fdb4c3fc34a0abe0420a3be |
|
BLAKE2b-256 | 3b3e83d40131c1d7404e6f7815ee0b074207a1f3f054cbd70593dd0c6c56c321 |