importcjj / sensitive Goto Github PK
View Code? Open in Web Editor NEW敏感词查找,验证,过滤和替换 🤓 FindAll, Validate, Filter and Replace words.
License: MIT License
敏感词查找,验证,过滤和替换 🤓 FindAll, Validate, Filter and Replace words.
License: MIT License
代码:
fmt.Println(filter.Replace("hello", 42))
fmt.Println(filter.Replace("hello world", 42))
fmt.Println(filter.Replace("人", 42))
fmt.Println(filter.Replace("不办人事 人", 42))
输出结果:
hell*
hello worl*
*
功能:程序初始化载入到word,后续请求使用word这个指针直接处理即可。但又需要定时刷新词库,但如果重新AddWord会导致内存上涨,如何先释放后重新addWord
err := filter.LoadNetWordDict("https://raw.githubusercontent.com/importcjj/sensitive/master/dict/dict.txt")
fmt.Println(err)
【Get "https://raw.githubusercontent.com/importcjj/sensitive/master/dict/dict.txt": dial tcp: lookup raw.githubusercontent.com: getaddrinfow: The requested name is valid, but no data of the requested type was found.】
请问这个问题如何解决?期待您的解答,谢谢!
package wordpackage_test
import (
"github.com/importcjj/sensitive"
"testing"
)
// 范例
func TestFilterExample(t *testing.T) {
filter := sensitive.New()
filter.AddWord("这句话应被屏蔽")
actual := filter.Replace("这 句 话 应 被 屏 蔽", '*')
expect := "*******"
if actual != expect {
t.Error("屏蔽失败")
}
}
上方是测试用例,过滤语句中如果含noise,会导致替换失败,目前还不支持测试用例里的这种用法,可以加入支持吗?
open ../dict/dict.txt: The system cannot find the path specified.
很奇怪的一件事,无法加载显示ioutil.ReadFile(path)这里出错,但是我自己重新写了一个加载文件的方法,采用绝对路径,可以加载成功,不知道问题出在哪里
不能删除已生成的树的节点吗
你的这个库在本地环境使用关键字过滤是正常的,放到服务器的时候就用不了
服务上使用关键查询不管输入什么内容 都是匹配关键字成功 可是匹配出来的关键字是空
Hello,
Your project is great, the code is easy to understand and use, however, the ReadMe of this project seems to be funny but not that professional.
I want to use this lib but a little worried about Code Review. Are you guys considering make an Readme/doc for all users from many other countries?
Thanks for your hard work, it helps a lot
filter.replace("这篇文章真的好垃圾啊", '*') // 这个*能换成字符串吗?
麻烦一下作者提供一下删除敏感字的函数接口,谢谢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.