Giter Site home page Giter Site logo

knightswatch's Introduction

The KnightsWatch

ML moderation bot for Reddit.

Uses machine learning to flag down comments that are possibly toxic.

Based from python chatbot by Tech with Tim.

Installation

  1. Requires Python 3.6. Virtual environment recommended.
  2. Use pip3 install -r requirements.txt to install dependencies.
  3. Configure the praw.ini file, located at env/lib/python3.6/site-packages/praw, with your bot tokens. PRAW Documentation
  4. Edit the settings.json to match your PRAW configuration. Copy the sample configuration from the sample-config folder.
  5. Create the intents.json file in the training folder. You can copy the sample configuration from the sample-config folder or modify the categories and labels.

Training

Method 1

Use this method if there is no model trained yet. This method will gather the latest comments and output them. Sort the comments and it will automatically populate the intents.json file for you.

  1. Run the collecter.py script.
  2. Comments will be collected automatically and will await user input.
  3. Type:
    • a: If the comment is acceptable.
    • n: If the comment is neutral.
    • w: If the comment is considered to be a warning.
    • Type any other character to skip the entry.
  4. Press Enter to submit.
  5. Rebuild the model as needed.

Method 2

This method will gather the latest comments and output them. It will display what it currently thinks a comment is categorized as. Sort the comments and it will automatically populate the intents.json file for you.

  1. Run the collecter_trainer.py script.
  2. Comments will be collected automatically and will await user input.
  3. Type:
    • a: If the comment is acceptable.
    • n: If the comment is neutral.
    • w: If the comment is considered to be a warning.
    • Type any other character to skip the entry.
  4. Press Enter to submit.
  5. Rebuild the model as needed.

Method 3

Manual entry method.

  1. Run the self_assign.py script.
  2. Enter a comment, it will be sanitized and re-outputted.
  3. Type:
    • a: If the comment is acceptable.
    • n: If the comment is neutral.
    • w: If the comment is considered to be a warning.
    • Type any other character to skip the entry.
  4. Press Enter to submit.

Notes

  • Comments are sanitized of all punctuation and potential offending characters.
  • Training data and models have been removed for public release.

knightswatch's People

Contributors

mikojimnz avatar

Stargazers

Cloei avatar Josh avatar Chris Dailey avatar

knightswatch's Issues

Handle HTTP Exceptions

Implement proper handling of HTTP 503 Exceptions.

Expected Behavior:
Except error, wait 60 seconds.

Screen Shot 2020-10-03 at 1 22 48 PM

Task Already Running

Describe the bug
read_comments() loop does not properly restart when an exception occurs.

Expected behavior
read_comments() should restart after sleep and exception occurs.

Screen Shot 2020-11-07 at 12 24 49 PM

RuntimeError: Task is already launched and is not completed.

Ignoring exception in on_ready
Traceback (most recent call last):
File "/home/ubuntu/KnightsWatch/env/lib/python3.6/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "bot.py", line 288, in on_ready
read_comments.start()
File "/home/ubuntu/KnightsWatch/env/lib/python3.6/site-packages/discord/ext/tasks/__init__.py", line 205, in start
raise RuntimeError('Task is already launched and is not completed.')
RuntimeError: Task is already launched and is not completed.

Retrain model on schedule

Describe the solution you'd like
Create a scheduled task to perform model retraining that can be called when ever.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.