sensitivewords

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sensitivewords 敏感词过滤

 example:
 words := sensitivewords.NewSensitiveWords().LoadKeywords(app.Root() + "/configs/debug/keywords.csv")
	fmt.Println(words.HasKeywords("鸡巴"))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store map[rune]*node

Store 关键字节点

func NewSensitiveWords

func NewSensitiveWords() Store

NewSensitiveWords 创建一个对象来加载关键字

func (Store) Add

func (store Store) Add(keywords string)

Add 增加关键字

func (Store) AppendToFile

func (store Store) AppendToFile(keywords string) (n int, err error)

AppendToFile 增加新的关键字时, 将同时写入到文件

func (Store) Filter

func (store Store) Filter(input string, replace rune) string

Filter 过滤敏感词

func (Store) HasKeywords

func (store Store) HasKeywords(input string) bool

HasKeywords 是否包含敏感词

func (Store) KeywordsList

func (store Store) KeywordsList(input string) []string

KeywordsList 获取触发的敏感词列表

func (Store) LoadKeywords

func (store Store) LoadKeywords(filename string) Store

LoadKeywords 加载文件中的关键字, 按行分割

Jump to

Keyboard shortcuts

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