ahocorasick

package module
v0.0.0-...-c8958a9 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2018 License: MIT Imports: 6 Imported by: 0

README

ahocorasick

基于ahocorasick算法的敏感词过滤,支持中文、线程安全

基于gansidui版本优化

gansidui原版

增加Has接口
增加Replace接口
增加多线程支持

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSensitiveArray

func BuildSensitiveArray(path string) []string

从csv生成敏感词数组

func BuildSensitiveStr

func BuildSensitiveStr(path string) string

从csv生成敏感词正则表达式字串

Types

type ACMatcher

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

func NewMatcher

func NewMatcher(dict []string) *ACMatcher

func (*ACMatcher) Has

func (m *ACMatcher) Has(s string) bool

是否包含敏感词,查找到任意立即返回

func (*ACMatcher) Match

func (m *ACMatcher) Match(s string) []int

包含敏感词位置、个数,统计所有可能项,比如"民主权"会统计成两个词

func (*ACMatcher) Replace

func (m *ACMatcher) Replace(s string, repl string) string

将s中的敏感词替换为repl,一旦匹配到敏感词立即替换,不会参与后续匹配

func (*ACMatcher) Size

func (m *ACMatcher) Size() int

Jump to

Keyboard shortcuts

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