Exemple #1
0
class Bot(discord.Client):
    async def on_ready(self):
        self.chatbot = ChatBot(name='Stella 2.0',
                               read_only=False,
                               logic_adapters=['chatterbot.logic.BestMatch'])
        self.trainer = ChatterBotCorpusTrainer(self.chatbot)
        self.trainer.train('./corpus.json')

    async def on_message(self, message):
        # don't respond to ourselves
        if message.author == self.user:
            return

        inpt = str(message.content.encode('utf-8'))
        outpt = self.chatbot.get_response(re.sub('<@[-+]?[1-9]\d*>', '', inpt))
        print('> ' + inpt)
        print(outpt)

        # 25% chance of replying
        if random.randint(0, 100) < 10 or f'<@{self.user.id}>' in inpt:
            inpt.replace(f'<@{self.user.id}>', '')
            await asyncio.sleep(random.randint(3, 5))
            async with message.channel.typing():
                await asyncio.sleep(len(str(outpt)) * 0.10)
                await message.channel.send(f'<@{message.author.id}> ' +
                                           str(outpt))
        self.trainer.export_for_training('./corpus.json')
Exemple #2
0
    def train(self):
        """
        Import seed data
        :return:
        """

        pub.sendMessage(Event.info, message = "Training, may take a while...")
        trainer = ChatterBotCorpusTrainer(self.bot)

        trainer.train(
            "chatterbot.corpus.english"
        )

        pub.sendMessage(Event.info, message = "exporting training data")

        makedirs("./output")
        trainer.export_for_training('./output/training_export.json')

        pub.sendMessage(Event.info, message = "Training complete.")
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
'''
This is an example showing how to create an export file from
an existing chat bot that can then be used to train other bots.
'''

chatbot = ChatBot('Export Example Bot')

# First, lets train our bot with some data
trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train('chatterbot.corpus.english')

# Now we can export the data to a file
trainer.export_for_training('./my_export.json')
Exemple #4
0
from create_chatbot_instance import new_ches_cak
from chatterbot.trainers import ChatterBotCorpusTrainer
from chatterbot.trainers import ListTrainer

# Create a new chat bot named ches cak
chatbot = new_ches_cak()
export = False

trainer = ChatterBotCorpusTrainer(chatbot)
print("Training custom datasets")
trainer.train("datasets/", )
print("trained from custom  datasets")

print("finished training")
if (export):
    trainer.export_for_training('./exported_train_data.json')
Exemple #5
0
        {
            'import_path': 'chatterbot.logic.WikipediaResponseAdapter'
        }
    ],
    preprocessors=[
        'chatterbot.preprocessors.clean_whitespace'
    ],
    filters=[
        'chatterbot.filters.RepetitiveResponseFilter'
    ],
)
trainer = ChatterBotCorpusTrainer(bot)

# Train the bot using training data in the file and export all training to a json file
trainer.train("./Gabungan")
trainer.export_for_training('./qbot_training.json')

# Training the bot using responses
def train(content):
    trainer = ListTrainer(bot)
    trainer.train(content)
    thanks = 'Thank you for training me'
    return thanks

def get_response(content):
        return bot.get_response(content)


async def check_for_trigger_match(query, trigger_list):
    for trigger in trigger_list:
        if query.startswith(trigger):
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

'''
This is an example showing how to create an export file from
an existing chat bot that can then be used to train other bots.
'''

chatbot = ChatBot('Export Example Bot')

# First, lets train our bot with some data
trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train('chatterbot.corpus.english')

# Now we can export the data to a file
trainer.export_for_training('./my_export.json')
Exemple #7
0
from chatterbot.trainers import ChatterBotCorpusTrainer, ListTrainer
import playsound
import speech_recognition as sr
from gtts import gTTS
import random

app = Flask(__name__)

credi_bot = ChatBot("CrediBot",
                    storage_adapter="chatterbot.storage.SQLStorageAdapter",
                    database_uri='sqlite:///database.sqlite3')

trainer = ChatterBotCorpusTrainer(credi_bot)
trainer.train("./data/creditos.yml")

trainer.export_for_training('./traning.json')


@app.route("/")
def home():
    return render_template("index.html")


@app.route("/get")
def get_bot_response():
    userText = request.args.get('msg')
    return str(credi_bot.get_response(userText))
    # return speak(str(daliaBot.get_response(userText)))


def speak(text):
Exemple #8
0
#!/usr/bin/env python

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

chatbot = ChatBot('Terminal',
                  storage_adapter='chatterbot.storage.SQLStorageAdapter',
                  trainer='chatterbot.trainers.ListTrainer',
                  database_uri='sqlite:///database.db')

trainer = ChatterBotCorpusTrainer(chatbot)

trainer.export_for_training('./export.yml')
Exemple #9
0
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

chatbot = ChatBot(
    "@ti-asa",
    database_uri='sqlite://db/db.sqlite3',
    logic_adapters=["chatterbot.logic.BestMatch"],
)

trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train('chatterbot.corpus.french.greetings')

trainer.export_for_training('./salfr.json')
Exemple #10
0
      database_uri='sqlite:///database.sqlite3',
      logic_adapters=[
        'chatterbot.logic.MathematicalEvaluation',
#        'chatterbot.logic.TimeLogicAdapter',
        'chatterbot.logic.BestMatch'
    ],
#
)

## First, lets train our bot with some data
trainer = ChatterBotCorpusTrainer(chatbot)
#
trainer.train('chatterbot.corpus.english')
#
## Now we can export the data to a file
trainer.export_for_training('./database.sqlite3.db')

trainer1=chatterbot.trainers.UbuntuCorpusTrainer(chatbot)
trainer1.train()

def get_feedback():

    text = input()

    if 'yes' in text.lower():
        return True
    elif 'no' in text.lower():
        return False
    else:
        print('Please type either "Yes" or "No"')
        return get_feedback()