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

Amount dropped with mark in loose parser #10

Closed
wvengen opened this issue Sep 25, 2018 · 2 comments
Closed

Amount dropped with mark in loose parser #10

wvengen opened this issue Sep 25, 2018 · 2 comments
Labels
bug:parsing Something is not parsed or parsed incorrectly parser:loose Affects the loose parser

Comments

@wvengen
Copy link
Member

wvengen commented Sep 25, 2018

$ bin/food_ingredient_parser --version
food_ingredient_parser v1.1.1
$ bin/food_ingredient_parser -r loose -s "foo 50%"
foo 50%
{:contains=>[{:name=>"foo", :amount=>"50%"}]}
$ bin/food_ingredient_parser -r loose -s "foo* 50%"
foo* 50%
{:contains=>[{:name=>"foo", :marks=>["*"]}]}
@wvengen wvengen added the bug Something isn't working label Sep 25, 2018
@wvengen
Copy link
Member Author

wvengen commented Sep 25, 2018

This is because the parser currently omits everything from the name after a nesting or mark (if there already is a name). This can be improved by allowing multiple nodes for the name.

@wvengen wvengen added parser:loose Affects the loose parser bug:parsing Something is not parsed or parsed incorrectly and removed bug Something isn't working labels Sep 25, 2018
@wvengen
Copy link
Member Author

wvengen commented May 31, 2024

Note that Transform::Amount.transform! extracts the amounts from ingredient names in the loose parser. The mark is extracted in the parser itself, so it effectively 'splits' the name, hence this issue.

wvengen added a commit that referenced this issue May 31, 2024
This allows the loose parser to include parts of the name before and
after other things like mark, amount or children.

In "cheese (MILK) with 2.3% fat" the whole ingredient name is now
included. Also things like "foo* 50%" now recognize the amount.
@wvengen wvengen closed this as completed May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:parsing Something is not parsed or parsed incorrectly parser:loose Affects the loose parser
Projects
None yet
Development

No branches or pull requests

1 participant