""" Generaciรณn del output en formato Markdown. """ import time from typing import Dict, List from config import DEVICE, OCR_MODEL_ID, TRANSLATION_MODEL_ID, DESCRIPTION_MODEL_ID SECTION_EMOJIS = { "entrantes": "๐Ÿฅ—", "starters": "๐Ÿฅ—", "principales": "๐Ÿ–", "main": "๐Ÿ–", "postres": "๐Ÿฐ", "desserts": "๐Ÿฐ", "bebidas": "๐Ÿท", "drinks": "๐Ÿท", } CULTURAL_NOTES = """## โ„น๏ธ CULTURAL NOTES **About Spanish Dining:** Spanish meals are social events meant to be enjoyed slowly. Lunch (comida) is typically served 2-4 PM, dinner (cena) after 9 PM. Sharing dishes (tapas style) is common and encouraged. **Regional Diversity:** Spain's cuisine varies dramatically by region - from seafood in Galicia to paella in Valencia, each area has unique specialties reflecting local ingredients and traditions. """ def _get_section_emoji(section_name: str) -> str: for key, emoji in SECTION_EMOJIS.items(): if key in section_name.lower(): return emoji return "๐Ÿฝ๏ธ" def generate_markdown( dishes: List[Dict], target_lang: str, include_cultural_notes: bool, ) -> str: """Genera output en formato Markdown estructurado.""" # Agrupar por secciรณn sections: Dict[str, List[Dict]] = {} for dish in dishes: sections.setdefault(dish["section"], []).append(dish) # Header md = f"""# ๐Ÿ‡ช๐Ÿ‡ธ Spanish Menu โ€” Cultural Guide **Generated:** {time.strftime('%Y-%m-%d %H:%M:%S')} **Target Language:** {target_lang} **Total Items:** {len(dishes)} dishes --- ## ๐Ÿ“Š MENU SUMMARY - **Sections:** {len(sections)} - **Dishes Processed:** {len(dishes)} """ prices = [d["price"] for d in dishes if d.get("price")] if prices: md += f"- **Price Range:** {min(prices)} - {max(prices)}\n" md += "\n---\n\n" # Secciones de platos for section_name, section_dishes in sections.items(): emoji = _get_section_emoji(section_name) md += f"## {emoji} {section_name.upper()}\n\n" for dish in section_dishes: md += f"### {dish['name']}\n\n" md += f"**๐Ÿ’ฐ Price:** {dish['price']}\n\n" md += f"**๐Ÿ“ Description:** \n{dish['description']}\n\n" md += "---\n\n" # Notas culturales if include_cultural_notes: md += CULTURAL_NOTES # Footer md += f"""--- ## ๐Ÿ” PROCESSING DETAILS - **OCR Model:** {OCR_MODEL_ID} - **Translation Model:** {TRANSLATION_MODEL_ID} - **Description Model:** {DESCRIPTION_MODEL_ID} - **Device:** {DEVICE.upper()} *Generated with โค๏ธ by Spanish Menu Translator* """ return md