예제 #1
0
class TkinterGUIExample(tk.Tk):

    def __init__(self, *args, **kwargs):
        '''
        Create & set window variables.
        '''
        tk.Tk.__init__(self, *args, **kwargs)

        self.chatbot = ChatBot("No Output",
            storage_adapter="chatterbot.adapters.storage.JsonFileStorageAdapter",
            logic_adapters=[
                "chatterbot.adapters.logic.ClosestMatchAdapter"
            ],
            input_adapter="chatterbot.adapters.input.VariableInputTypeAdapter",
            output_adapter="chatterbot.adapters.output.OutputFormatAdapter",
            database="../database.db"
        )

        self.title("Chatterbot")

        self.initialize()

    def initialize(self):
        '''
        Set window layout.
        '''
        self.grid()

        self.respond = ttk.Button(self, text='Get Response', command=self.get_response)
        self.respond.grid(column=0, row=0, sticky='nesw', padx=3, pady=3)

        self.usr_input = ttk.Entry(self, state='normal')
        self.usr_input.grid(column=1, row=0, sticky='nesw', padx=3, pady=3)

        self.conversation_lbl = ttk.Label(self, anchor=tk.E, text='Conversation:')
        self.conversation_lbl.grid(column=0, row=1, sticky='nesw', padx=3, pady=3)

        self.conversation = ScrolledText.ScrolledText(self, state='disabled')
        self.conversation.grid(column=0, row=2, columnspan=2, sticky='nesw', padx=3, pady=3)

    def get_response(self):
        '''
        Get a response from the chatbot &
        display it.
        '''
        user_input = self.usr_input.get()
        self.usr_input.delete(0, tk.END)

        response = self.chatbot.get_response(user_input)

        self.conversation['state'] = 'normal'
        self.conversation.insert(
            tk.END, "Human: " + user_input + "\n" + "ChatBot: " + str(response.text) + "\n"
        )
        self.conversation['state'] = 'disabled'

        time.sleep(0.5)
예제 #2
0
    def __init__(self, *args, **kwargs):
        '''
        Create & set window variables.
        '''
        tk.Tk.__init__(self, *args, **kwargs)

        self.chatbot = ChatBot("No Output",
            storage_adapter="chatterbot.adapters.storage.JsonFileStorageAdapter",
            logic_adapters=[
                "chatterbot.adapters.logic.ClosestMatchAdapter"
            ],
            input_adapter="chatterbot.adapters.input.VariableInputTypeAdapter",
            output_adapter="chatterbot.adapters.output.OutputFormatAdapter",
            database="../database.db"
        )

        self.title("Chatterbot")

        self.initialize()
예제 #3
0
import sys
sys.path.append("..")
from chatterbot.chatterbot import ChatBot

chatbot = ChatBot(
        'Ron Obvious',
        trainer='chatterbot.trainers.ChatterBotCorpusTrainer',
        silence_performance_warning=True
        )

chatbot.train("chatterbot.corpus.english")
print(chatbot.get_response("Hello, how are you today?"))
예제 #4
0
import pytz
import utils
import random
from chatterbot.chatterbot import ChatBot
import sys
from tzlocal import get_localzone
import json
from google_api import sendEmail, setReminder
from weather import getWeather
from datab import read

chatbot = ChatBot('PseudoBot',
                  trainer='chatterbot.trainers.ListTrainer',
                  storage_adapter="chatterbot.storage.MongoDatabaseAdapter",
                  logic_adapters=[{
                      'import_path':
                      'chatterbot.logic.BestMatch',
                      "response_selection_method":
                      "chatterbot.response_selection.get_first_response"
                  }],
                  filters=['chatterbot.filters.RepetitiveResponseFilter'])

triggered = {}
numberOfReplies = {}

threshold = 50


def get_response(query,
                 assistant,
                 accessToken='',
                 userEmail='',
예제 #5
0
from chatterbot.chatterbot import ChatBot
from chatterbot.trainers import ListTrainer


# Create a new instance of a ChatBot
popat = ChatBot("Terminal",
    storage_adapter="chatterbot.storage.sql_storage.SQLStorageAdapter",
    logic_adapters=[
        "chatterbot.logic.mathematical_evaluation.MathematicalEvaluation",
        "chatterbot.logic.time_adapter.TimeLogicAdapter",
        "chatterbot.logic.best_match.BestMatch"
    ],
    input_adapter="chatterbot.input.terminal.TerminalAdapter",
    output_adapter="chatterbot.output.terminal.TerminalAdapter",
    database="../database.db"
)
popat.set_trainer(ListTrainer)
popat.train([
    "hi",
    "hello",
    "how are you",
    "why are you interested",
    "that is good to hear",
    "thank you",
    "you are welcome",
    "sorry",
    "its okay",
    "what is your name",
    "my name is popat",
])
print("Type something to begin...")
예제 #6
0
from chatterbot.chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import UbuntuCorpusTrainer

chatbot = ChatBot('PseudoBot',
                  trainer='chatterbot.trainers.ChatterBotCorpusTrainer',
                  storage_adapter="chatterbot.storage.MongoDatabaseAdapter",
                  logic_adapters=[{
                      'import_path':
                      'chatterbot.logic.BestMatch',
                      "response_selection_method":
                      "chatterbot.response_selection.get_first_response"
                  }, {
                      'import_path':
                      'chatterbot.logic.MathematicalEvaluation'
                  }])

print "Trained"
while (True):
    message = str(raw_input())
    print chatbot.get_response(message)
import sys
sys.path.append("..")
from chatterbot.chatterbot import ChatBot
from chatterbot.adapters.logic.closest_meaning import ClosestMeaningAdapter
import logging
'''
This is an example showing how to train a chat bot using the
Ubuntu Corpus of conversation dialog.
'''

# Enable info level logging
logging.basicConfig(level=logging.INFO)

chatbot = ChatBot(
    'Example Bot',
    trainer='chatterbot.trainers.UbuntuCorpusTrainer',
    logic_adapters=[
        'chatterbot.adapters.logic.ClosestMeaningAdapter',
        'chatterbot.adapters.logic.SentimentAdapter'
    ],
)

# Start by training our bot with the Ubuntu corpus data
chatbot.train()

# Now let's get a response to a greeting
response = chatbot.get_response('What\'s the matter with you?')
print(response)
예제 #8
0
from settings import MAILGUN

'''
To use this example, create a new file called settings.py.
In settings.py define the following:

MAILGUN = {
    "CONSUMER_KEY": "my-mailgun-api-key",
    "API_ENDPOINT": "https://api.mailgun.net/v3/my-domain.com/messages"
}
'''

# Change these to match your own email configuration
FROM_EMAIL = "*****@*****.**"
RECIPIENTS = ["*****@*****.**"]

bot = ChatBot(
    "Mailgun Example Bot",
    mailgun_from_address=FROM_EMAIL,
    mailgun_api_key=MAILGUN["CONSUMER_KEY"],
    mailgun_api_endpoint=MAILGUN["API_ENDPOINT"],
    mailgun_recipients=RECIPIENTS,
    output_adapter="chatterbot.adapters.io.Mailgun",
    storage_adapter="chatterbot.adapters.storage.JsonFileStorageAdapter",
    database="../database.db"
)

# Send an example email to the address provided
response = bot.get_response("How are you?")
print("Check your inbox at ", RECIPIENTS)
예제 #9
0
from chatterbot.trainers import ListTrainer
from chatterbot.chatterbot import ChatBot
import os

#trains the AI

bot = ChatBot('support')
trainer = ListTrainer(bot)

for _file in os.listdir('txt'):
    chats = open('txt/' + _file, 'r').readlines()

    trainer.train(chats)

t = True

while t:
    request = input('You:')
    response = bot.get_response(request)

    print('bot:', response)
예제 #10
0
sys.path.append("..")
from chatterbot.chatterbot import ChatBot
from settings import MAILGUN
'''
To use this example, create a new file called settings.py.
In settings.py define the following:

MAILGUN = {
    "CONSUMER_KEY": "my-mailgun-api-key",
    "API_ENDPOINT": "https://api.mailgun.net/v3/my-domain.com/messages"
}
'''

# Change these to match your own email configuration
FROM_EMAIL = "*****@*****.**"
RECIPIENTS = ["*****@*****.**"]

bot = ChatBot(
    "Mailgun Example Bot",
    mailgun_from_address=FROM_EMAIL,
    mailgun_api_key=MAILGUN["CONSUMER_KEY"],
    mailgun_api_endpoint=MAILGUN["API_ENDPOINT"],
    mailgun_recipients=RECIPIENTS,
    output_adapter="chatterbot.adapters.io.Mailgun",
    storage_adapter="chatterbot.adapters.storage.JsonFileStorageAdapter",
    database="../database.db")

# Send an example email to the address provided
response = bot.get_response("How are you?")
print("Check your inbox at ", RECIPIENTS)
예제 #11
0
from tkinter import *
import pyttsx3 as pp

engine = pp.init()

voices = engine.getProperty('voices')

engine.setProperty('voice', voices[0].id)


def speak(word):
    engine.say(word)
    engine.runAndWait()


chatbot = ChatBot('my bot')
trainer = ListTrainer(chatbot)
trainer.train([
    'hello', 'hi there !', 'what is your name ?',
    'My name is Bot , i am created by Neha', 'how are you ?',
    'I am doing great these days', 'thank you', 'In which city you live ?',
    'I live in ur pc', 'In which language you talk?',
    ' I mostly talk in english', 'what do u like most',
    'I always there for ur work', 'tell me about urself bot',
    'okay I m bot created by Neha I m here for  ur help how can i help you thank you',
    'thank you', 'welcome', 'bye', 'bye nice to meet  you'
])

#print("Talk to bot")
#while True:
# request=input('you: ')
from chatterbot.chatterbot import ChatBot  # import the chatbot
from pep8 import readlines
from chatterbot.trainers import ListTrainer  # method to train the chatbot

bot = ChatBot('Test')  # create the chatbot

conv = open('chat.txt', 'r').readlines()

bot.set_trainer(ListTrainer)  # set the trainers
bot.train(conv)  # train the bot

while True:
    request = input('You: ')
    response = bot.get_response(request)
    print('Bot: ', response)
예제 #13
0
import sys
sys.path.append("..")
from chatterbot.chatterbot import ChatBot

chatbot = ChatBot('Ron Obvious',
                  trainer='chatterbot.trainers.ChatterBotCorpusTrainer',
                  silence_performance_warning=True)

chatbot.train("chatterbot.corpus.english")
print(chatbot.get_response("Hello, how are you today?"))
예제 #14
0
In settings.py define the following:

TWITTER = {
    "CONSUMER_KEY": "my-twitter-consumer-key",
    "CONSUMER_SECRET": "my-twitter-consumer-secret",
    "ACCESS_TOKEN": "my-access-token",
    "ACCESS_TOKEN_SECRET": "my-access-token-secret"
}
'''

chatbot = ChatBot(
    "ChatterBot",
    storage_adapter="chatterbot.adapters.storage.TwitterAdapter",
    logic_adapters=["chatterbot.adapters.logic.ClosestMatchAdapter"],
    input_adapter="chatterbot.adapters.input.TerminalAdapter",
    output_adapter="chatterbot.adapters.output.TerminalAdapter",
    database="../database.db",
    twitter_consumer_key=TWITTER["CONSUMER_KEY"],
    twitter_consumer_secret=TWITTER["CONSUMER_SECRET"],
    twitter_access_token_key=TWITTER["ACCESS_TOKEN"],
    twitter_access_token_secret=TWITTER["ACCESS_TOKEN_SECRET"])

print("Type something to begin...")

while True:
    try:
        bot_input = chatbot.get_response(None)

    except (KeyboardInterrupt, EOFError, SystemExit):
        break
예제 #15
0
import sys
sys.path.append("..")
from chatterbot.chatterbot import ChatBot

# Create a new chat bot named Charlie
chatbot = ChatBot("Charlie")

# Get a response to the input "How are you?"
response = chatbot.get_response("How are you?")

print(response)
예제 #16
0
from flask import Flask, render_template, request
from chatterbot.chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
app = Flask(__name__)
english_bot = ChatBot("Chatterbot",
                      storage_adapter="chatterbot.storage.SQLStorageAdapter")
trainer = ChatterBotCorpusTrainer(english_bot)
trainer.train("chatterbot.corpus.english")
trainer.train("data/data.yml")


@app.route("/")
def index():
    return render_template("index.html")  #to send context to html file


@app.route("/get")
def get_bot_response():
    userText = request.args.get(
        "msg")  #get data from input, we write js to index.html
    return str(english_bot.get_response(userText))


if __name__ == "__main__":
    app.run(debug=True)
TWITTER = {
    "CONSUMER_KEY": "my-twitter-consumer-key",
    "CONSUMER_SECRET": "my-twitter-consumer-secret",
    "ACCESS_TOKEN": "my-access-token",
    "ACCESS_TOKEN_SECRET": "my-access-token-secret"
}
'''

chatbot = ChatBot("ChatterBot",
    storage_adapter="chatterbot.adapters.storage.TwitterAdapter",
    logic_adapters=[
        "chatterbot.adapters.logic.ClosestMatchAdapter"
    ],
    input_adapter="chatterbot.adapters.input.TerminalAdapter",
    output_adapter="chatterbot.adapters.output.TerminalAdapter",
    database="../database.db",
    twitter_consumer_key=TWITTER["CONSUMER_KEY"],
    twitter_consumer_secret=TWITTER["CONSUMER_SECRET"],
    twitter_access_token_key=TWITTER["ACCESS_TOKEN"],
    twitter_access_token_secret=TWITTER["ACCESS_TOKEN_SECRET"]
)

print("Type something to begin...")

while True:
    try:
        bot_input = chatbot.get_response(None)

    except (KeyboardInterrupt, EOFError, SystemExit):
        break
예제 #18
0
import sys
sys.path.append("..")
from chatterbot.chatterbot import ChatBot

bot = ChatBot(
    "Math & Time Bot",
    logic_adapters=[
        "chatterbot.adapters.logic.MathematicalEvaluation",
        "chatterbot.adapters.logic.TimeLogicAdapter"
    ],
    input_adapter="chatterbot.adapters.input.VariableInputTypeAdapter",
    output_adapter="chatterbot.adapters.output.OutputFormatAdapter")

# Print an example of getting one math based response
response = bot.get_response("What is 4 + 9?")
print(response)

# Print an example of getting one time based response
response = bot.get_response("What time is it?")
print(response)