SRK-CobuildX's picture
Release v0.1
d770b7e verified
Raw History Blame Contribute Delete
1.15 kB
# Copyright 2026 Cobuild Tech Private Limited
# SPDX-License-Identifier: Apache-2.0
"""Run from the model folder: python example.py (every text below is invented for this example)"""
from cbx_profanity import ProfanityClassifier
clf = ProfanityClassifier(".")
texts = [
"Thanks for sharing the recipe, my mother makes it the same way every Diwali.",
"शाम को बारिश हो सकती है, छाता साथ रखना।", # Hindi: it may rain in the evening, take an umbrella
"நாளைக்கு கூட்டம் பத்து மணிக்கு தொடங்கும்.", # Tamil: tomorrow's meeting starts at ten
"bc aaj traffic bahut kharab hai, ek ghanta phas gaya", # romanized Hindi: swearing, not aimed at anyone
"saala harami, teri aukaat kya hai", # romanized Hindi: abuse aimed at the reader
"What a stupid useless idiot, nobody asked for your opinion.",
]
for text, r in zip(texts, clf.classify(texts)):
print(f"{'OFFENSIVE' if r['offensive'] else 'clean '} {','.join(r['labels']) or '-':<24} {text}")