You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class ConfirmBot(Bot):
def init(self):
self.q = "Do you like soccer?"
def _think(self, s):
print("Whether you like it nor not, let's talk something about soccer! I'm really interested in it!")
class TeamBot(Bot):
def __init__(self):
self.q = "Buddy, what's your favorite team in the Chinese Super League?"
def _think(self, s):
if 'sipg' in s.lower():
print("Wow! We are both fans of Shanghai SIPG! Nice to talk with you!")
else:
print("Pity, as you can see, we're opponents...")
class CompareBot(Bot):
def __init__(self):
self.q = "Which one of the team in the Chinese Super League do you think will win the championship?"
def _think(self, s):
teams = ['Shenzhen Jiazhaoye', 'Shandong Luneng', 'Beijing Guoan', 'Shanghai Greenland Shenhua',
'Guangzhou Evergrand', 'Chongqing SWM Motors', 'Tianjin Teda', 'Henan Jianye', 'Jiangsu Suning',
'Dalian Pro', 'Wuhan Zall', 'Guangzhou Fuli', 'Hebei HX Xingfu', 'Shijiazhuang yongchang',
'Qingdao Huanghai', 'Shanghai SIPG']
return f"I hope that {random.choice(teams)} will win."
class Oscar:
def __init__(self, wait=1):
Bot.wait = wait
self.bots = []
def add(self, bot):
self.bots.append(bot)
def _prompt(self, s):
print(s)
print()
def run(self):
self._prompt("This is Oscar dialog system. Let's talk.")
for bot in self.bots:
bot.run()
oscar = Oscar(1)
oscar.add(ConfirmBot())
oscar.add(TeamBot())
oscar.add(CompareBot())
oscar.run()
The text was updated successfully, but these errors were encountered:
写了一段代码,在运行的时候总会先给出None,再给出计算机的答案,向老师求教
from time import sleep
from termcolor import colored
import random
class Bot:
class ConfirmBot(Bot):
def init(self):
self.q = "Do you like soccer?"
class TeamBot(Bot):
class CompareBot(Bot):
class Oscar:
oscar = Oscar(1)
oscar.add(ConfirmBot())
oscar.add(TeamBot())
oscar.add(CompareBot())
oscar.run()
The text was updated successfully, but these errors were encountered: