A Python package to parse structured information from recipe ingredient sentences
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: 8017
-> 86.42%
Word-level results:
Total: 53495
Correct: 51379
-> 96.04%
Development
The development dependencies are in the requirements-dev.txt
file.
Note that development includes training the model.
-
Black
is used for code formatting. -
isort
is used for import sorting. -
flake8
is used for linting. Note the line length standard (E501) is ignored. -
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.0a4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2761e1a480166b1171da757a48a3dac6bed870b20ce85e73880229ba1991bebc |
|
MD5 | b11c107d069eba656abee009293e94c7 |
|
BLAKE2b-256 | 0507dc579c0fad8425d5ab2907e6396417bfc9fdc13243f27c483ff87cc1f1b0 |
Hashes for ingredient_parser_nlp-0.1.0a4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9a4309038efb8ae2cbec3f1b37984db730e6e2c4551546efe332ce75ccde0d1 |
|
MD5 | a3ae5e769be92359a7adca0fb2e42364 |
|
BLAKE2b-256 | b472cbd263ae45c02a4af5f147c4e88364c840f1a1b10734e22ae7ebee5e33d0 |