Skip to main content

Mood adaptive chatbot

Project description

MoodBot is a mood adaptive chatbot that calculates moods from an input statement and generates an response. MoodBot was created as a project for Los Altos Hacks VI.

MoodBot works by finding sentence similarities using Cosine Similarity. The sentenced are tokenized using NLTK to plug into the cosine formula. We then compared already trained input and output statements agianst each other to find matches that are within a specified threshold.

MoodBot when imported, has no pre-trained data. To train MoodBot, you can use it's training functions to train data from .json files. MoodBot finds conversations within the raw message files by finding time proximity between messages and checking for repeat message authors. After a conversation with one input statement and one output statement is created, MoodBot can find the best matching input statement to an output statement using self.response.

Basic Example:

from moodbot import discord_trainer
from moodbot import chatbot
import json

trainer = discord_trainer(token)
raw_data = trainer.query_channel(CHANNEL_ID, limit=10000)
data = []
for message in raw_data:
    data.append({
        'content': message.content,
        'author': message.author_id,
        'timestamp': message.timestamp,
    })

# load into json
with open(f'data/CHANNEL_ID.json', 'w') as file:
    file.write(json.dumps(data, indent=4))

client = chatbot()
client.train('data/CHANNEL_ID')

print(client.response('Hello!').content)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moodbot-1.0.8.tar.gz (5.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page