Skip to content

Comments

Fix: unparsed ingredients poorly formatted when fed to NLP parser#7086

Open
gabrielclimb wants to merge 4 commits intomealie-recipes:mealie-nextfrom
gabrielclimb:fix/ingredient-parser-unparsed-string
Open

Fix: unparsed ingredients poorly formatted when fed to NLP parser#7086
gabrielclimb wants to merge 4 commits intomealie-recipes:mealie-nextfrom
gabrielclimb:fix/ingredient-parser-unparsed-string

Conversation

@gabrielclimb
Copy link

Summary

  • Fixes [BUG] - Unparsed ingredients with quantities are poorly formatted when fed to NLP #7079
  • Unparsed ingredients with a default quantity of 1 and the full text in the note field (e.g. "1/2 cup apples") were being reconstructed as "1 1/2 cup apples", causing the NLP parser to misinterpret the quantity
  • Added ingredientToParserString() that prefers originalText, falls back to just the note for unparsed ingredients (no unit/food), and only uses the full reconstruction for properly parsed ingredients

Test plan

  • Existing tests pass
  • New unit tests for ingredientToParserString covering unparsed, originalText, parsed, and empty cases
  • Manual test: create recipe with unparsed ingredient (qty=1, note="1/2 cup apples"), open parse dialog, verify NLP receives "1/2 cup apples"

@alexxxxxxxxxxandria
Copy link
Contributor

Apologies that I can't just contribute this directly right now, but I recommend also adding tests for items that are less ambiguous. The "1/2 cup apples" was my go-to because you could get a fraction you wouldn't expect, but another example was "2 tbsp olive oil" being reconstructed as "1 2 tbsp olive oil" and then being parsed as "1 tbsp olive oil"

@gabrielclimb
Copy link
Author

Apologies that I can't just contribute this directly right now, but I recommend also adding tests for items that are less ambiguous. The "1/2 cup apples" was my go-to because you could get a fraction you wouldn't expect, but another example was "2 tbsp olive oil" being reconstructed as "1 2 tbsp olive oil" and then being parsed as "1 tbsp olive oil"

Ok, I will add this

@gabrielclimb
Copy link
Author

@alexxxxxxxxxxandria , could you take another look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] - Unparsed ingredients with quantities are poorly formatted when fed to NLP

2 participants