This project provides a Dockerized Flask service for detecting hate speech in tweets using the cardiffnlp/twitter-roberta-base-hate-latest model. The API accepts a tweet in the request body and returns 0 for non-hate speech and 1 for hate speech.
Note: Downloading dependencies can take up to 20 minutes, depending on your internet speed.
git clone https://github.com/wolffbe/twitter-hate-speech-api.git
cd twitter-hate-speech-api
docker build -t twitter-hate-detector .
docker run -p 8000:8000 twitter-hate-detector
pip install -r requirements.txt
python main.py
POST /detectRequest Body:
{
"tweet": "Your tweet text here"
}
Response:
{
"hate_speech": 0 // or 1 for hate speech
}
An example of a hate speech detection request:
curl -X POST http://localhost:8000/detect -H "Content-Type: application/json" -d '{"tweet": "Illegal immigrants steal!"}'
curl -X POST http://localhost:8000/detect -H "Content-Type: application/json" -d "{\"tweet\":\"Illegal immigrants steal!\"}"
{
"hate_speech": 1
}
An example of a non-hate speech detection request:
curl -X POST http://localhost:8000/detect -H "Content-Type: application/json" -d '{"tweet": "I hope you have a wonderful day!"}'
curl -X POST http://localhost:8000/detect -H "Content-Type: application/json" -d "{\"tweet\":\"I hope you have a wonderful day!\"}"
{
"hate_speech": 0
}
2 commits
Python
88.0%
Dockerfile
12.0%
This project provides a Dockerized Flask service for detecting hate speech in tweets using the cardiffnlp/twitter-roberta-base-hate-latest model. The API accepts a tweet in the request body and returns 0 for non-hate speech and 1 for hate speech.
Note: Downloading dependencies can take up to 20 minutes, depending on your internet speed.
git clone https://github.com/wolffbe/twitter-hate-speech-api.git
cd twitter-hate-speech-api
docker build -t twitter-hate-detector .
docker run -p 8000:8000 twitter-hate-detector
pip install -r requirements.txt
python main.py
POST /detectRequest Body:
{
"tweet": "Your tweet text here"
}
Response:
{
"hate_speech": 0 // or 1 for hate speech
}
An example of a hate speech detection request:
curl -X POST http://localhost:8000/detect -H "Content-Type: application/json" -d '{"tweet": "Illegal immigrants steal!"}'
curl -X POST http://localhost:8000/detect -H "Content-Type: application/json" -d "{\"tweet\":\"Illegal immigrants steal!\"}"
{
"hate_speech": 1
}
An example of a non-hate speech detection request:
curl -X POST http://localhost:8000/detect -H "Content-Type: application/json" -d '{"tweet": "I hope you have a wonderful day!"}'
curl -X POST http://localhost:8000/detect -H "Content-Type: application/json" -d "{\"tweet\":\"I hope you have a wonderful day!\"}"
{
"hate_speech": 0
}
2 commits
Python
88.0%
Dockerfile
12.0%