Ejemplo n.º 1
0
    def run(self):
        database = DatabaseManager(self._args)
        try:
            character_manager = CharacterManager(database)
            discord_manager = Bot(character_manager,
                                  command_prefix='MG!',
                                  prefix='MG!',
                                  command_attrs=dict(hidden=True))

            self.load_cogs(discord_manager)

            discord_manager.run(self._token)

        except KeyboardInterrupt:
            database.close()
            logging.warning("Exiting...")
            sys.exit(1)
Ejemplo n.º 2
0
import random

from database.configuration import connection_string
from database.database_manager import DatabaseManager
from ml.recommender import Recommender
from Utils.logger import logger

dbmg = DatabaseManager(connection_string)
questions_db = dbmg.select_query(
    "select * from replies", None,
    fetch_to_dict=True)
dbmg.close()

data = {'id':[], 'description':[]}

for question in questions_db:
    content = question['text']
    if content is None:
        content = ""
        logger.error("Question of id {} does not have content".format(question['replies_id']))
    data['id'].append(question['replies_id'])
    data['description'].append(content)

question_recommender = Recommender()
question_recommender.train(data)

rnd = random.randint(0, 20)
for item_to_recommend_index in range(rnd, rnd+rnd):

    print("Current item: ", data['description'][item_to_recommend_index])
    recommended_items = question_recommender.predict(data['id'][item_to_recommend_index], 5)