Esempio n. 1
0
class TestBot(unittest.TestCase):
    def __init__(self, *args, **kwargs):
        super(TestBot, self).__init__(*args, **kwargs)
        self.bot = Bot()

    def test_bot(self):
        self.assertEqual(self.bot.ask("hi"), "Hey.")
        self.assertIn(self.bot.ask("sadfkljdfkjlhfd"), DEFAULT)
Esempio n. 2
0
class Service:

    def __init__(self):
        self.__bot = Bot()

    def template(self):
		return render_template('chat.html')

    def message(self): 

        if not self.__bot.loaded():
            self.__bot.load()

        return self.__bot.ask(
            request
                .form['msg']
                .encode('utf-8')
                .strip())
Esempio n. 3
0
# Import class Bot's defenition from bot.py
from bot import Bot

# Make an instance of the bot.
AI = Bot()

# Prompt User for input
while True:
    prompt = AI.user_name + ": "
    que = raw_input(prompt)
    print "AI: "
    if (AI.ask(que.lower())):
        break
Esempio n. 4
0
import nltk

nltk.download("punkt")

bot = Bot()
data_loader = DataLoader()

data_loader.load_data()

HOST = "HOST_ADDRESS"
PORT = 4000

# Number of responses
RANGE = 15

# Connect as a client to other host (Group 28)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect((HOST, PORT))
    for i in range(RANGE):

        # Receive msg
        msg = s.recv(1024).decode("utf-8")
        print("OTHER CHATBOT: ", msg)

        # Generate response
        response = bot.ask(msg)
        print("OOMCK: ", response + "\n\n")

        # Send response
        s.send(bytes(response, "utf-8"))