支持Leet语、Unicode同形字及机器学习检测的脏话检测与内容审核库。适用于过滤用户生成内容、审核评论、检查脏话、屏蔽消息或在应用中构建内容审核功能。支持24种语言。
Glin Profanity - 内容调和库是一项面向实际任务的技能,主要用于Profanity 检测库可以捕捉到诸如 Leetspeak( f4ck , sh1t), Unicode 诡计( Cyrilic lookalikes) 等逃避尝试, 以及被模糊的文本。它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。
若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;
涉及批量任务时,还应保存进度,避免中断后重复操作。该技能适合用于一次性任务,也可以接入自动化工作流,与其他技能或上层代理配合完成更完整的业务链路;在组合使用时,应明确每一步的输入输出关系,并避免不同步骤之间出现参数冲突。
一款用于检测不当用语的库,可识别各类规避手段,例如 leetspeak(如 f4ck、sh1t)、Unicode 技巧(如西里尔字母形近字)以及混淆文本。
# JavaScript/TypeScript npm install glin-profanity # Python pip install glin-profanity
import { checkProfanity, Filter } from 'glin-profanity';
// 简单检测
const result = checkProfanity("您的文本内容", {
detectLeetspeak: true,
normalizeUnicode: true,
languages: ['english']
});
result.containsProfanity // boolean
result.profaneWords // 检测到的违禁词数组
result.processedText // 已屏蔽处理后的文本
// 使用 Filter 实例
const filter = new Filter({
replaceWith: '***',
detectLeetspeak: true,
normalizeUnicode: true
});
filter.isProfane("text") // boolean
filter.checkProfanity("text") // 完整结果对象
from glin_profanity import Filter
filter = Filter({
"languages": ["english"],
"replace_with": "***",
"detect_leetspeak": True
})
filter.is_profane("text") # True/False
filter.check_profanity("text") # 完整结果字典
import { useProfanityChecker } from 'glin-profanity';
function ChatInput() {
const { result, checkText } = useProfanityChecker({
detectLeetspeak: true
});
return (
checkText(e.target.value)} />
);
}
| 特性 | 说明 |
|---|---|
| leetspeak 检测 | 识别 f4ck、sh1t、@$$ 等模式 |
| Unicode 标准化 | 将西里尔字母 fսck 转换为 fuck |
| 支持 24 种语言 | 包括阿拉伯语、中文、俄语、印地语等 |
| 上下文白名单 | 适配医疗、游戏、技术等专业领域 |
| 机器学习集成 | 可选集成 TensorFlow.js 毒性检测模型 |
| 结果缓存 | 采用 LRU 缓存提升性能 |
const filter = new Filter({
languages: ['english', 'spanish'], // 待检测的语言列表
detectLeetspeak: true, // 启用 leetspeak 检测(如 f4ck、sh1t)
leetspeakLevel: 'moderate', // 可选值:basic | moderate | aggressive
normalizeUnicode: true, // 启用 Unicode 标准化以识别 Unicode 规避手段
replaceWith: '*', // 屏蔽替换字符
preserveFirstLetter: false, // 是否保留首字母(f*** vs ****)
customWords: ['badword'], // 自定义违禁词列表
ignoreWords: ['hell'], // 白名单词汇(不视为违禁词)
cacheSize: 1000 // LRU 缓存条目数
});
import { analyzeContext } from 'glin-profanity';
const result = analyzeContext("该患者患有乳腺肿瘤", {
domain: 'medical', // 可选值:medical | gaming | technical | educational
contextWindow: 3, // 匹配项前后纳入分析的词数
confidenceThreshold: 0.7 // 触发标记所需的最低置信度
});
import { batchCheck } from 'glin-profanity';
const results = batchCheck([
"评论 1",
"评论 2",
"评论 3"
], { returnOnlyFlagged: true });
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 } }
const filter = new Filter({
detectLeetspeak: true,
normalizeUnicode: true,
languages: ['english']
});
bot.on('message', (msg) => {
if (filter.isProfane(msg.text)) {
deleteMessage(msg);
warnUser(msg.author);
}
});
const result = filter.checkProfanity(userContent);
if (result.containsProfanity) {
return {
valid: false,
issues: result.profaneWords,
suggestion: result.processedText // 已屏蔽版本
};
}
相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 133.9万人学习
共49课时 | 82.5万人学习