- 
                Notifications
    
You must be signed in to change notification settings  - Fork 17
 
Open
Description
Attempting to parse sentences such as "1 cup plus 2 tablespoons olive oil" results in HTTP 500 error with the traceback:
Traceback (most recent call last):
  File "/home/tom/Recipes/ingredient-parser/webtools/app.py", line 190, in parser
    quantity=str(amount.quantity),
                 ^^^^^^^^^^^^^^^
AttributeError: 'CompositeIngredientAmount' object has no attribute 'quantity'This is because the amount parsed is returned as a CompositeIngredientAmount object:
[CompositeIngredientAmount(amounts=[IngredientAmount(quantity=Fraction(1, 1),
                                                     quantity_max=Fraction(1, 1),
                                                     unit=<Unit('cup')>,
                                                     text='1 cup',
                                                     confidence=0.999822,
                                                     starting_index=0,
                                                     APPROXIMATE=False,
                                                     SINGULAR=False,
                                                     RANGE=False,
                                                     MULTIPLIER=False,
                                                     PREPARED_INGREDIENT=False),
                                    IngredientAmount(quantity=Fraction(2, 1),
                                                     quantity_max=Fraction(2, 1),
                                                     unit=<Unit('tablespoon')>,
                                                     text='2 tablespoons',
                                                     confidence=0.997124,
                                                     starting_index=3,
                                                     APPROXIMATE=False,
                                                     SINGULAR=False,
                                                     RANGE=False,
                                                     MULTIPLIER=False,
                                                     PREPARED_INGREDIENT=False)],
                           join=' plus ',
                           subtractive=False,
                           text='1 cup plus 2 tablespoons',
                           confidence=0.9984729999999999,
                           starting_index=0)]The webtools parser should be fixed to support amounts returned as ComposteIngredientAmount objects.
mcioffi
Metadata
Metadata
Assignees
Labels
No labels