• Stars
    star
    630
  • Rank 71,328 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Sensitive

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

FindAll, Validate, Filter and Replace words.

Build Status GoDoc

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

用法

package main

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

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

AddWord

添加敏感词

filter.AddWord("垃圾")

Replace

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

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

Filter

直接移除词语

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

FindIn

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

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

Validate

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

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

FindAll

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

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

LoadNetWordDict

加载网络词库。

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

UpdateNoisePattern

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

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

More Repositories

1

mobc

A generic connection pool for Rust with async/await support
Rust
283
star
2

rust-miniproxy

手把手教你用Rust写代理, 代码已完成, 文章不定期更新
JavaScript
154
star
3

nipper

A Rust crate for manipulating HTML with CSS selectors
Rust
121
star
4

rust-ajson

Rust port of gjson,get JSON value by dotpath syntax
Rust
104
star
5

gkd-rs

A multi-connections TCP accelerator, written in Rust
Rust
26
star
6

trie-go

The golang implementation of trie tree.
Go
24
star
7

danmu.go

基于golang的命令行形式的直播网站(斗鱼)的弹幕浏览
Go
18
star
8

react-affix

A simple react affix component(Deprecated, use sticky instead)
JavaScript
15
star
9

mobc-redis

Redis support for the mobc connection pool
Rust
12
star
10

notes

My notes
10
star
11

mobc-postgres

Rust
9
star
12

neighbor

基于geohash和mysql实现的附近的人
Go
6
star
13

Posts

📫 Posts is a Python library for send mail easily.
Python
5
star
14

douyu

Crawler For DouyuTv Statistics
Python
4
star
15

yake

Pelican theme.
HTML
4
star
16

tiresias

simple demos for learning scarpy
Python
2
star
17

sparta

Douyu Statistic Backend
JavaScript
2
star
18

comethandler

🔫 helps the server which is builded with golang to push messages to the http clients easily.
Go
2
star
19

tide-demo

Rust
1
star
20

hackathon-2015

Eleme Hackathon 2015
Java
1
star
21

wisburg-terminal

JavaScript
1
star
22

flask_restful_doc

Generate api docs for flask restful resource
Python
1
star
23

bomd-server

base on markdown. a lightweight blog framework which id managed in local
CSS
1
star
24

noname

Go
1
star
25

remote-shortcuts

通过手机使用快捷键操作windows程序
Rust
1
star
26

init-react-webpack-project

A simple and small python2 script that can help you to init a react & webpack project.
Python
1
star