File size: 2,422 Bytes
d0f45ac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
from transformers import pipeline
def generate_recommendations(party_on_weekends, flavor_preference, texture_dislike, price_range):
# Define the list of ingredients
ingredients = ["oranges", "apples", "pears", "grapes", "watermelon", "lemon", "lime"]
# Apply the rules based on user answers
allowed_fruits = ingredients.copy()
if party_on_weekends == "yes":
allowed_fruits = list(set(allowed_fruits) & set(["apples", "pears", "grapes", "watermelon"]))
if flavor_preference == "cider":
allowed_fruits = list(set(allowed_fruits) & set(["apples", "oranges", "lemon", "lime"]))
elif flavor_preference == "sweet":
allowed_fruits = list(set(allowed_fruits) & set(["watermelon", "oranges"]))
elif flavor_preference == "waterlike":
allowed_fruits = list(set(allowed_fruits) & set(["watermelon"]))
if "grapes" in allowed_fruits:
allowed_fruits.remove("watermelon")
if texture_dislike == "smooth":
if "pears" in allowed_fruits:
allowed_fruits.remove("pears")
elif texture_dislike == "slimy":
slimy_fruits = ["watermelon", "lime", "grapes"]
allowed_fruits = list(set(allowed_fruits) - set(slimy_fruits))
elif texture_dislike == "waterlike":
if "watermelon" in allowed_fruits:
allowed_fruits.remove("watermelon")
if price_range < 3:
if "lime" in allowed_fruits:
allowed_fruits.remove("lime")
if "watermelon" in allowed_fruits:
allowed_fruits.remove("watermelon")
elif 4 < price_range < 7:
if "pears" in allowed_fruits:
allowed_fruits.remove("pears")
if "apples" in allowed_fruits:
allowed_fruits.remove("apples")
return allowed_fruits
def main():
# Take user input for each question
party_answer = input("Do you go out to party on weekends? (yes or no): ").lower()
flavor_answer = input("What flavors do you like? (cider, sweet, waterlike): ").lower()
texture_answer = input("What texture do you dislike? (smooth, slimy, waterlike): ").lower()
price_answer = int(input("What price range will you buy a drink for? ($1-$10): "))
# Call the function with user inputs
recommendations = generate_recommendations(party_answer, flavor_answer, texture_answer, price_answer)
print("Recommended fruits:", recommendations)
if __name__ == "__main__":
main()
|