diff --git a/chatter/chat.py b/chatter/chat.py index eca1056..276f6d8 100644 --- a/chatter/chat.py +++ b/chatter/chat.py @@ -1,9 +1,11 @@ import asyncio +import pathlib from datetime import datetime, timedelta import discord from redbot.core import Config from redbot.core import commands +from redbot.core.data_manager import cog_data_path from chatter.chatterbot import ChatBot from chatter.chatterbot.trainers import ListTrainer @@ -22,11 +24,13 @@ class Chatter: "whitelist": None, "days": 1 } + path: pathlib.Path = cog_data_path(self) + data_path = path / ("database.sqlite3") self.chatbot = ChatBot( "ChatterBot", storage_adapter='chatter.chatterbot.storage.SQLStorageAdapter', - database='./database.sqlite3' + database=str(data_path) ) self.chatbot.set_trainer(ListTrainer) diff --git a/chatter/chatterbot/chatterbot.py b/chatter/chatterbot/chatterbot.py index c7a92cb..08576c3 100644 --- a/chatter/chatterbot/chatterbot.py +++ b/chatter/chatterbot/chatterbot.py @@ -2,10 +2,7 @@ from __future__ import unicode_literals import logging -from . import utils -from .input import InputAdapter -from .output import OutputAdapter -from .storage import StorageAdapter +from chatter.chatterbot import utils class ChatBot(object): @@ -14,7 +11,7 @@ class ChatBot(object): """ def __init__(self, name, **kwargs): - from .logic import MultiLogicAdapter + from chatter.chatterbot.logic import MultiLogicAdapter self.name = name kwargs['name'] = name @@ -33,9 +30,9 @@ class ChatBot(object): output_adapter = kwargs.get('output_adapter', 'chatter.chatterbot.output.OutputAdapter') # Check that each adapter is a valid subclass of it's respective parent - utils.validate_adapter_class(storage_adapter, StorageAdapter) - utils.validate_adapter_class(input_adapter, InputAdapter) - utils.validate_adapter_class(output_adapter, OutputAdapter) + # utils.validate_adapter_class(storage_adapter, StorageAdapter) + # utils.validate_adapter_class(input_adapter, InputAdapter) + # utils.validate_adapter_class(output_adapter, OutputAdapter) self.logic = MultiLogicAdapter(**kwargs) self.storage = utils.initialize_class(storage_adapter, **kwargs) @@ -139,7 +136,7 @@ class ChatBot(object): """ Learn that the statement provided is a valid response. """ - from .conversation import Response + from chatter.chatterbot.conversation import Response if previous_statement: statement.add_response( diff --git a/chatter/chatterbot/comparisons.py b/chatter/chatterbot/comparisons.py index 59efa95..5e253a0 100644 --- a/chatter/chatterbot/comparisons.py +++ b/chatter/chatterbot/comparisons.py @@ -92,7 +92,7 @@ class SynsetDistance(Comparator): """ Download required NLTK corpora if they have not already been downloaded. """ - from .utils import nltk_download_corpus + from chatter.chatterbot.utils import nltk_download_corpus nltk_download_corpus('corpora/wordnet') @@ -100,7 +100,7 @@ class SynsetDistance(Comparator): """ Download required NLTK corpora if they have not already been downloaded. """ - from .utils import nltk_download_corpus + from chatter.chatterbot.utils import nltk_download_corpus nltk_download_corpus('tokenizers/punkt') @@ -108,7 +108,7 @@ class SynsetDistance(Comparator): """ Download required NLTK corpora if they have not already been downloaded. """ - from .utils import nltk_download_corpus + from chatter.chatterbot.utils import nltk_download_corpus nltk_download_corpus('corpora/stopwords') @@ -177,7 +177,7 @@ class SentimentComparison(Comparator): Download the NLTK vader lexicon for sentiment analysis that is required for this algorithm to run. """ - from .utils import nltk_download_corpus + from chatter.chatterbot.utils import nltk_download_corpus nltk_download_corpus('sentiment/vader_lexicon') @@ -252,7 +252,7 @@ class JaccardSimilarity(Comparator): Download the NLTK wordnet corpora that is required for this algorithm to run only if the corpora has not already been downloaded. """ - from .utils import nltk_download_corpus + from chatter.chatterbot.utils import nltk_download_corpus nltk_download_corpus('corpora/wordnet') diff --git a/chatter/chatterbot/logic/__init__.py b/chatter/chatterbot/logic/__init__.py index 1930556..8a6cc97 100644 --- a/chatter/chatterbot/logic/__init__.py +++ b/chatter/chatterbot/logic/__init__.py @@ -1,5 +1,5 @@ -from .best_match import BestMatch from .logic_adapter import LogicAdapter +from .best_match import BestMatch from .low_confidence import LowConfidenceAdapter from .mathematical_evaluation import MathematicalEvaluation from .multi_adapter import MultiLogicAdapter diff --git a/chatter/chatterbot/logic/best_match.py b/chatter/chatterbot/logic/best_match.py index 5c48121..f19fc99 100644 --- a/chatter/chatterbot/logic/best_match.py +++ b/chatter/chatterbot/logic/best_match.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from .logic_adapter import LogicAdapter +from chatter.chatterbot.logic import LogicAdapter class BestMatch(LogicAdapter): diff --git a/chatter/chatterbot/logic/low_confidence.py b/chatter/chatterbot/logic/low_confidence.py index 585cf20..2d33bba 100644 --- a/chatter/chatterbot/logic/low_confidence.py +++ b/chatter/chatterbot/logic/low_confidence.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals from chatter.chatterbot.conversation import Statement -from .best_match import BestMatch +from chatter.chatterbot.logic import BestMatch class LowConfidenceAdapter(BestMatch): diff --git a/chatter/chatterbot/logic/multi_adapter.py b/chatter/chatterbot/logic/multi_adapter.py index 6cfe30f..5ae79f4 100644 --- a/chatter/chatterbot/logic/multi_adapter.py +++ b/chatter/chatterbot/logic/multi_adapter.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals from collections import Counter from chatter.chatterbot import utils -from .logic_adapter import LogicAdapter +from chatter.chatterbot.logic import LogicAdapter class MultiLogicAdapter(LogicAdapter): diff --git a/chatter/chatterbot/logic/no_knowledge_adapter.py b/chatter/chatterbot/logic/no_knowledge_adapter.py index 55208b4..848b23e 100644 --- a/chatter/chatterbot/logic/no_knowledge_adapter.py +++ b/chatter/chatterbot/logic/no_knowledge_adapter.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from .logic_adapter import LogicAdapter +from chatter.chatterbot.logic import LogicAdapter class NoKnowledgeAdapter(LogicAdapter): diff --git a/chatter/chatterbot/logic/specific_response.py b/chatter/chatterbot/logic/specific_response.py index 101dd3b..ef7a630 100644 --- a/chatter/chatterbot/logic/specific_response.py +++ b/chatter/chatterbot/logic/specific_response.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from .logic_adapter import LogicAdapter +from chatter.chatterbot.logic import LogicAdapter class SpecificResponseAdapter(LogicAdapter): diff --git a/chatter/chatterbot/logic/time_adapter.py b/chatter/chatterbot/logic/time_adapter.py index 72902e2..d4bbd15 100644 --- a/chatter/chatterbot/logic/time_adapter.py +++ b/chatter/chatterbot/logic/time_adapter.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from datetime import datetime -from .logic_adapter import LogicAdapter +from chatter.chatterbot.logic import LogicAdapter class TimeLogicAdapter(LogicAdapter): diff --git a/chatter/chatterbot/output/__init__.py b/chatter/chatterbot/output/__init__.py index 80abe4f..52c3534 100644 --- a/chatter/chatterbot/output/__init__.py +++ b/chatter/chatterbot/output/__init__.py @@ -1,8 +1,8 @@ +from .output_adapter import OutputAdapter from .gitter import Gitter from .hipchat import HipChat from .mailgun import Mailgun from .microsoft import Microsoft -from .output_adapter import OutputAdapter from .terminal import TerminalAdapter __all__ = ( diff --git a/chatter/chatterbot/output/gitter.py b/chatter/chatterbot/output/gitter.py index ba01fa8..664d341 100644 --- a/chatter/chatterbot/output/gitter.py +++ b/chatter/chatterbot/output/gitter.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from .output_adapter import OutputAdapter +from chatter.chatterbot.output import OutputAdapter class Gitter(OutputAdapter): diff --git a/chatter/chatterbot/output/hipchat.py b/chatter/chatterbot/output/hipchat.py index 2546092..20029fa 100644 --- a/chatter/chatterbot/output/hipchat.py +++ b/chatter/chatterbot/output/hipchat.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import json -from .output_adapter import OutputAdapter +from chatter.chatterbot.output import OutputAdapter class HipChat(OutputAdapter): diff --git a/chatter/chatterbot/output/mailgun.py b/chatter/chatterbot/output/mailgun.py index 71a9a7a..d022a51 100644 --- a/chatter/chatterbot/output/mailgun.py +++ b/chatter/chatterbot/output/mailgun.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from .output_adapter import OutputAdapter +from chatter.chatterbot.output import OutputAdapter class Mailgun(OutputAdapter): diff --git a/chatter/chatterbot/output/microsoft.py b/chatter/chatterbot/output/microsoft.py index 816fc97..4f2426a 100644 --- a/chatter/chatterbot/output/microsoft.py +++ b/chatter/chatterbot/output/microsoft.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import json -from .output_adapter import OutputAdapter +from chatter.chatterbot.output import OutputAdapter class Microsoft(OutputAdapter): diff --git a/chatter/chatterbot/output/terminal.py b/chatter/chatterbot/output/terminal.py index 8ab63e1..005d0ae 100644 --- a/chatter/chatterbot/output/terminal.py +++ b/chatter/chatterbot/output/terminal.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from .output_adapter import OutputAdapter +from chatter.chatterbot.output import OutputAdapter class TerminalAdapter(OutputAdapter): diff --git a/chatter/chatterbot/trainers.py b/chatter/chatterbot/trainers.py index 042019e..f3a4165 100644 --- a/chatter/chatterbot/trainers.py +++ b/chatter/chatterbot/trainers.py @@ -2,8 +2,8 @@ import logging import os import sys -from . import utils -from .conversation import Statement, Response +from chatter.chatterbot import utils +from chatter.chatterbot.conversation import Statement, Response class Trainer(object): @@ -127,7 +127,7 @@ class ChatterBotCorpusTrainer(Trainer): def __init__(self, storage, **kwargs): super(ChatterBotCorpusTrainer, self).__init__(storage, **kwargs) - from .corpus import Corpus + from chatter.chatterbot.corpus import Corpus self.corpus = Corpus() diff --git a/chatter/chatterbot/utils.py b/chatter/chatterbot/utils.py index e18549e..9785bd4 100644 --- a/chatter/chatterbot/utils.py +++ b/chatter/chatterbot/utils.py @@ -46,7 +46,7 @@ def validate_adapter_class(validate_class, adapter_class): :raises: Adapter.InvalidAdapterTypeException """ - from .adapters import Adapter + from chatter.chatterbot.adapters import Adapter # If a dictionary was passed in, check if it has an import_path attribute if isinstance(validate_class, dict):