From 2853910caf568379e79e2cd9925bb1f8d0c84a1e Mon Sep 17 00:00:00 2001 From: bobloy Date: Thu, 16 Aug 2018 14:17:27 -0400 Subject: [PATCH 1/8] better path? --- chatter/chat.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chatter/chat.py b/chatter/chat.py index eca1056..c4939d5 100644 --- a/chatter/chat.py +++ b/chatter/chat.py @@ -1,4 +1,5 @@ import asyncio +import pathlib from datetime import datetime, timedelta import discord @@ -7,7 +8,7 @@ from redbot.core import commands from chatter.chatterbot import ChatBot from chatter.chatterbot.trainers import ListTrainer - +from redbot.core.data_manager import cog_data_path class Chatter: """ @@ -22,11 +23,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=data_path ) self.chatbot.set_trainer(ListTrainer) From 47e7f46e2e67a38a00bd9cbd7388576e477a8f45 Mon Sep 17 00:00:00 2001 From: bobloy Date: Thu, 16 Aug 2018 14:25:22 -0400 Subject: [PATCH 2/8] gotta be str --- chatter/chat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chatter/chat.py b/chatter/chat.py index c4939d5..9b0b6ef 100644 --- a/chatter/chat.py +++ b/chatter/chat.py @@ -10,6 +10,7 @@ from chatter.chatterbot import ChatBot from chatter.chatterbot.trainers import ListTrainer from redbot.core.data_manager import cog_data_path + class Chatter: """ This cog trains a chatbot that will talk like members of your Guild @@ -29,7 +30,7 @@ class Chatter: self.chatbot = ChatBot( "ChatterBot", storage_adapter='chatter.chatterbot.storage.SQLStorageAdapter', - database=data_path + database=str(data_path) ) self.chatbot.set_trainer(ListTrainer) From b9055e43ca02e39ac27a07343368ac4813016fa7 Mon Sep 17 00:00:00 2001 From: bobloy Date: Thu, 16 Aug 2018 14:38:30 -0400 Subject: [PATCH 3/8] better imports --- chatter/chatterbot/logic/best_match.py | 2 +- chatter/chatterbot/logic/low_confidence.py | 2 +- chatter/chatterbot/logic/multi_adapter.py | 2 +- chatter/chatterbot/logic/no_knowledge_adapter.py | 2 +- chatter/chatterbot/logic/specific_response.py | 2 +- chatter/chatterbot/logic/time_adapter.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) 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): From 5d9ea59386cf3b19525faf729f5678fc05369529 Mon Sep 17 00:00:00 2001 From: bobloy Date: Thu, 16 Aug 2018 14:43:50 -0400 Subject: [PATCH 4/8] even more import changes --- chatter/chatterbot/chatterbot.py | 8 ++++---- chatter/chatterbot/output/gitter.py | 2 +- chatter/chatterbot/output/hipchat.py | 2 +- chatter/chatterbot/output/mailgun.py | 2 +- chatter/chatterbot/output/microsoft.py | 2 +- chatter/chatterbot/output/terminal.py | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/chatter/chatterbot/chatterbot.py b/chatter/chatterbot/chatterbot.py index c7a92cb..765e47c 100644 --- a/chatter/chatterbot/chatterbot.py +++ b/chatter/chatterbot/chatterbot.py @@ -3,9 +3,9 @@ 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.input import InputAdapter +from chatter.chatterbot.output import OutputAdapter +from chatter.chatterbot.storage import StorageAdapter class ChatBot(object): @@ -14,7 +14,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 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): From 6364b209d1360262ca76aca1d3ba8da77e037a38 Mon Sep 17 00:00:00 2001 From: bobloy Date: Thu, 16 Aug 2018 14:48:43 -0400 Subject: [PATCH 5/8] ALL the imports --- chatter/chatterbot/chatterbot.py | 4 ++-- chatter/chatterbot/comparisons.py | 10 +++++----- chatter/chatterbot/trainers.py | 6 +++--- chatter/chatterbot/utils.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/chatter/chatterbot/chatterbot.py b/chatter/chatterbot/chatterbot.py index 765e47c..988482f 100644 --- a/chatter/chatterbot/chatterbot.py +++ b/chatter/chatterbot/chatterbot.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import logging -from . import utils +from chatter.chatterbot import utils from chatter.chatterbot.input import InputAdapter from chatter.chatterbot.output import OutputAdapter from chatter.chatterbot.storage import StorageAdapter @@ -139,7 +139,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/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): From 67fc739ca86ddd12383f0a196613cac04aad4695 Mon Sep 17 00:00:00 2001 From: bobloy Date: Thu, 16 Aug 2018 14:51:57 -0400 Subject: [PATCH 6/8] Don't validate adapters --- chatter/chatterbot/chatterbot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chatter/chatterbot/chatterbot.py b/chatter/chatterbot/chatterbot.py index 988482f..d6e9cea 100644 --- a/chatter/chatterbot/chatterbot.py +++ b/chatter/chatterbot/chatterbot.py @@ -33,9 +33,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) From f9720736ca80388aaaeb7c22bcebe8e1fb1ef2e2 Mon Sep 17 00:00:00 2001 From: bobloy Date: Thu, 16 Aug 2018 15:07:14 -0400 Subject: [PATCH 7/8] add message --- chatter/chat.py | 2 +- chatter/chatterbot/chatterbot.py | 3 --- chatter/chatterbot/input/__init__.py | 2 +- chatter/chatterbot/storage/__init__.py | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/chatter/chat.py b/chatter/chat.py index 9b0b6ef..276f6d8 100644 --- a/chatter/chat.py +++ b/chatter/chat.py @@ -5,10 +5,10 @@ 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 -from redbot.core.data_manager import cog_data_path class Chatter: diff --git a/chatter/chatterbot/chatterbot.py b/chatter/chatterbot/chatterbot.py index d6e9cea..08576c3 100644 --- a/chatter/chatterbot/chatterbot.py +++ b/chatter/chatterbot/chatterbot.py @@ -3,9 +3,6 @@ from __future__ import unicode_literals import logging from chatter.chatterbot import utils -from chatter.chatterbot.input import InputAdapter -from chatter.chatterbot.output import OutputAdapter -from chatter.chatterbot.storage import StorageAdapter class ChatBot(object): diff --git a/chatter/chatterbot/input/__init__.py b/chatter/chatterbot/input/__init__.py index 53c53f9..625b583 100644 --- a/chatter/chatterbot/input/__init__.py +++ b/chatter/chatterbot/input/__init__.py @@ -1,6 +1,6 @@ -from .input_adapter import InputAdapter from .gitter import Gitter from .hipchat import HipChat +from .input_adapter import InputAdapter from .mailgun import Mailgun from .microsoft import Microsoft from .terminal import TerminalAdapter diff --git a/chatter/chatterbot/storage/__init__.py b/chatter/chatterbot/storage/__init__.py index 77d3e04..c456292 100644 --- a/chatter/chatterbot/storage/__init__.py +++ b/chatter/chatterbot/storage/__init__.py @@ -1,6 +1,6 @@ -from .storage_adapter import StorageAdapter from .mongodb import MongoDatabaseAdapter from .sql_storage import SQLStorageAdapter +from .storage_adapter import StorageAdapter __all__ = ( 'StorageAdapter', From daffa3e1556ccd33dc08f030d1b89191cb07c6b3 Mon Sep 17 00:00:00 2001 From: bobloy Date: Thu, 16 Aug 2018 15:12:55 -0400 Subject: [PATCH 8/8] corrected imports --- chatter/chatterbot/input/__init__.py | 2 +- chatter/chatterbot/logic/__init__.py | 2 +- chatter/chatterbot/output/__init__.py | 2 +- chatter/chatterbot/storage/__init__.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chatter/chatterbot/input/__init__.py b/chatter/chatterbot/input/__init__.py index 625b583..53c53f9 100644 --- a/chatter/chatterbot/input/__init__.py +++ b/chatter/chatterbot/input/__init__.py @@ -1,6 +1,6 @@ +from .input_adapter import InputAdapter from .gitter import Gitter from .hipchat import HipChat -from .input_adapter import InputAdapter from .mailgun import Mailgun from .microsoft import Microsoft from .terminal import TerminalAdapter 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/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/storage/__init__.py b/chatter/chatterbot/storage/__init__.py index c456292..77d3e04 100644 --- a/chatter/chatterbot/storage/__init__.py +++ b/chatter/chatterbot/storage/__init__.py @@ -1,6 +1,6 @@ +from .storage_adapter import StorageAdapter from .mongodb import MongoDatabaseAdapter from .sql_storage import SQLStorageAdapter -from .storage_adapter import StorageAdapter __all__ = ( 'StorageAdapter',