Profanity detection and content moderation library with leetspeak, Unicode homoglyph, and ML-powered detection. Use when filtering user-generated content, moderating comments, checking text for profanity, censoring messages, or building content moderation into applications. Supports 24 languages.
可检测规避尝试的脏话检测库,如Leetspeak(f4ck、sh1t)、Unicode技巧(西里尔字母形近字)和混淆文本。
bash
javascript
import { checkProfanity, Filter } from glin-profanity;
// 简单检查
const result = checkProfanity(您的文本内容, {
detectLeetspeak: true,
normalizeUnicode: true,
languages: [english]
});
result.containsProfanity // 布尔值
result.profaneWords // 检测到的脏话数组
result.processedText // 审查后的版本
// 使用Filter实例
const filter = new Filter({
replaceWith: *,
detectLeetspeak: true,
normalizeUnicode: true
});
filter.isProfane(文本) // 布尔值
filter.checkProfanity(文本) // 完整结果对象
python
from glin_profanity import Filter
filter = Filter({
languages: [english],
replace_with: *,
detect_leetspeak: True
})
filter.is_profane(文本) # True/False
filter.check_profanity(文本) # 完整结果字典
tsx
import { useProfanityChecker } from glin-profanity;
function ChatInput() {
const { result, checkText } = useProfanityChecker({
detectLeetspeak: true
});
return (
checkText(e.target.value)} />
);
}
| 特性 | 描述 |
|---|---|
| Leetspeak检测 | f4ck、sh1t、@$$ 等模式 |
| Unicode标准化 |
javascript
const filter = new Filter({
languages: [english, spanish], // 要检查的语言
detectLeetspeak: true, // 捕获 f4ck、sh1t
leetspeakLevel: moderate, // basic | moderate | aggressive
normalizeUnicode: true, // 捕获Unicode技巧
replaceWith: *, // 替换字符
preserveFirstLetter: false, // f vs *
customWords: [badword], // 添加自定义词汇
ignoreWords: [hell], // 白名单词汇
cacheSize: 1000 // LRU缓存条目数
});
javascript
import { analyzeContext } from glin-profanity;
const result = analyzeContext(患者患有乳腺肿瘤, {
domain: medical, // medical | gaming | technical | educational
contextWindow: 3, // 匹配词周围的上下文窗口
confidenceThreshold: 0.7 // 标记的最低置信度
});
javascript
import { batchCheck } from glin-profanity;
const results = batchCheck([
评论1,
评论2,
评论3
], { returnOnlyFlagged: true });
javascript
import { loadToxicityModel, checkToxicity } from glin-profanity/ml;
await loadToxicityModel({ threshold: 0.9 });
const result = await checkToxicity(你太差劲了);
// { toxic: true, categories: { toxicity: 0.92, insult: 0.87 } }
bot.on(message, (msg) => {
if (filter.isProfane(msg.text)) {
deleteMessage(msg);
warnUser(msg.author);
}
});
if (result.containsProfanity) {
return {
valid: false,
issues: result.profaneWords,
suggestion: result.processedText // 审查后的版本
};
}
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 glin-profanity-1776374311 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 glin-profanity-1776374311 技能
skillhub install glin-profanity-1776374311
文件大小: 2.44 KB | 发布时间: 2026-4-17 13:48