2.0.0
2.0.0
Caution
This release contains some breaking changes
-
ParsedIngredient.nameis now a list ofIngredientTextobjects, or an empty list no name is identified. -
The
quantity_fractionsoptional keyword argument has been removed.IngredientAmount.quantityandIngredientAmount.quantity_maxreturnfractions.Fractionobjects. Conversion tofloatcan be achieved by e.g.:# Round to 3 decimal places round(float(quantity), 3)
-
New dependency: floret.
Processing
-
Identify where multiple alternative ingredients are given for the stated amount. For example
# Simple example >>> parse_ingredient("2 tbsp butter or olive oil").name [ IngredientText(text='butter', confidence=0.983045, starting_index=2), IngredientText(text='olive oil', confidence=0.930385, starting_index=4) ] # Complex example >>> parse_ingredient("2 cups chicken or beef stock").name [ IngredientText(text='chicken stock', confidence=0.776891, starting_index=2), IngredientText(text='beef stock', confidence=0.94334, starting_index=4) ]
This is enabled by default, but can be disabled by setting
separate_ingredients=Falseinparse_ingredient. If disabled, theParsedIngredient.namefield will be listing containing a singleIngredientTextobject. -
Set
PREPARED_INGREDIENTflag on amounts in cases like... to yield 2 cups ...
-
Add
convert_to(...)function toIngredientAmountandCompositeIngredientAmountdataclasses to convert the amount to the given units. Conversion between mass and volume is also supported using a default density (density of water) that can be changed.>>> p = parse_ingredient("1 8 ounce can chopped tomatoes") >>> # Convert "8 ounce" to grams >>> p.amount[1].convert_to("g") IngredientAmount(quantity=Fraction(5669904625000001, 25000000000000), quantity_max=Fraction(5669904625000001, 25000000000000), unit=<Unit('gram')>, text='226.80 gram', confidence=0.999051, starting_index=1, APPROXIMATE=False, SINGULAR=True, RANGE=False, MULTIPLIER=False, PREPARED_INGREDIENT=False) >>> # Cannot convert where the quantity or unit is a string >>> p.amount[0].convert_to("g") TypeError: Cannot convert where quantity or unit is a string.
Model
- Include custom word embeddings as features used by the model. This requires a new dependency of the floret library.