HackatonSmall / modules /recommender.py
Crocolil's picture
Upload folder using huggingface_hub
73921fc verified
Raw
History Blame Contribute Delete
1.28 kB
def generate_care_notes(plant_info: dict, plant_name: str | None = None, genus: str | None = None) -> str:
"""Build a short care note from CSV-derived plant metadata (rule-based, no model).
Args:
plant_info: Care metadata (watering_frequency_days, sunlight, soil, fertilization_type).
plant_name: Common plant name, if known.
genus: Genus name, if known.
Returns:
A short care note assembled from simple templates.
"""
subject = plant_name or genus or "This plant"
sentences = []
sunlight = plant_info.get("sunlight")
if sunlight:
sentences.append(f"{subject} needs {sunlight}.")
soil = plant_info.get("soil")
if soil:
sentences.append(f"It thrives in {soil} soil.")
watering = plant_info.get("watering_frequency_days")
if watering:
sentences.append(f"{watering}.")
fertilization = plant_info.get("fertilization_type")
if fertilization and str(fertilization).strip().lower() not in ("no", "none", ""):
sentences.append(f"Feed it with {str(fertilization).lower()} fertilizer.")
else:
sentences.append("No fertilizer is needed for this plant.")
return " ".join(sentences) if sentences else f"No care information available for {subject}."