trie

package
v0.0.0-...-1ec2636 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

关键词检索trie树,目前是用于敏感词过滤

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Trie

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

trie树

func New

func New() Trie

func (*Trie) AddElement

func (t *Trie) AddElement(key string)

添加关键词

func (*Trie) PrintKeys

func (t *Trie) PrintKeys()

打印trie树结构

func (*Trie) Replace

func (t *Trie) Replace(text string) (num int, replaced string)

替换文本中所有匹配上的敏感词 参数:

num: 敏感词数量
replaced: 替换后的文本

func (*Trie) Search

func (t *Trie) Search(text string) (pos int, key string)

搜索文本中能够匹配上的第一个关键词,返回其位置和关键词

type TrieElement

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

trie树节点

Jump to

Keyboard shortcuts

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