
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Parses unstructured recipe ingredient text into standardized quantities, units, and foods
Python 📦 package for extracting quantities, units, and food words from unstructured recipe ingredients text.
ingredient-slicer
works by standardizing the input text and then applying a set of rules and heuristic methods to parse out quantities, units, and food words from unstructured recipe ingredients text.
ingredient-slicer
was designed to provide a robust and lightweight method for parsing recipe ingredients
text without relying on any external dependencies or NLP/ML models.
That being said, it is not perfect and can always be improved upon.
ingredient_slicer
can be downloaded from PyPI via pip
like so:
pip install ingredient-slicer
Provide a string to the IngredientSlicer
class and thats it. Invoke the to_json()
method to return the parsed ingredient.
import ingredient_slicer
slicer = ingredient_slicer.IngredientSlicer("2 (15-ounces) cans chickpeas, rinsed and drained")
slicer.to_json()
{
'ingredient': '2 (15-ounces) cans chickpeas, rinsed and drained',
'standardized_ingredient': '2 cans chickpeas, rinsed and drained',
'food': 'chickpeas',
# primary quantity and units
'quantity': '30',
'unit': 'ounces',
'standardized_unit': 'ounce',
# any other secondary quantity and units found in the string
'secondary_quantity': '2',
'secondary_unit': 'cans',
'standardized_secondary_unit': 'can',
'gram_weight': '850.49',
'prep': ['drained', 'rinsed'],
'size_modifiers': [],
'dimensions': [],
'is_required': True,
'parenthesis_content': ['15 ounce']
}
Individual ingredient components can also be found using methods like food()
, quantity()
, or unit()
import ingredient_slicer
slicer = ingredient_slicer.IngredientSlicer("3 tbsp unsalted butter, softened at room temperature")
slicer.food()
>>> 'unsalted butter'
slicer.quantity()
>>> '3'
slicer.unit()
>>> 'tbsp'
slicer.standardized_unit()
>>> 'tablespoon'
slicer.prep()
>>> ['room temperature', 'softened']
If you find a bug or have an idea for a new feature, please open an issue or submit a pull request :)
FAQs
Parses unstructured recipe ingredient text into standardized quantities, units, and foods
We found that ingredient-slicer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.