百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

sensitive

> 编程语言
开源

敏感词查找,验证,过滤和替换 FindAll, Validate, Filter and Replace words.

702 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

敏感词查找,验证,过滤和替换 FindAll, Validate, Filter and Replace words.

Sensitive

敏感词查找,验证,过滤和替换

FindAll, Validate, Filter and Replace words.

新增分支Aho-Corasick以支持AC自动机

用法

go
package main

import (
	"fmt"
	"github.com/importcjj/sensitive"
)

func main() {
	filter := sensitive.New()
	filter.LoadWordDict("path/to/dict")
	// Do something
}

AddWord

添加敏感词

go
filter.AddWord("垃圾")

Replace

把词语中的字符替换成指定的字符,这里的字符指的是rune字符,比如*就是'*'。

go
filter.Replace("这篇文章真的好垃圾", '*')
// output => 这篇文章真的好**

Filter

直接移除词语

go
filter.Filter("这篇文章真的好垃圾啊")
// output => 这篇文章真的好啊

FindIn

查找并返回第一个敏感词,如果没有则返回false

go
filter.FindIn("这篇文章真的好垃圾")
// output => true, 垃圾

Validate

验证内容是否ok,如果含有敏感词,则返回false和第一个敏感词。

go
filter.Validate("这篇文章真的好垃圾")
// output => false, 垃圾

FindAll

查找内容中的全部敏感词,以数组返回。

go
filter.FindAll("这篇文章真的好垃圾")
// output => [垃圾]

LoadNetWordDict

加载网络词库。

go
filter.LoadNetWordDict("https://raw.githubusercontent.com/importcjj/sensitive/master/dict/dict.txt")

UpdateNoisePattern

设置噪音模式,排除噪音字符。

go
// failed
filter.FindIn("这篇文章真的好垃x圾")      // false
filter.UpdateNoisePattern(`x`)
// success
filter.FindIn("这篇文章真的好垃x圾")      // true, 垃圾
filter.Validate("这篇文章真的好垃x圾")    // False, 垃圾

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Godirtywordsfiltergogolang

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言