trie

package
v1.20.76 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Zlib Imports: 2 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Empty = ""
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	No    string
	Text  string `xml:"text" json:"text"`   //找出的词
	Index int    `xml:"index" json:"index"` //找出的位置
}

type Node

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

func (*Node) Add

func (node *Node) Add(r rune, n *Node) *Node

func (*Node) Get

func (node *Node) Get(r rune) (*Node, bool)

func (*Node) IsLeaf

func (node *Node) IsLeaf() bool

IsLeaf 是否叶子节点

func (*Node) IsPathEnd

func (node *Node) IsPathEnd() bool

IsPathEnd 某个路径的结束

func (*Node) IsRoot

func (node *Node) IsRoot() bool

IsRoot 是否为根节点

func (*Node) SoftDel

func (node *Node) SoftDel()

SoftDel 置软删除状态

type Trie

type Trie struct {
	Root *Node
}

func NewTrie

func NewTrie() *Trie

func (*Trie) Add

func (tree *Trie) Add(word string) (no string)

Add 添加, return no 唯一的编号

func (*Trie) AddRune added in v1.5.5

func (tree *Trie) AddRune(word []rune) (no string)

func (*Trie) Del

func (tree *Trie) Del(word string)

func (*Trie) DelRune added in v1.5.5

func (tree *Trie) DelRune(word []rune)

func (*Trie) Filter

func (tree *Trie) Filter(text string) string

Filter 直接过滤掉字符串中的敏感词

func (*Trie) FilterRune added in v1.5.5

func (tree *Trie) FilterRune(text []rune) string

func (*Trie) FindAll

func (tree *Trie) FindAll(text string) []*Group

func (*Trie) FindIn

func (tree *Trie) FindIn(text string) (bool, string)

func (*Trie) FindInGroup added in v1.5.1

func (tree *Trie) FindInGroup(text string) (bool, Group)

func (*Trie) FindInReturnNo added in v1.1.29

func (tree *Trie) FindInReturnNo(text string) (bool, string, string)

FindInReturnNo 判断text中是否含有词库中的词

func (*Trie) FindRune added in v1.5.6

func (tree *Trie) FindRune(text []rune) (bool, Group)

func (*Trie) FindRunes added in v1.5.5

func (tree *Trie) FindRunes(text []rune) []*Group

FindRunes 找有所有包含在词库中的词

func (*Trie) Replace

func (tree *Trie) Replace(text string, character rune) string

Replace 词语替换

func (*Trie) ReplaceRune added in v1.5.5

func (tree *Trie) ReplaceRune(text []rune, character rune) string

func (*Trie) Validate

func (tree *Trie) Validate(text string) (bool, string)

func (*Trie) ValidateReturnNo added in v1.1.29

func (tree *Trie) ValidateReturnNo(text string) (bool, string, string)

ValidateReturnNo 验证字符串是否合法,如不合法则返回false和检测到 的第一个敏感词

func (*Trie) ValidateRune added in v1.5.5

func (tree *Trie) ValidateRune(text []rune) (bool, Group)

Jump to

Keyboard shortcuts

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