commit
02081d4256
@ -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)
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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')
|
||||
|
||||
|
@ -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
|
||||
|
@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .logic_adapter import LogicAdapter
|
||||
from chatter.chatterbot.logic import LogicAdapter
|
||||
|
||||
|
||||
class BestMatch(LogicAdapter):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .logic_adapter import LogicAdapter
|
||||
from chatter.chatterbot.logic import LogicAdapter
|
||||
|
||||
|
||||
class NoKnowledgeAdapter(LogicAdapter):
|
||||
|
@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .logic_adapter import LogicAdapter
|
||||
from chatter.chatterbot.logic import LogicAdapter
|
||||
|
||||
|
||||
class SpecificResponseAdapter(LogicAdapter):
|
||||
|
@ -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):
|
||||
|
@ -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__ = (
|
||||
|
@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .output_adapter import OutputAdapter
|
||||
from chatter.chatterbot.output import OutputAdapter
|
||||
|
||||
|
||||
class Gitter(OutputAdapter):
|
||||
|
@ -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):
|
||||
|
@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .output_adapter import OutputAdapter
|
||||
from chatter.chatterbot.output import OutputAdapter
|
||||
|
||||
|
||||
class Mailgun(OutputAdapter):
|
||||
|
@ -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):
|
||||
|
@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .output_adapter import OutputAdapter
|
||||
from chatter.chatterbot.output import OutputAdapter
|
||||
|
||||
|
||||
class TerminalAdapter(OutputAdapter):
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user