Healthy-Dining Food Intelligence
Menu Parsing, Food Ontology & Nutrition Scoring
My Role
- Own DOM-homogeneity parser instead of per-site scrapers
- Food ontology breaking dishes into ingredients
- BERT entity linking to canonical ingredients
Approach at a Glance
Details- 1Universal Menu Parser: DOM Homogeneity Algorithm
- 2OCR for Non-HTML Menus
- 3Food Ontology
- 4BERT-Based Ingredient Entity Linking
- 5Nutrition Calculation and Health Scoring
- 6Dish Photo Recognition (Started)
Executive Summary
The food intelligence behind a healthy-eating app in the Estonian market. The app helps diners find restaurants and dishes that fit a healthy diet, with health scores per restaurant and dish. Its business model was hybrid: restaurants could also pay for promoted placement in the search results.
To make that work, the app had to know what was actually in every dish across the city's restaurants. I built the intelligence layer that turned scattered restaurant websites into structured, nutrition-aware data:
- A universal menu parser: my own algorithm, which extracts menus from any restaurant website by analysing the structure of the page.
- A food ontology: it breaks dishes down into ingredients.
- A BERT-based entity linker: it maps every ingredient mention to a canonical ingredient.
- A nutrition layer: it turns ingredients into calories and nutrients.
The pipeline recognised menu dishes with 95% accuracy, linked ingredients at 0.85 F1, and processed menus 4.1x faster than building per-site scrapers or entering menus by hand. The project ran from January to September 2022, before the LLM boom, and I was the only ML engineer in a startup team of 9+.
Client Profile
The client was a startup building a healthy-dining app for the Estonian market. Diners wanted to know which restaurants serve healthy food and what a given dish contains. Restaurants, for their part, could pay to be promoted to exactly those diners.
The data problem was hard on every level:
- No standard format: every restaurant publishes its menu differently. Some use custom websites, some use templates, and a few only post images or PDFs.
- No ingredient data: dish names and descriptions are free text in Estonian, English and Russian, and rarely list ingredients or nutrition facts. Estonian was the hardest, because NLP tooling and pretrained models for it were far scarcer than for English or Russian.
- No LLMs: this was 2022, so every step had to be solved with purpose-built algorithms and smaller models rather than one general model.
Technical Approach
-
Universal Menu Parser: DOM Homogeneity Algorithm – Instead of writing a scraper for every restaurant website, I designed an algorithm based on one hypothesis: the items of a menu share the same structure. Each dish on a page is rendered by the same, or almost the same, HTML pattern. The algorithm makes bottom-up and top-down passes through the page's DOM tree, finds groups of sibling elements that are structurally identical or very similar, and identifies the repeating block that forms the menu. From each item it extracts the dish name, description and price. Because it relies on structure rather than site-specific selectors, it works across website layouts and languages. That made menu processing 4.1x faster than per-site scrapers or manual entry.
-
OCR for Non-HTML Menus – For restaurants that only publish menus as images or PDFs, an OCR step turns them into text that enters the same pipeline.
-
Food Ontology – A purpose-built ontology models the domain: dishes, their typical ingredients, and the relationships between them. Dish names and descriptions are broken down into ingredients, even when the menu only says something like "chicken Caesar".
-
BERT-Based Ingredient Entity Linking – Ingredient mentions come in many forms and spellings, across Estonian, English and Russian. A BERT-based entity linking model maps each mention to a canonical ingredient in the ontology, at 0.85 F1. This is what makes ingredients comparable across restaurants and links each one to nutrition data.
-
Nutrition Calculation and Health Scoring – Linked ingredients are connected to nutrient values, so the system can estimate calories and nutrients per dish and compute the health scores the app shows for dishes and restaurants.
-
Dish Photo Recognition (Started) – We began work on recognising dishes from photos as an additional signal. The contract ended before this part went far.
Business Outcome
The healthy-dining app got what its whole proposition depended on: structured, nutrition-aware data for restaurant menus, collected automatically from the restaurants' own websites. Menu dishes were recognised with 95% accuracy, ingredients were linked at 0.85 F1, and menus were processed 4.1x faster than with per-site scrapers or manual entry. Diners could search for healthy dishes and restaurants, and restaurants could be promoted to exactly the audience that cared.
The universal menu parser is the most reusable result of the project: a structure-based way to pull repeating content out of any web page without hand-written rules for each site.
Technologies
Planning something similar?
Tell me about it on a short call. New projects can start within 2 weeks