问题描述
python chatterbot库提供了convo.txt下面的数据集
output.txt
或在对此数据集进行训练时,与下面的数据集(yml)配合使用
当调用get_response('hey')时,仅给出1和2,为什么呢?以及当用户键入“嘿”时如何获得多个响应,我希望它随机生成“嘿1嘿2”和“嘿3”之间
解决方法
使用语料库训练器,它比文本文件要好得多,并且每次都要删除数据库以确保获得正确的输出。
print("We have the following genres,choose one: hip-hop,alt-rock,indie rock,electronic")
hiphop = input("Do you want to listen to hip-hop? (yes/no)")
altrock = input("Do you want to listen to alt-rock? (yes/no)")
indierock = input("Do you want to listen to indie-rock? (yes/no)")
electronic = input("Do you want to listen to electronic? (yes/no)")
hhsongs = ("Jay-Z - Feelin' It","Notorious B.I.G. - Big Poppa","Ice Cube - Today Was a Good Day","Eazy-E - Boyz-n-the-Hood","Dr. Dre - Nuthin' but a G Thang")
arsongs = ("Radiohead - Karma Police","Beck - Loser","Cage the Elephant - Ain't No Rest for the Wicked","The Killers - Mr. Brightside")
irsongs = ("The Strokes - Hard to Explain","The Spinto Band - Oh Mandy","The Pixies - Here Comes Your Man","Vampire Weekend - A Punk")
esongs = ("Daft Punk - One More Time","Justice - Genesis","Deadmau5 - Animal","Flyring Lotus - GNG BNG")
if hiphop == "yes":
import random
print("Suggested: " + random.choice(hhsongs))
elif altrock == "alt-rock":
import random
print("Suggested: " + random.choice(arsongs))
elif indierock == "indie rock":
import random
print("Suggested: " + random.choice(irsongs))
elif electronic:
import random
print("Suggested: " + random.choice(esongs))