sx

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

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStock

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

func NewFileStock

func NewFileStock(p string) (*FileStock, error)

func (*FileStock) ReadAll

func (fs *FileStock) ReadAll() []string

type Filter

type Filter interface {
	// Excludes 用于设置需要排除的内容,主要用于忽略敏感词中间的特殊字符
	// 比如:
	// 将中线(-)设置为排除内容,同时将 "今天" 设置为敏感词
	// 匹配的时候, "今天" 和 "今-天" 都将被判定为敏感词
	Excludes(items ...rune)

	// Contains 用于检测是否有敏感词:如果有敏感词,返回 true;如果没有敏感词,返回 false;
	Contains(text string) bool

	// FindFirst 用于查找出第一个敏感词
	FindFirst(text string) string

	// FindAll 用于查找出所有敏感词
	FindAll(text string) []string

	// Replace 用于替换敏感词
	Replace(text string, replace rune) string
}

type MemoryStock

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

func NewMemoryStock

func NewMemoryStock(words ...string) (*MemoryStock, error)

func (*MemoryStock) ReadAll

func (ms *MemoryStock) ReadAll() []string

type TrieFilter

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

func NewTrieFilter

func NewTrieFilter(stock WordStock) *TrieFilter

func (*TrieFilter) Contains

func (filter *TrieFilter) Contains(text string) bool

func (*TrieFilter) Excludes

func (filter *TrieFilter) Excludes(items ...rune)

func (*TrieFilter) FindAll

func (filter *TrieFilter) FindAll(text string) []string

func (*TrieFilter) FindFirst

func (filter *TrieFilter) FindFirst(text string) string

func (*TrieFilter) Replace

func (filter *TrieFilter) Replace(text string, replace rune) string

type WordStock

type WordStock interface {
	// ReadAll 获取所有的词语
	ReadAll() []string
}

Directories

Path Synopsis
examples module

Jump to

Keyboard shortcuts

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