Deep learning to

detect threat in text

What is Hatescan?

Hatescan contains several machine learning models used for detecting threatening language in texts.

Currently, the API works for English text.

How does it work?

Type a sentence into the text box to see its threatening score. Hatescan returns a percentage that represents the likelihood that someone will perceive the text as threatening.

What does the probability mean?

The probability score does not refer to the degree of threat of the text but rather the likelihood that someone perceives the text as threatening.

Analyse

Hatescan API

Python

import requests
import json

'''
Get threat score for the text from Hatescan API.
The API supports english language text.
'''
def get_threat_probability(text):
    payload = {
        "text": text
    }

    headers = {
        "Content-Type": "application/json; charset=utf-8"
    }

    # Hatescan API url
    api_hatescan_url = 'https://api.hatescan.com/predict/threat'

    # sending post request to the API
    hatescan_response = requests.post(api_hatescan_url, headers=headers, json=payload)

    # return toxic probability
    return hatescan_response.json()


if __name__ == '__main__':
    # sample text
    text = "I am a happy guy."
    threat_probability = get_threat_probability(text)
    print(threat_probability)