sensitive

package
v1.20.61 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2024 License: Zlib Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGroup = "def"

Variables

This section is empty.

Functions

func WithDefaultGroupOpt added in v1.20.11

func WithDefaultGroupOpt() option.Option

func WithRegexOpt added in v1.20.11

func WithRegexOpt() option.Option

Types

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter 敏感词过滤器

func New

func New(reg bool) *Filter

New 返回一个敏感词过滤器

func (*Filter) AddWord

func (filter *Filter) AddWord(words ...string)

AddWord 添加敏感词

func (*Filter) DelWord

func (filter *Filter) DelWord(words ...string)

DelWord 删除敏感词

func (*Filter) Filter

func (filter *Filter) Filter(text string) string

Filter 过滤敏感词

func (*Filter) FindAll

func (filter *Filter) FindAll(text string) []*trie.Group

FindAll 找到所有匹配词

func (*Filter) FindIn

func (filter *Filter) FindIn(text string) (bool, string)

FindIn 检测敏感词

func (*Filter) Load

func (filter *Filter) Load(rd io.Reader) error

Load common method to add words

func (*Filter) LoadWordDict

func (filter *Filter) LoadWordDict(path string) error

LoadWordDict 加载敏感词字典

func (*Filter) LoadWordDictByNetworkFile added in v0.5.36

func (filter *Filter) LoadWordDictByNetworkFile(url string) error

LoadWordDictByNetworkFile 加载网络敏感词字典,文本文件

func (*Filter) RemoveNoise

func (filter *Filter) RemoveNoise(text string) string

RemoveNoise 去除空格等噪音

func (*Filter) Replace

func (filter *Filter) Replace(text string, repl rune, replaceF func(repl rune) string) string

Replace 和谐敏感词

func (*Filter) UpdateNoisePattern

func (filter *Filter) UpdateNoisePattern(pattern string)

UpdateNoisePattern 更新去噪模式

func (*Filter) Validate

func (filter *Filter) Validate(text string) (bool, string)

Validate 检测字符串是否合法

type Regexp added in v0.5.36

type Regexp struct {
	// contains filtered or unexported fields
}

func NewRegexp added in v0.5.36

func NewRegexp() *Regexp

func (*Regexp) Add added in v0.5.36

func (r *Regexp) Add(reg string) (*regexp.Regexp, error)

func (*Regexp) Del added in v0.5.36

func (r *Regexp) Del(reg string)

func (*Regexp) Filter added in v0.5.36

func (r *Regexp) Filter(text string) string

func (*Regexp) FindAll added in v0.5.36

func (r *Regexp) FindAll(text string) []*trie.Group

FindAll 找到所有匹配词

func (*Regexp) FindIn added in v0.5.36

func (r *Regexp) FindIn(text string) (bool, string)

FindIn 检测敏感词

func (*Regexp) Replace added in v0.5.36

func (r *Regexp) Replace(text string, repl string) string

func (*Regexp) Validate added in v0.5.36

func (r *Regexp) Validate(text string) (bool, string)

type SensMgr added in v1.20.11

type SensMgr struct {
	// contains filtered or unexported fields
}

func NewMgr added in v1.20.11

func NewMgr(opts ...option.Option) *SensMgr

func (*SensMgr) Add added in v1.20.11

func (m *SensMgr) Add(group string, opts ...option.Option) *Filter

func (*SensMgr) Get added in v1.20.11

func (m *SensMgr) Get(group string) *Filter

func (*SensMgr) Load added in v1.20.11

func (m *SensMgr) Load(group string, path string) error

func (*SensMgr) LoadNetworkFileByGroup added in v1.20.11

func (m *SensMgr) LoadNetworkFileByGroup(group string, url string) error

func (*SensMgr) LoadUrl added in v1.20.11

func (m *SensMgr) LoadUrl(url string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL