Skip to content

feat: recognise cooking and packaging units in item descriptions - #1122

Open
jmylchreest wants to merge 1 commit into
TomBursch:mainfrom
jmylchreest:feat/units-vocabulary
Open

jmylchreest wants to merge 1 commit into
TomBursch:mainfrom
jmylchreest:feat/units-vocabulary

Conversation

@jmylchreest

@jmylchreest jmylchreest commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

The unit vocabulary is x, mg/g/kg and ml/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").

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
jmylchreest force-pushed the feat/units-vocabulary branch from 21c0435 to 77865c9 Compare July 31, 2026 20:06
@TomBursch TomBursch added the enhancement New feature or request label Aug 25, 2026

This branch has not been deployed

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants