Skip to content

API for detecting hate speech using a Neural Network and Word2Vec

Notifications You must be signed in to change notification settings

hateflow/hf-backend

Repository files navigation

HateFlow backend

HateFlow can detect and classify inappropriate comments. It is available using an API documented here.

Installation

(tested on Ubuntu 20.04 and Python 3.8)

cd hateflow
pip3 install -r requirements.txt  --no-cache-dir

Training a model

python3 train.py

Evaluating the current model

python3 get_accuracy.py

Hosting the API

This section assumes an installation at /var/hateflow.

sudo mkdir /var/www/nltk_data
sudo mkdir /var/www/gensim-data
sudo chown www-data:www-data /var/www/*data

Apache has to be set up according to the system specific requirements.

Apache configuration file

<VirtualHost *:80>
                ServerName example.org
                ServerAdmin [email protected]

                WSGIDaemonProcess hateflow user=www-data group=www-data threads=5 home=/var/hateflow/
                WSGIScriptAlias / /var/hateflow/main.wsgi

                <Directory /var/hateflow/>
                        WSGIProcessGroup hateflow
                        WSGIApplicationGroup %{GLOBAL}
                        Require all granted
                </Directory>

                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel warn
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>