def generate_random_toy_name()

in data-analytics/next25-turbocharge-ecomm/generate_and_publish_image.py [0:0]


def generate_random_toy_name() -> str:
    """
    Generates a random, child-friendly toy name. Includes "toy".
    """
    materials = [
        "wooden", "plush", "plastic", "soft", "colorful",
        "musical", "interactive", "stacking", "rolling", "cuddly",
    ]
    animals = [
        "bear", "dog", "cat", "rabbit", "lion", "elephant",
        "monkey", "giraffe", "penguin", "parrot", "duck",
        "fish", "horse", "puppy", "kitten", "bunny"
    ]
    objects = [
        "train", "blocks", "car", "truck", "puzzle",
        "doll", "boat", "plane", "rattle", "stacker", "xylophone",
    ]
    descriptors = [
        "with tracks", "for building", "for cuddling", "that sings",
        "with lights", "for learning", "",  # Empty string for no extra descriptor
        "set", "and friends"
    ]

    material = random.choice(materials)
    # Choose animal or object, not both.
    if random.random() < 0.6:  # 60% chance of an object
        item = random.choice(objects)
        animal = ""
    else:  # 40% chance of animal
        item = ""
        animal = random.choice(animals)

    descriptor = random.choice(descriptors)

    # Construct the name, handling different combinations logically.
    if item:
        name = f"{material} toy {item} {descriptor}"
    elif animal:
        name = f"{material} {animal} toy {descriptor}"
    else:  # Edge Case
        name = f"{material} toy"

    # Clean up extra spaces and capitalize.
    name = " ".join(name.split()).title()
    return name