| """Shared paths and constants for the NutriWeb data pipeline. |
| |
| The pipeline runs offline on a workstation. It reads the full Open Food Facts |
| parquet (~7.8 GB) and emits a compact DuckDB catalog that the Streamlit app on |
| Hugging Face Spaces downloads at startup. |
| """ |
|
|
| from pathlib import Path |
|
|
| |
| SOURCE_REPO = "openfoodfacts/product-database" |
| SOURCE_FILE = "food.parquet" |
|
|
| |
| REPO_ROOT = Path(__file__).resolve().parent.parent |
| DATA_DIR = REPO_ROOT / "data" |
| CATALOG_PATH = DATA_DIR / "nutriweb-us.duckdb" |
|
|
| |
| |
| |
| COUNTRY_TAG = "en:united-states" |
|
|
| |
| |
| NUTRIENT_MAP = { |
| "energy-kcal": "energy_kcal_100g", |
| |
| "energy-kj": "energy_kj_100g", |
| "fat": "fat_100g", |
| "saturated-fat": "saturated_fat_100g", |
| "carbohydrates": "carbohydrates_100g", |
| "sugars": "sugars_100g", |
| "fiber": "fiber_100g", |
| "proteins": "proteins_100g", |
| "salt": "salt_100g", |
| "sodium": "sodium_100g", |
| |
| |
| |
| "fruits-vegetables-legumes-estimate-from-ingredients": "fruits_veg_legumes_100g", |
| "fruits-vegetables-nuts-estimate-from-ingredients": "fruits_veg_nuts_100g", |
| } |
|
|
| |
| |
| KJ_PER_KCAL = 4.184 |
|
|
| |
| SALT_PER_SODIUM = 2.5 |
|
|
| |
| |
| |
| MACRO_COLUMNS = [ |
| "energy_kcal_100g", |
| "fat_100g", |
| "saturated_fat_100g", |
| "carbohydrates_100g", |
| "sugars_100g", |
| "fiber_100g", |
| "proteins_100g", |
| "salt_derived", |
| ] |
|
|
| |
| |
| |
| DISQUALIFYING_QUALITY_ERRORS = [ |
| "en:nutrition-value-total-over-105", |
| "en:nutrition-value-negative-energy", |
| "en:nutrition-value-negative-fat", |
| "en:nutrition-value-negative-carbohydrates", |
| "en:nutrition-value-negative-proteins", |
| "en:nutrition-value-negative-sugars", |
| "en:nutrition-value-negative-salt", |
| "en:energy-value-in-kcal-does-not-match-value-computed-from-other-nutrients", |
| ] |
|
|