rename to chatterbot

pull/1/head
Bobloy 7 years ago
parent 6697ed3b92
commit 5d2a13f2a3

@ -5,8 +5,8 @@ import discord
from discord.ext import commands
from redbot.core import Config
from .source import ChatBot
from .source.trainers import ListTrainer
from .chatterbot import ChatBot
from .chatterbot.trainers import ListTrainer
class Chatter:
@ -23,7 +23,11 @@ class Chatter:
"days": 1
}
self.chatbot = ChatBot("ChatterBot")
self.chatbot = ChatBot(
"ChatterBot",
storage_adapter='chatterbot.storage.SQLStorageAdapter',
database='./database.sqlite3'
)
self.chatbot.set_trainer(ListTrainer)
self.config.register_global(**default_global)

@ -3,7 +3,7 @@ ChatterBot is a machine learning, conversational dialog engine.
"""
from .chatterbot import ChatBot
__version__ = '0.8.4'
__version__ = '0.8.5'
__author__ = 'Gunther Cox'
__email__ = 'gunthercx@gmail.com'
__url__ = 'https://github.com/gunthercox/ChatterBot'

@ -16,7 +16,7 @@ class Adapter(object):
"""
Gives the adapter access to an instance of the ChatBot class.
:param chatbot: A chat bot instanse.
:param chatbot: A chat bot instance.
:type chatbot: ChatBot
"""
self.chatbot = chatbot

@ -20,15 +20,15 @@ class ChatBot(object):
self.default_session = None
storage_adapter = kwargs.get('storage_adapter', 'chatter.source.storage.SQLStorageAdapter')
storage_adapter = kwargs.get('storage_adapter', 'chatterbot.storage.SQLStorageAdapter')
logic_adapters = kwargs.get('logic_adapters', [
'chatter.source.logic.BestMatch'
'chatterbot.logic.BestMatch'
])
input_adapter = kwargs.get('input_adapter', 'chatter.source.input.VariableInputTypeAdapter')
input_adapter = kwargs.get('input_adapter', 'chatterbot.input.VariableInputTypeAdapter')
output_adapter = kwargs.get('output_adapter', 'chatter.source.output.OutputAdapter')
output_adapter = kwargs.get('output_adapter', 'chatterbot.output.OutputAdapter')
# Check that each adapter is a valid subclass of it's respective parent
utils.validate_adapter_class(storage_adapter, StorageAdapter)
@ -45,7 +45,7 @@ class ChatBot(object):
# Add required system logic adapter
self.logic.system_adapters.append(
utils.initialize_class('chatter.source.logic.NoKnowledgeAdapter', **kwargs)
utils.initialize_class('chatterbot.logic.NoKnowledgeAdapter', **kwargs)
)
for adapter in logic_adapters:
@ -59,7 +59,7 @@ class ChatBot(object):
preprocessors = kwargs.get(
'preprocessors', [
'chatter.source.preprocessors.clean_whitespace'
'chatterbot.preprocessors.clean_whitespace'
]
)
@ -69,7 +69,7 @@ class ChatBot(object):
self.preprocessors.append(utils.import_module(preprocessor))
# Use specified trainer or fall back to the default
trainer = kwargs.get('trainer', 'chatter.source.trainers.Trainer')
trainer = kwargs.get('trainer', 'chatterbot.trainers.Trainer')
TrainerClass = utils.import_module(trainer)
self.trainer = TrainerClass(self.storage, **kwargs)
self.training_data = kwargs.get('training_data')

@ -130,7 +130,7 @@ class SynsetDistance(Comparator):
"""
from nltk.corpus import wordnet
from nltk import word_tokenize
from . import utils
from chatterbot import utils
import itertools
tokens1 = word_tokenize(statement.text.lower())

@ -0,0 +1,3 @@
default_app_config = (
'chatterbot.ext.django_chatterbot.apps.DjangoChatterBotConfig'
)

@ -1,5 +1,5 @@
from ...conversation import StatementMixin
from ... import constants
from chatterbot.conversation import StatementMixin
from chatterbot import constants
from django.db import models
from django.apps import apps
from django.utils import timezone

@ -1,5 +1,5 @@
from django.contrib import admin
from .models import (
from chatterbot.ext.django_chatterbot.models import (
Statement, Response, Conversation, Tag
)

@ -3,6 +3,6 @@ from django.apps import AppConfig
class DjangoChatterBotConfig(AppConfig):
name = 'chatter.source.ext.django_chatterbot'
name = 'chatterbot.ext.django_chatterbot'
label = 'django_chatterbot'
verbose_name = 'Django ChatterBot'

@ -2,8 +2,8 @@
These factories are used to generate fake data for testing.
"""
import factory
from . import models
from ... import constants
from chatterbot.ext.django_chatterbot import models
from chatterbot import constants
from factory.django import DjangoModelFactory

@ -11,8 +11,8 @@ class Command(BaseCommand):
can_import_settings = True
def handle(self, *args, **options):
from ..... import ChatBot
from ... import settings
from chatterbot import ChatBot
from chatterbot.ext.django_chatterbot import settings
chatterbot = ChatBot(**settings.CHATTERBOT)

@ -1,4 +1,4 @@
from .abstract_models import (
from chatterbot.ext.django_chatterbot.abstract_models import (
AbstractBaseConversation, AbstractBaseResponse,
AbstractBaseStatement, AbstractBaseTag
)

@ -2,16 +2,16 @@
Default ChatterBot settings for Django.
"""
from django.conf import settings
from ... import constants
from chatterbot import constants
CHATTERBOT_SETTINGS = getattr(settings, 'CHATTERBOT', {})
CHATTERBOT_DEFAULTS = {
'name': 'ChatterBot',
'storage_adapter': 'chatter.source.storage.DjangoStorageAdapter',
'input_adapter': 'chatter.source.input.VariableInputTypeAdapter',
'output_adapter': 'chatter.source.output.OutputAdapter',
'storage_adapter': 'chatterbot.storage.DjangoStorageAdapter',
'input_adapter': 'chatterbot.input.VariableInputTypeAdapter',
'output_adapter': 'chatterbot.output.OutputAdapter',
'django_app_name': constants.DEFAULT_DJANGO_APP_NAME
}

@ -1,8 +1,8 @@
import json
from django.views.generic import View
from django.http import JsonResponse
from ... import ChatBot
from . import settings
from chatterbot import ChatBot
from chatterbot.ext.django_chatterbot import settings
class ChatterBotViewMixin(object):
@ -28,7 +28,7 @@ class ChatterBotViewMixin(object):
Return the conversation for the session if one exists.
Create a new conversation if one does not exist.
"""
from .models import Conversation, Response
from chatterbot.ext.django_chatterbot.models import Conversation, Response
class Obj(object):
def __init__(self):

@ -3,9 +3,9 @@ from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from sqlalchemy.ext.declarative import declared_attr, declarative_base
from ...constants import TAG_NAME_MAX_LENGTH, STATEMENT_TEXT_MAX_LENGTH
from .types import UnicodeString
from ...conversation import StatementMixin
from chatterbot.constants import TAG_NAME_MAX_LENGTH, STATEMENT_TEXT_MAX_LENGTH
from chatterbot.ext.sqlalchemy_app.types import UnicodeString
from chatterbot.conversation import StatementMixin
class ModelBase(object):
@ -73,8 +73,8 @@ class Statement(Base, StatementMixin):
return [tag.name for tag in self.tags]
def get_statement(self):
from ...conversation import Statement as StatementObject
from ...conversation import Response as ResponseObject
from chatterbot.conversation import Statement as StatementObject
from chatterbot.conversation import Response as ResponseObject
statement = StatementObject(
self.text,

@ -1,7 +1,7 @@
from __future__ import unicode_literals
from time import sleep
from . import InputAdapter
from ..conversation import Statement
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement
class Gitter(InputAdapter):

@ -1,7 +1,7 @@
from __future__ import unicode_literals
from time import sleep
from . import InputAdapter
from ..conversation import Statement
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement
class HipChat(InputAdapter):

@ -1,5 +1,5 @@
from __future__ import unicode_literals
from ..adapters import Adapter
from chatterbot.adapters import Adapter
class InputAdapter(Adapter):

@ -1,7 +1,7 @@
from __future__ import unicode_literals
import datetime
from . import InputAdapter
from ..conversation import Statement
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement
class Mailgun(InputAdapter):

@ -1,7 +1,7 @@
from __future__ import unicode_literals
from time import sleep
from . import InputAdapter
from ..conversation import Statement
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement
class Microsoft(InputAdapter):

@ -1,7 +1,7 @@
from __future__ import unicode_literals
from . import InputAdapter
from ..conversation import Statement
from ..utils import input_function
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement
from chatterbot.utils import input_function
class TerminalAdapter(InputAdapter):

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from . import InputAdapter
from ..conversation import Statement
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement
class VariableInputTypeAdapter(InputAdapter):

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from ..adapters import Adapter
from ..utils import import_module
from chatterbot.adapters import Adapter
from chatterbot.utils import import_module
class LogicAdapter(Adapter):
@ -17,8 +17,8 @@ class LogicAdapter(Adapter):
def __init__(self, **kwargs):
super(LogicAdapter, self).__init__(**kwargs)
from ..comparisons import levenshtein_distance
from ..response_selection import get_first_response
from chatterbot.comparisons import levenshtein_distance
from chatterbot.response_selection import get_first_response
# Import string module parameters
if 'statement_comparison_function' in kwargs:

@ -1,5 +1,5 @@
from __future__ import unicode_literals
from ..conversation import Statement
from chatterbot.conversation import Statement
from .best_match import BestMatch

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from . import LogicAdapter
from ..conversation import Statement
from chatterbot.logic import LogicAdapter
from chatterbot.conversation import Statement
class MathematicalEvaluation(LogicAdapter):

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from collections import Counter
from .. import utils
from chatterbot import utils
from .logic_adapter import LogicAdapter
@ -13,7 +13,7 @@ class MultiLogicAdapter(LogicAdapter):
"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
super(MultiLogicAdapter, self).__init__(**kwargs)
# Logic adapters added by the chat bot
self.adapters = []

@ -15,7 +15,7 @@ class SpecificResponseAdapter(LogicAdapter):
def __init__(self, **kwargs):
super(SpecificResponseAdapter, self).__init__(**kwargs)
from ..conversation import Statement
from chatterbot.conversation import Statement
self.input_text = kwargs.get('input_text')

@ -79,7 +79,7 @@ class TimeLogicAdapter(LogicAdapter):
return features
def process(self, statement):
from ..conversation import Statement
from chatterbot.conversation import Statement
now = datetime.now()

@ -1,4 +1,4 @@
from ..adapters import Adapter
from chatterbot.adapters import Adapter
class OutputAdapter(Adapter):

@ -1,5 +1,5 @@
from . import StorageAdapter
from .. import constants
from chatterbot.storage import StorageAdapter
from chatterbot import constants
class DjangoStorageAdapter(StorageAdapter):

@ -1,4 +1,4 @@
from . import StorageAdapter
from chatterbot.storage import StorageAdapter
class Query(object):
@ -116,7 +116,7 @@ class MongoDatabaseAdapter(StorageAdapter):
"""
Return the class for the statement model.
"""
from ..conversation import Statement
from chatterbot.conversation import Statement
# Create a storage-aware statement
statement = Statement
@ -128,7 +128,7 @@ class MongoDatabaseAdapter(StorageAdapter):
"""
Return the class for the response model.
"""
from ..conversation import Response
from chatterbot.conversation import Response
# Create a storage-aware response
response = Response

@ -1,8 +1,8 @@
from . import StorageAdapter
from chatterbot.storage import StorageAdapter
def get_response_table(response):
from ..ext.sqlalchemy_app.models import Response
from chatterbot.ext.sqlalchemy_app.models import Response
return Response(text=response.text, occurrence=response.occurrence)
@ -86,28 +86,28 @@ class SQLStorageAdapter(StorageAdapter):
"""
Return the statement model.
"""
from ..ext.sqlalchemy_app.models import Statement
from chatterbot.ext.sqlalchemy_app.models import Statement
return Statement
def get_response_model(self):
"""
Return the response model.
"""
from ..ext.sqlalchemy_app.models import Response
from chatterbot.ext.sqlalchemy_app.models import Response
return Response
def get_conversation_model(self):
"""
Return the conversation model.
"""
from ..ext.sqlalchemy_app.models import Conversation
from chatterbot.ext.sqlalchemy_app.models import Conversation
return Conversation
def get_tag_model(self):
"""
Return the conversation model.
"""
from ..ext.sqlalchemy_app.models import Tag
from chatterbot.ext.sqlalchemy_app.models import Tag
return Tag
def count(self):
@ -379,14 +379,14 @@ class SQLStorageAdapter(StorageAdapter):
"""
Drop the database attached to a given adapter.
"""
from ..ext.sqlalchemy_app.models import Base
from chatterbot.ext.sqlalchemy_app.models import Base
Base.metadata.drop_all(self.engine)
def create(self):
"""
Populate the database with the tables.
"""
from ..ext.sqlalchemy_app.models import Base
from chatterbot.ext.sqlalchemy_app.models import Base
Base.metadata.create_all(self.engine)
def _session_finish(self, session, statement_text=None):

@ -1,3 +0,0 @@
default_app_config = (
'chatter.source.ext.django_chatterbot.apps.DjangoChatterBotConfig'
)
Loading…
Cancel
Save