Medical Term Detection is an optional capability that is made available as part of Sightengine's Text Moderation APIs. This capability is useful to detect if user-generated texts (comments, messages, posts, reviews, usernames, etc.) contain words related to medical drugs.
Other categories are also available through the Text Moderation API, for instance Extremism Detection, Drug Detection and Weapon Detection.
If you have images or videos, you might also want to use the Medical drug Detection API for Visual content.
Detected text items are common names of medication used against pain, depression, anxiety, insomnia, obesity and erectile dysfunction, but also names of molecules found in these medicines. These topics are all sensitive issues as they could be a sign of a feeling of insecurity, or result in a dependence or addiction to the medication used to treat or control them.
Here are a few examples of the names of medication that are detected:
Treated issue | Example |
pain |
fentanyl |
depression |
prozac |
anxiety |
valium |
insomnia |
flurazepam |
obesity |
bontril |
erectile dysfunction |
viagra |
As for Profanity Detection, the API also returns an intensity score for each medical term, under the intensity field. This intensity level depends on how the medication is made available:
Intensity | Description |
high |
The most unsafe level, with medicines that are only available under prescription and for which the selling, exchange or simple giving away in a private circle would be a serious concern. |
medium |
Medium level, with medicines that are available either over the counter or under prescription and for which the selling, exchange or simple giving away in a private circle would be a reasonable concern. |
low |
Lowest level, with medicines only available over the counter for which the selling, exchange or simple giving away in a private circle could be a lower concern. |
The API is a lot stronger than simple word-based filters. It catches not only exact medical terms but also all kinds of variations (millions of them) that might be used to evade filtering while smartly ignoring false positives.
Here are a few examples of the types of obfuscations that will be caught (not exhaustive):
Obfuscation | Example |
Repetitions | viaaaagrrrra |
Insertions | b**o_nt- r -il |
Obfuscation and Special characters | 🄿®øź🄐© |
Spelling mistakes and phonetic variations | xanaks |
Leet speak | \/aL!|_|m |
Smart embeddings | cialisaddict but not socialism |
The Medical category can be activated for all languages supported by the Text Moderation API. Medical terms are typically considered to be international as they are proper nouns of medication that are known and used worldwide (tramadol, xanax, etc.).
The Medical Category can be activated as part of Standard Text Moderation and Username Moderation. To activate this category, you need to add an extra request parameter named categories. This parameter is a comma-separated list of categories you want to activate. For medical term detection, its value would be medical
Let's say you want to detect references to medical drugs in the following text item:
got some a1pr@z()lam?
Simply send a POST request containing the UTF-8 formatted text along with the comma separated list of categories you want to detect and the ISO 639-1 language code (such as en for english). Here is an example:
curl -X POST 'https://api.sightengine.com/1.0/text/check.json' \
-F 'text=got some a1pr@z()lam?' \
-F 'lang=en' \
-F 'categories=medical' \
-F 'mode=rules' \
-F 'api_user={api_user}' \
-F 'api_secret={api_secret}'
# this example uses requests
import requests
import json
data = {
'text': 'got some a1pr@z()lam?',
'mode': 'rules',
'lang': 'en',
'categories': 'medical',
'api_user': '{api_user}',
'api_secret': '{api_secret}'
}
r = requests.post('https://api.sightengine.com/1.0/text/check.json', data=data)
output = json.loads(r.text)
$params = array(
'text' => 'got some a1pr@z()lam?',
'lang' => 'en',
'categories' => 'medical',
'mode' => 'rules',
'api_user' => '{api_user}',
'api_secret' => '{api_secret}',
);
// this example uses cURL
$ch = curl_init('https://api.sightengine.com/1.0/text/check.json');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$response = curl_exec($ch);
curl_close($ch);
$output = json_decode($response, true);
// this example uses axios and form-data
const axios = require('axios');
const FormData = require('form-data');
data = new FormData();
data.append('text', 'got some a1pr@z()lam?');
data.append('lang', 'en');
data.append('categories', 'medical');
data.append('mode', 'rules');
data.append('api_user', '{api_user}');
data.append('api_secret', '{api_secret}');
axios({
url: 'https://api.sightengine.com/1.0/text/check.json',
method:'post',
data: data,
headers: data.getHeaders()
})
.then(function (response) {
// on success: handle response
console.log(response.data);
})
.catch(function (error) {
// handle error
if (error.response) console.log(error.response.data);
else console.log(error.message);
});
See request parameter description
Parameter | Type | Description |
text | string | UTF-8 encoded text to moderate |
mode | string | comma-separated list of modes. Modes are rules for the rule-based model or ml for ML models |
categories | string | comma-separated list of categories to check. Possible values: profanity, personal, link, drug, weapon, violence, self-harm, medical, extremism, spam, content-trade, money-transaction (optional) |
lang | string | comma-separated list of target languages |
opt_countries | string | comma-separated list of target countries for phone number detection (optional) |
list | string | id of a custom list to be used for rule-based moderation (optional) |
api_user | string | your API user id |
api_secret | string | your API secret |
The JSON response contains a description of profanities with positions within the text string.
{
"status": "success",
"request": {
"id": "req_c2lMeJnezdvrMUzezMMjB",
"timestamp": 1655367252.21477,
"operations": 1
},
"profanity": {
"matches": []
},
"personal": {
"matches": []
},
"link": {
"matches": []
},
"medical": {
"matches": [
{
"type": "medical",
"match": "alprazolam",
"start": 9,
"end": 19
}
]
}
}
See our full list of Text models for details on other filters and checks you can run on your text content. You might also want to check our Image & Video models to moderate images and videos. This includes moderation of text in images/videos.
Was this page helpful?