Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative ingredients #27

Open
icaliman opened this issue Nov 8, 2024 · 2 comments
Open

Alternative ingredients #27

icaliman opened this issue Nov 8, 2024 · 2 comments

Comments

@icaliman
Copy link

icaliman commented Nov 8, 2024

Thanks for working on this library!

I want to ask a question about alternative ingredients.

In the documentation you have these examples:

  • 3 tablespoons butter or olive oil, or a mixture should have the name as butter or olive oil
  • 4 shoots spring shallots or 4 shallots, minced should have the name as spring shallots and the comment as or 4 shallots, minced because there are different quantities of spring shallots to shallots.

Is it possible to change the behavior and return a list with ingredients, something similar to CompositeIngredientAmount?

For example 3 tablespoons butter or olive oil, or a mixture can be split into two alternative ingredients:

AlternativeIngredient(
    ingredients=[
        ParsedIngredient(
            name=IngredientText(text='butter', ...),
            ...
        ),
        ParsedIngredient(
            name=IngredientText(text='olive oil', ...),
            ...
        ),
    ]
)

What do you think about this?

@strangetom
Copy link
Owner

Hi @icaliman

Thanks for the suggestion. This is something I've been thinking about for a while now but haven't got round to.

I think the two examples you used show two cases:

  1. 3 tablespoons butter or olive oil, or a mixture has multiple ingredients with the same amounts. We could return something like
ParsedIngredient(
    name=AlternativeIngredients(ingredients=[
        IngredientText(text="butter", ...),
        IngredientText(text="olve oil", ...),
    ]),
    ...
)

This should be fairly straightforward to do.

  1. 4 shoots spring shallots or 4 shallots, minced is a bit more complex because we would need to return two ParsedIngredient objects, as you show in your example. I'm not sure how to do this yet.

@strangetom
Copy link
Owner

This is proving to be more difficult than I first thought. The problem is working out how to handle sentences where the name of the ingredient is split.

3 tablespoons butter or olive oil, or a mixture

This sentence is straightforward to handle by splitting on the conjunction or.

1 large red or yellow pepper

This kind of sentence is a more difficult because I think we would want the output to be red pepper and yellow pepper. We could use the fact that red and yellow are adjectives and pepper is a noun to work out how to combine red and pepper, but this only works in a few cases e.g.

1 cup beef or chicken stock

Again, we would want to extract beef stock and chicken stock, but all the tokens are nouns which doesn't help much.

This problem is the same as one of the limitations of the foundation foods functionality, so the same solution should work for both. I have an idea for changing the model used for the foundation foods to work for this too, but it involves changing the token labelling scheme which is going to be very time consuming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants