feat: recognise cooking and packaging units in item descriptions - #1122
Open
jmylchreest wants to merge 1 commit into
Open
jmylchreest wants to merge 1 commit into
jmylchreest wants to merge 1 commit into
Conversation
The unit vocabulary was x, mg/g/kg and ml/l, so anything else was read as part of the item name: "2 tbsp olive oil" became an item literally named "tbsp olive oil", sitting alongside "olive oil" in the same household. Imperial and packaging units now parse, along with the "2 cans of beans" construction, so the name is just the food. The vocabulary moves to app/util/units.py because the splitter and merger each carried their own copy of it. The merger folds plurals, so "1 tin" and "2 tins" add up instead of listing separately. Units are deliberately only converted within the SI families. A cup and a pint mean different things either side of the Atlantic, so those merge only with themselves rather than guessing. Word units keep the space they had as free text: "3 tins", but "500g".
jmylchreest
force-pushed
the
feat/units-vocabulary
branch
from
July 31, 2026 20:06
21c0435 to
77865c9
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The unit vocabulary is
x,mg/g/kgandml/l, so anything else ends up in the item name. "2 tbsp olive oil" becomes an item called "tbsp olive oil", sitting alongside "olive oil".Adds imperial and packaging units, plus the "2 cans of beans" form, so the name is just the food. Word boundaries are enforced, so "canned tomatoes", "boxing gloves" and "offal" are untouched.
The vocabulary moves to
app/util/units.py. The merger now folds plurals, so "1 tin" and "2 tins" add up.Units are only converted within the SI families. A cup and a pint are not the same, so they merge only with themselves.
One existing expectation changes:
"1 bag of Kartoffeln"now splits to("Kartoffeln", "1 bag")rather than("bag of Kartoffeln", "1").