Chatterbot如何获得多个回复

问题描述

python chatterbot库提供了convo.txt下面的数据集

output.txt

hey
hey 1
hey
hey 2
hey
hey 3

或在对此数据集进行训练时,与下面的数据集(yml)配合使用

- - hey
  - hey 1
- - hey
  - hey 2
- - hey
  - hey 3

调用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))

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...