# NutriRival's copy of Open Food Facts: alterations This is the alteration file the Open Database License asks for (ODbL v1.0 §4.6 b): it describes how NutriRival's derivative database is made from Open Food Facts. It is published at https://nutririval.com/off-alterations.txt, linked from https://nutririval.com/data. The scripts named below are available on request at support@nutririval.com. **Source:** the official Open Food Facts Parquet export (Hugging Face, `openfoodfacts/product-database`, `food.parquet`), as read on 30 October 2026 (the export of October 2026). **Licence** of the source and of this derivative database: Open Database License v1.0 (https://opendatacommons.org/licenses/odbl/1-0/); the contents: Database Contents License v1.0. © Open Food Facts contributors (https://world.openfoodfacts.org). The product images (CC BY-SA) are not read. **Result:** the table `off_products` (3,471,894 products of about 4.8 million in the export) and the table `off_words` (a spelling dictionary of their names and brands), both on NutriRival's Supabase project, read by the app's food search and barcode scanner. A dump of either table is available on request at support@nutririval.com (§4.6 a). The derivative database is produced by the scripts in this folder: `export.py` (with `names.py`), `load.sh`, `words.py` (with `words.sh`), and the table definitions in `supabase/off_products_table.sql` and `supabase/off_words.sql`. In detail: ## 1. Which products are kept (`export.py`) A product is kept when it is not marked obsolete, has a name (after the tidying below) and an energy value between 0 and 900 kcal per 100 g (after the kJ correction below), and is sold in one of the app's regions or has no country given. The regions are the country lists in `export.py` (`REGIONS`: Europe, North America, Latin America, Asia, Middle East & Africa, Oceania); `en:world` and a product with no `countries_tags` count as region 0, shown everywhere. Products still contradicting themselves after the corrections of §4, or with more than 100 g of any macronutrient (or 105 g of the three together) per 100 g, are dropped. When a barcode appears more than once in the export, the most scanned entry is kept (`load.sh`). ## 2. Which columns are kept Read from the export: `code`, `lang`, `obsolete`, `product_name` (every language), `brands`, `brands_tags`, `countries_tags`, `serving_size`, `serving_quantity`, `unique_scans_n`, `nutriments`, `product_quantity_unit`, `quantity`. Written to `off_products`: `code`, `lang`, `name` (the main name, else the product's own language's, else the first), `name_en`, `name_fr`, `name_nl`, `name_de`, `name_es` (only when they differ from `name`), `brands`, `brands_tags` (as plain slugs, a language prefix removed), `regions` (the region numbers above), `serving_size` (cut at 60 characters), `serving_quantity` (the first number of the export's value), `scans` (`unique_scans_n`), `kcal`, `liquid`, and per 100 g: `protein`, `carbs`, `fat`, `fiber`, `sugars`, `sodium`, `sat_fat`, `trans_fat`, `mono_fat`, `poly_fat`, `cholesterol`, `calcium`, `iron`, `potassium`, `magnesium`, `zinc`, `phosphorus`, `vit_c`, `vit_a`, `vit_d`, `vit_b6`, `vit_b12`, `folates` (from the export's `nutriments` `100g` values: `proteins`, `carbohydrates`, `fat`, `fiber`, `sugars`, `sodium`, `saturated-fat`, `trans-fat`, `monounsaturated-fat`, `polyunsaturated-fat`, `cholesterol`, `calcium`, `iron`, `potassium`, `magnesium`, `zinc`, `phosphorus`, `vitamin-c`, `vitamin-a`, `vitamin-d`, `vitamin-b6`, `vitamin-b12`, `folates`), and `search_text`: the distinct words of the names and brands, lower-cased, accents stripped (œ → oe, æ → ae, ß → ss), anything but a–z and 0–9 replaced by a space. The table itself adds a full-text index on `search_text`. No other field (categories, ingredients, labels, images, scores…) is read. ## 3. How names are tidied (`names.py`) Each name (the main one and each language's): HTML entities decoded (repeatedly, some were escaped several times); UTF-8 read as Windows-1252 put back ("français" → "français"); invisible characters removed; runs of spaces, underscores and non-breaking spaces made one space; " - " normalised; leading and trailing punctuation removed (a trailing "." stays); an unclosed bracket cut off at the end removed with its text; a name with no letters (a barcode, ".", "???"), a placeholder ("Product", "Unknown", "Food", "N/A"…) or a bare quantity ("500g", "75 CL") is dropped, so the next language's name is taken or the product goes; an all-lowercase name gets a capital to start. Names are cut at 200 characters. Names in other languages and scripts are left as written. ## 4. How the numbers are corrected (`export.py`; the same rule as the app's `src/services/consistency.ts`) - Energy: `energy-kcal`, else `energy` ÷ 4.184; a value over 900 kcal per 100 g is read as kJ typed as kcal and divided by 4.184. - Numbers that contradict each other (protein and fat alone give more kcal than stated, or all the macros give nearly double the stated kcal unless carbohydrates are nearly all of it) are put right where the mistake has a shape: the energy typed in kJ (× 4.184), the macros of a serving (every nutrient back to 100 g by the serving size), else the kcal recomputed from the macros (4 kcal/g protein and carbohydrates, 9 fat, 2 fibre). - Minerals and vitamins above what any food holds (`MICRO_CAPS` in `export.py`, grams per 100 g) are read as mg or µg typed as g when that fits (÷ 1,000 or ÷ 1,000,000), else dropped. - A part larger than its whole (sugars of carbohydrates; saturated, trans, mono- and polyunsaturated of fat, with 5% + 0.5 g of slack), a negative value and a fibre over 90 g are dropped (set unknown). - A serving quantity outside 1 g – 2,000 g is dropped. - `liquid` is derived: true when the pack's unit is ml, or the quantity or serving size is written in ml, cl, dl or l. ## 5. The words table (`words.py`, `off_words`) Every word of 3–30 letters in the kept products' `search_text` with the number of products holding it, plus the words of the app's verified generic foods (ANSES-Ciqual names in 5 languages) and of the restaurant chains' menu names, each counted 5 and marked `food` (never corrected). Words held by a single product are left out. The app's `spell_query()` uses it to correct a typo to a far more common word. ## 6. Refreshing The copy is rebuilt whole from a new export about monthly (`scripts/off-products/README.md`); every rule above is applied again, nothing is edited by hand on the server. Changes to these rules are made in the scripts and so in this file's description of them.