# input输入 韭菜 鸡蛋 土豆 马铃薯 豆腐
结果 …
# 机器人的回答是关键词预设,遇到没有预设的前提就!
def generate_food_associations(keywords):
associations = []
for keyword in keywords:
if keyword == '韭菜':
associations.extend(['韭菜盒子', '韭菜炒鸡蛋', '韭菜水饺', '韭菜炒豆芽', '韭菜烙'])
elif keyword == '鸡蛋':
associations.extend(['蛋炒饭', '水煮蛋', '蛋包饭', '鸡蛋羹', '蛋黄酥'])
elif keyword == '土豆' or keyword == '马铃薯':
associations.extend(['土豆泥', '炖土豆牛肉', '炸土豆片', '土豆烧鸡', '土豆沙拉'])
elif keyword == '豆腐':
associations.extend(['香辣豆腐', '豆腐汤', '麻婆豆腐', '蒸豆腐', '豆腐皮'])
return associations
user_input = input("请输入关键词,用空格分隔:")
keywords = user_input.split()
associations = generate_food_associations(keywords)
print("关键词联想:")
for association in associations:
print(association)