Exemplo n.º 1
0
# coding=utf-8

from chatterbot import ChatBot

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

# Train based on the english corpus
chatbot.train("chatterbot.corpus.chinese")

# Get a response to an input statement
chatbot.get_response("为什么两个鼻孔?")
Exemplo n.º 2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'eric.guo'

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

chatbot = ChatBot("Ron Obvious")

conversation = [
    "Hello", "Hi there!", "How are you doing?", "I'm doing great.",
    "That is good to hear", "Thank you.", "You're welcome."
]

chatbot.set_trainer(ListTrainer)
chatbot.train(conversation)

response = chatbot.get_response("Good morning!")
print(response)
Exemplo n.º 3
0
# -*- coding: utf-8 -*-

import json
from flask import Flask, Response, request, abort, jsonify, make_response
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from flask_cors import CORS
from .utils import json_response

app = Flask(__name__)
CORS(app, origins='*', allow_headers=['Content-Type', 'Accept'])

english_bot = ChatBot('Chatterbot',
                      storage_adapter='chatterbot.storage.SQLStorageAdapter')

english_bot.set_trainer(ChatterBotCorpusTrainer)
english_bot.train('chatterbot.corpus.english')


@app.errorhandler(400)
def not_found(error):
    return make_response(jsonify({'error': 'Bad request'}), 400)


@app.errorhandler(404)
def not_found(error):
    res = {'error': 'Not found'}
    return make_response(jsonify(res), 404)


@app.route('/')
Exemplo n.º 4
0
from chatterbot import ChatBot
chatbot = ChatBot('Brandon', trainer='chatterbot.trainers.ListTrainer')
response = chatbot.get_response("Hi there")
print(response)
Exemplo n.º 5
0
import os, sys
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# corpus_file = os.path.join(BASE_DIR,"database/jsonfile/test.json")
corpus_file = os.path.join(BASE_DIR, 'trainning\\test.json')
# from core.MyRobert import bot

from chatterbot import ChatBot

bot = ChatBot(
    "Terminal",
    storage_adapter='chatterbot.storage.MongoDatabaseAdapter',
    logic_adapters=[
        {
            'import_path': "chatterbot.logic.BestMatch"
        },
    ],
    filters=['chatterbot.filters.RepetitiveResponseFilter'],
    # trainer='chatterbot.trainers.ListTrainer',
    input_adapter="chatterbot.input.VariableInputTypeAdapter",
    output_adapter="chatterbot.output.OutputAdapter",
    database_uri="mongodb://localhost:27017/",
    database="xbt",
    read_only=True,
)
bot.set_trainer(ChatterBotCorpusTrainer)

# 使用中文语料库训练它
# if __name__ == '__main__':

# bot.train([
#     "你认为什么时间戒烟是最好的?",
#     "戒烟越早越好什么时候戒烟都为时不晚。",
Exemplo n.º 6
0
from flask import Flask, render_template, request
from 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("data/data.yml")

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

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


if __name__ == "__main__":
    app.run()
Exemplo n.º 7
0
def chatterbot_msg(MSG):
    chatbot = ChatBot("Magali")
    trainer = ChatterBotCorpusTrainer(chatbot)
    trainer.train("chatterbot.corpus.portuguese")
    output = chatbot.get_response(str(MSG))
    return output
Exemplo n.º 8
0
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

# Create a new chat bot named L0ra
chatbot = ChatBot('L0ra')

trainer = ListTrainer(chatbot)

trainer.train([
    "I don't normally talk to people with DMs but your twitter feed is cool",
    "Chilling.... lol..", "How are you?",
    "what's your favorite security question?", "How did I spark your interest",
    "I don’t know who I was in my past life to be blessed enough to end up with someone like you.",
    "I’m at the grocery store… I’m thinking wine tonight?",
    "What can we do tonight...in bed?",
    "I know we fought last night… I’m sorry and still love you.",
    "I am looking for real men for meeting in my video chat #pussy #cumtribute #chat",
    "Does anyone likes exchange pics?",
    "Do you believe in kiss and tell? Cause I want you to kiss me and do things to me in your mind and tell me all about it.",
    "Let’s try something new in the kitchen tonight. And no, I don’t mean food!",
    "I can’t wait to kiss you later",
    "Take care of what’s mine, Baby. I’ll see you later.",
    "I have a kinky surprise for you", "#lonely and #bored Anyone wanna #chat",
    "Is it sexy enough for you",
    "The fact that I chose spending more time with you over sleep must mean you’re pretty special!",
    "Hello!", "I spent a hard day!",
    "Have you ever touched yourself thinking about me?",
    "Is it sexy enough for you?",
    "I’ve had a rough day; give me a rough night.",
    "Do you want me to rate your D guys? lmao",
    "I couldn’t imagine a better person to share my life with",
from chatterbot.trainers import ListTrainer
from chatterbot import ChatBot
import os

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

for _file in os.listdir('files'):
    chats = open('files/' + _file, 'r').readlines()
    print(chats)
    trainer.train(chats)

while True:
    request = input('Me: ')
    response = bot.get_response(request)

    print('Bot: ', response)
Exemplo n.º 10
0
from flask import Flask, render_template, request
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

app = Flask(__name__)

bot = ChatBot(name='chatterbot',
              logic_adapters=[
                  'chatterbot.logic.MathematicalEvaluation',
                  'chatterbot.logic.BestMatch',
                  'chatterbot.logic.SpecificResponseAdapter'
              ])
trainer = ChatterBotCorpusTrainer(bot)
trainer.train("chatterbot.corpus.english")


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


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


if __name__ == "__main__":
    app.config['ENV'] = 'development'
    app.config['DEBUG'] = True
    app.config['TESTING'] = True
Exemplo n.º 11
0
from flask import Flask, jsonify, request
from chatterbot.trainers import ListTrainer
from chatterbot import ChatBot
import json
from flask_cors import CORS
import mandarin
app = Flask(__name__)
#CORS(app)

amicia = ChatBot("Amica")
amicia.set_trainer(ListTrainer)
amicia.train(mandarin.mandarin_conversation)

@app.route("/conversation", methods=['POST'])
def conversation():
    user_input = request.get_json()
    print (user_input)
    question = user_input['user']
    response = amicia.get_response(question).text
    print(response)
    output = { 'data': response }
    return jsonify(output)

if __name__ == "__main__":
    app.run(host='0.0.0.0',port='5080')
Exemplo n.º 12
0
import logging
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import ChatterBotCorpusTrainer
# from chatterbot.trainers import UbuntuCorpusTrainer
from django.conf import settings

# Creating ChatBot Instance
bota = ChatBot(**settings.CHATTERBOT)

logging.basicConfig(level=logging.INFO)

training_data_que_ans = open(
    f'{settings.BASE_DIR}/bot/static/bota/que_ans.txt').read().splitlines()
training_data_personal = open(
    f'{settings.BASE_DIR}/bot/static/bota/training_data.txt').read(
    ).splitlines()

training_data = training_data_que_ans + training_data_personal

trainer = ListTrainer(bota)
trainer.train(training_data)

trainer_corpus = ChatterBotCorpusTrainer(bota)
trainer_corpus.train('chatterbot.corpus.english')

# ubuntu_corpus_trainer = UbuntuCorpusTrainer(bota)
# ubuntu_corpus_trainer.train()
Exemplo n.º 13
0
from chatterbot import ChatBot
bot = ChatBot('Anvesha')

from chatterbot.trainers import ListTrainer

bot.set_trainer(ListTrainer)
#Training
bot.train(['What is your name?', 'My name is Anvesha'])
bot.train(['Who are you?', 'I am a bot, created by you.'])
bot.train(['Do you know me?', 'Yes, you created me.', 'Yash?', 'No Idea!!'])

import os
for files in os.listdir('./english/'):
    data = open('./english/' + files, 'r').readlines()
    bot.train(data)
'''
    #Training the bot who doesn't have the upper english folder in the local computer
    
from chatterbot.trainers import ChatterBotCorpusTrainer
trainer = ChatterBotCorpusTrainer(bot)
trainer.train("chatterbot.corpus.english")
'''

while True:
    message = input('\t\t\tYou:')
    if message.strip() != 'Bye':
        reply = bot.get_response(message)
        print('\t\t\tAnvesha: ', reply)
    if message.strip() == 'Bye':
        print('Anvesha: Bye')
        break
Exemplo n.º 14
0
from django.shortcuts import render, render_to_response
from django.http import HttpResponse
import json
from django.views.decorators.csrf import csrf_exempt

from chatterbot import ChatBot

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

# Train based on the english corpus

#Already trained and it's supposed to be persistent
# chatbot.train("chatterbot.corpus.english")


@csrf_exempt
def get_response(request):
    response = {'status': None}

    if request.method == 'POST':
        data = json.loads(request.body)
        message = data['message']

        chat_response = chatbot.get_response(message).text
        response['message'] = {
            'text': chat_response,
Exemplo n.º 15
0
from flask import Flask, render_template, request
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from chatterbot.trainers import ListTrainer

app = Flask(__name__)

bot = ChatBot("Candice")
trainer = ListTrainer(bot)
trainer.train(['What is your name?', 'My name is Candice'])
trainer.train(['Who are you?', 'I am a bot'])
trainer.train(['Do created you?', 'Tony Stark', 'Sahil Rajput', 'You?'])
trainer = ChatterBotCorpusTrainer(bot)
trainer.train("chatterbot.corpus.english")


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


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


if __name__ == "__main__":
    app.run()
Exemplo n.º 16
0
#!/usr/bin/env python3.5
from wxpy import *
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
chatbot = ChatBot("deepThought")  # 用于回复消息的机器人
# chatbot.set_trainer(ChatterBotCorpusTrainer)
chatbot = ChatterBotCorpusTrainer(chatbot)
chatbot.train("chatterbot.corpus.chinese")  # 使用该库的中文语料库
bot = Bot(cache_path=True)  # 用于接入微信的机器人
tuling = Tuling(api_key="0f5639cdfe0a4f7e94e7d745eab23667")

# group_2 = bot.groups("哈哈群")[0]# 进行测试的群
group_2 = bot.groups().search('哈哈群')[0]
# group_2 = bot.search('wxpy')[0]
group_2.send("大家好,我是人工智能")


@bot.register(group_2)
def reply_my_friend(msg):
    print(msg)
    tuling.do_reply(msg)
    # return chatbot.get_response(msg.text).text# 使用机器人进行自动回复


# 堵塞线程,并进入 Python 命令行
embed()
Exemplo n.º 17
0
from chatterbot.trainers import ChatterBotCorpusTrainer
import os
import nltk
import ssl

# try:
#     _create_unverified_https_context = ssl._create_unverified_context
# except AttributeError:
#     pass
# else:
#     ssl._create_default_https_context = _create_unverified_https_context
#
# nltk.download()

#Create a chatbot
bot = ChatBot('Friend')
trainer = ChatterBotCorpusTrainer(bot)
trainer.train('chatterbot.corpus.english')


#chat feature
def main():
    while True:
        message = input('\t\t\tYou:')
        if message.strip() != 'Bye':
            reply = bot.get_response(message)
            print('Friend:', reply)
        if message.strip() == ' Bye':
            print('Friend: Bye')
            break
Exemplo n.º 18
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 10 17:08:46 2019

@author: jeetu
"""

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

bot = ChatBot("test")
conv = open("chat.txt", "r").readlines()

trainer = ListTrainer(bot)
trainer.train(conv)

while True:
    request = input("you: ")
    response = bot.get_response(request)
    print("Bot: ", response)
Exemplo n.º 19
0
# chatbot/bot.py
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

diego = ChatBot("Diego")

trainer = ChatterBotCorpusTrainer(diego)
trainer.train(
    "chatterbot.corpus.english.greetings",
    "chatterbot.corpus.english.conversations",
)
Exemplo n.º 20
0
from linebot.models import *

from chatterbot import ChatBot
from random import randint
import MySQLdb
import requests
import json
import multiprocessing
import time

botList = []
botnum = 700
while botnum < 1000:
    chatbot = ChatBot(
        "bot" + str(botnum),
        storage_adapter='chatterbot.storage.SQLStorageAdapter',
        database='./Brain/' + str(botnum) + '.sqlite3',
        read_only=True,
    )
    botList.append(chatbot)
    botnum += 100


def job(index, msg, return_list):
    response = botList[index].get_response(msg)
    print("回應: " + response.text + "(" + str(response.confidence) + ")")
    if (response.confidence >= 0.4):
        print({"confidence": response.confidence, "lys": response.text})
        queryy = "SELECT `kkboxID`, `Artists`,`SongName` FROM `LyricsData` WHERE `Lyrics` like '%" + response.text + "%'"
        print("queryy = " + queryy)
        cursor.execute(queryy)
        record = cursor.fetchone()
Exemplo n.º 21
0
from chatterbot import ChatBot
import logging

# Uncomment the following line to enable verbose logging
# logging.basicConfig(level=logging.INFO)

# Create a new instance of a ChatBot
bot = ChatBot(
    "Terminal",
    storage_adapter="chatterbot.adapters.storage.JsonFileStorageAdapter",
    logic_adapters=[
        "chatterbot.adapters.logic.MathematicalEvaluation",
        "chatterbot.adapters.logic.TimeLogicAdapter",
        "chatterbot.adapters.logic.ClosestMatchAdapter"
    ],
    input_adapter="chatterbot.adapters.input.TerminalAdapter",
    output_adapter="chatterbot.adapters.output.TerminalAdapter",
    database="../database.db")

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

# The following loop will execute each time the user enters input
while True:
    try:
        # We pass None to this method because the parameter
        # is not used by the TerminalAdapter
        bot_input = bot.get_response(None)

    # Press ctrl-c or ctrl-d on the keyboard to exit
    except (KeyboardInterrupt, EOFError, SystemExit):
        break
# ChatBot       :AAG
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
import os

bot = ChatBot('Bot')
bot.set_trainer(ListTrainer)
# Can Download Training Files Here: https://github.com/gunthercox/chatterbot-corpus/tree/master/chatterbot_corpus/data
training_files = os.path.join(
    os.getcwd(), 'english')  #Path where English training files are

for file in os.listdir(training_files):
    data = open(os.path.join(training_files, file)).readlines()
    bot.train(data)
    print('Talk to ChatBot')
try:
    while True:
        text = input('You: ')
        reply = bot.get_response(text)
        print('Bot:', reply)
except:
    print('GoodBye, Take Care')
Exemplo n.º 23
0
# helper.py

from chatterbot import ChatBot

# momo_chat = ChatBot(
#     'momo',
#     # 指定存储方式
#     # 指定logic adpater 我们这里指定三个
#     logic_adapters=[
#         "chatterbot.logic.BestMatch",
#         "chatterbot.logic.MathematicalEvaluation",  # 数学模块
#         "chatterbot.logic.TimeLogicAdapter",  # 时间模块
#     ],
#     input_adapter="chatterbot.input.VariableInputTypeAdapter",
#     output_adapter="chatterbot.output.OutputAdapter",
#     database="chatterbot",
#     read_only=True
# )
momo_chat = ChatBot('mmo',
                    trainer='chatterbot.trainers.ChatterBotCorpusTrainer')
momo_chat.train("chatterbot.corpus.chinese")


def get_momo_answer(content):
    #  获取机器人返回结果函数
    response = momo_chat.get_response(content)

    if isinstance(response, str):
        return response
    return response.text
Exemplo n.º 24
0
from chatterbot import ChatBot

chatbot = ChatBot('tBot')
Exemplo n.º 25
0
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 30 21:21:24 2017

@author: XingHan
"""
from chatterbot import ChatBot

bot = ChatBot("Terminal",
              storage_adapter="chatterbot.storage.SQLStorageAdapter",
              logic_adapters=[
                  "chatterbot.logic.MathematicalEvaluation",
                  "chatterbot.logic.TimeLogicAdapter",
                  "chatterbot.logic.BestMatch"
              ],
              input_adapter="chatterbot.input.TerminalAdapter",
              output_adapter="chatterbot.output.TerminalAdapter",
              database="../database.db")

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

# The following loop will execute each time the user enters input
while True:
    try:
        # We pass None to this method because the parameter
        # is not used by the TerminalAdapter
        bot_input = bot.get_response(None)

    # Press ctrl-c or ctrl-d on the keyboard to exit
    except (KeyboardInterrupt, EOFError, SystemExit):
        break
Exemplo n.º 26
0
import serial 
import threading
import time
import speech_recognition as sr
import pyttsx3 

#chatbot lib
from chatterbot.trainers import ListTrainer 

from chatterbot import ChatBot


JARVISbot = ChatBot("JARVIS")

 #texto inicial, com as conversas o bot vai ficando mais inteligente
conversa1 = ['hello jarvis','hello sir','how you doing ?', 'im great,how about you?','jarvis','im here sir','yes sir']
conversa2 = ['whats up Jarvis?','hey Gabriel','are you feeling good ?','cant be better! how can I help you ?']
conversa3 = ['i am fine', 'thats great','thank you','your welcome sir','thanks','my pleasure','how are you','im great,thanks for asking']
conversa4 = ['jarvis what is my name?', 'you are gabriel, my creator', 'turn on video game', 'unfortunately i cant do that because im not programmed to this function yet']
conversa5 = ['can you tell me a joke?', 'im not great with jokes, but here it goes. Why six was afraid of seven?', 'why?', 'because seven ate nine']
conversa6 = ['jarvis who is my grandfather ?','your grandfather is Almeer','jarvis say hello','hey everyone']
conversa7 = ['who are you?','i am jarvis, a personal assistent created by Gabriel de Lemos']
conversa8 = ['im fine','cool','good morning jarvis','good morning sir','good evening jarvis','good evening sir','nice to meet you','nice to meet you too']
conversa9 = ['how is the weather today','today is a great day to work sir, for more especific details access the weather forecast','jarvis say hi to my teacher','hello Gabriels teacher, how you doing?']
conversa10 = ['jarvis what do you think about artificial intelligence','well,thats a great subjact,artificial intelligence is intelligence demonstrated by machines,the capacity of showing cognitive functions that humans associate with the human mind, such as learning and problem solving']
conversa11 = ['how do you know about this','every thing is on the internet sir','what do you thing about education','Education gives us an understanding of the world around us and offers us an opportunity to use that knowledge wisely,Irrespective of race, creed, and gender, education makes it possible for people to stand out as equal with all the other persons from different walks of life']
conversa12 = ['what is the theory of relativity','Einsteins theory of special relativity says that time slows down or speeds up depending on how fast you move relative to something else,Approaching the speed of light, a person inside a spaceship would age much slower than his twin at home, Also, under Einsteins theory of general relativity, gravity can bend time']
conversa13 = ['who was Albert Einstein','Albert Einstein was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics,alongside quantum mechanics']
conversa14 = ['jarvis say hello to in metrics', 'hello people from inmetrics, my name is Jarvis a personal assistant created by Gabriel de Lemos', 'good jarvis and what do you have to say to them', 'i hope gabriel made a great presentation, after all i cant speak badly of him because he programmed me to say only great things']

treinar = ListTrainer(JARVISbot)
Exemplo n.º 27
0
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from flask import Flask, render_template, request

app = Flask(__name__)
chatbot = ChatBot('Charlie')
trainer = ListTrainer(chatbot)


def clearChatbotData():
    chatbot.storage.drop()


#call this function when want to clear old data
#clearChatbotData()
trainer = ListTrainer(chatbot)


def train_from_text_file():
    data = open('chat_training_data.txt').read()
    conversations = data.strip().split('\n')
    trainer.train(conversations)


train_from_text_file()
response = chatbot.get_response('Who is prime minister of india?')


@app.route("/")
def home():
    return render_template("index.html")
Exemplo n.º 28
0
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import ChatterBotCorpusTrainer

# chats = open('chats.txt', 'r').readlines()
responds = open('chats.txt', 'r').readlines()

bot = ChatBot(
    'Trombosit', 
    storage_adapter='chatterbot.storage.SQLStorageAdapter', 
    input_adapter="chatterbot.input.VariableInputTypeAdapter", 
    output_adapter="chatterbot.output.OutputAdapter",
    logic_adapters=[
        "chatterbot.logic.BestMatch"
    ])
# bot.set_trainer(ListTrainer)
# bot.train(responds)

# bot.set_trainer(ChatterBotCorpusTrainer)
# bot.train('chatterbot.corpus.indonesia')

def chat(input):
    print("received message:", input)
    response = bot.get_response(input)
    print("sending message:", response)
    return response
Exemplo n.º 29
0
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

nicole_chatbot = ChatBot(
    name='Nicole',
    logic_adapters=[
        "chatterbot.logic.BestMatch",
        "chatterbot.logic.MathematicalEvaluation"
    ]
)

nicole_chatbot.set_trainer(ChatterBotCorpusTrainer)

nicole_chatbot.train(
   "chatterbot.corpus.english.greetings",
    "chatterbot.corpus.english.conversations"
)


#method trainer
#Allows a chat bot to be trained using a list of strings
#where the list represents a conversation.
#nicole face
file = open('nicoleface.txt','r')
if file.mode == 'r':
    contents = file.read()
    print(contents)

file.close()

print('Hi dear, i´m alive...')
Exemplo n.º 30
0
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import ChatterBotCorpusTrainer
# Creating ChatBot Instance
chatbot = ChatBot('CoronaBot')

# Training with Personal Ques & Ans
conversation = [
    'hello', 'hi there !', 'what is your name ?',
    'My name is Bot , i am created by suraj', 'how are you ?',
    'I am doing great these days', 'In which city you live ?',
    'I live in jodhpur', 'In which language you talk?',
    ' I mostly talk in english', 'Could you hear me?', 'Yes I can',
    'You are beautiful', 'Thank you very much', 'How old are you',
    'Im too young as you have created me yesterday only!'
]

trainer = ListTrainer(chatbot)
trainer.train(conversation)

# Training with English Corpus Data
trainer_corpus = ChatterBotCorpusTrainer(chatbot)
trainer_corpus.train('chatterbot.corpus.english')