Skip to content

For issue #42 - #44

Merged
strangetom merged 2 commits into
strangetom:developfrom
mcioffi:2.4.0-issue-42
Nov 11, 2025
Merged

For issue #42#44
strangetom merged 2 commits into
strangetom:developfrom
mcioffi:2.4.0-issue-42

Conversation

@mcioffi

@mcioffi mcioffi commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

Fixes

TL;DR — Addresses #42

  • Now accounts for both CompositeIngredientAmount and IngredientAmount in webapp parser
  • Makes flask's jsonify more context aware for Fraction/Unit by extending Flask's DefaultJSONProvider

- [x] Accounts for CompositeIngredientAmount in webapp parser
- [x] Makes flask's jsonify more context aware for Fraction/Unit
@strangetom

Copy link
Copy Markdown
Owner

Thanks @mcioffi.

Is it possible to visually associate the parts of a CompositeIngredientAmount when displaying to show that they are associated? The subtractive attribute of CompositeIngredientAmount might be helpful in deciding how display it.

@mcioffi

mcioffi commented Nov 7, 2025

Copy link
Copy Markdown
Contributor Author

Does a tooltip suffice? Tooltips/badges are currently used in the parser table for amounts, e.g. singular [1], prepared ingredient [P], approximate [~], and can do something similar for composites, if you have a chararcter or symbol in mind, e.g. composite ingredient [C].

Because the list is decomposed down to just a list of IngredientAmount when passed back from server to client, I have to find a way to identify it as being part of CompositeIngredientAmount. Do you know if there is ever a scenario where a parsed sentence has a combo of IngredientAmount and CompositeIngredientAmount, or do they all just roll up to CompositeIngredientAmount. Any example ingredient sentences for that scenario if it holds?

Screenshot 2025-11-07 at 9 24 26 AM

@strangetom

Copy link
Copy Markdown
Owner

It is possible to have a mixture of CompositeIngredientAmounts and IngredientAmounts, for example

1/4 cup plus 1 tablespoon (25 g) unsweetened dark cocoa powder

What is you continued decomposing to IngredientAmounts but grouped them where they're part of a CompositeIngredientAmount e.g.

[
   [
      IngredientAmount(),
      IngredientAmount()
   ],
   IngredientAmount()
]

and then any sublists with more than 1 item would indicate that they're associated.

@mcioffi

mcioffi commented Nov 10, 2025

Copy link
Copy Markdown
Contributor Author

Does this suffice from visual perspective on the parser table?

Screenshot 2025-11-10 at 1 38 22 PM

@strangetom

Copy link
Copy Markdown
Owner

That looks like it will work fine 👍

@mcioffi

mcioffi commented Nov 11, 2025

Copy link
Copy Markdown
Contributor Author

Should be ready to test. I had been trying to get the parser to return both a CompositeIngredient with some other badges that identify attributes like singular, prepared, or approximate to see if the different badges/tooltips render correctly alongside each other. I tried the following, but the prepared ingredient gets lost when composite ingredients are identified. It might be a syntax that the trainer hasn't seen before in this context, but figured to show an example.

Has prepared ingredient
3 cups (750 ml) strained beef or vegetable stock
Screenshot 2025-11-11 at 8 56 32 AM

Adds composite ingredient syntax to prepared ingredient sentence
3 cups (750 ml) plus 0.2 cups (47 ml) strained beef or vegetable stock
Screenshot 2025-11-11 at 8 56 24 AM

@strangetom

Copy link
Copy Markdown
Owner

Thanks, that seems like it works fine.

The flags are set during the post-processing based on patterns of labels and tokens. 3 cups (750 ml) plus 0.2 cups (47 ml) strained beef or vegetable stock does not contain a supported pattern, but something like 3 cups plus 0.2 cups (797 ml) strained beef or vegetable stock does work:
image

It does look like there could some improvements here. About 3 cups plus 0.2 cups (797 ml) strained beef or vegetable stock should have the amounts flagged as approximate, but doesn't.

@strangetom
strangetom merged commit f4103d8 into strangetom:develop Nov 11, 2025
4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants