triesearch

package module
v0.0.0-...-24a98b2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

README

triesearch

介绍

前缀树

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	//  Children
	/**
	 *  @Author: rym 2022-11-16 09:09:00
	 *  @Description: 该节点的子节点字典
	 */
	Children map[rune]*Node `json:"children"`

	//  ContentMap
	/**
	 *  @Author: rym 2023-03-09 16:00:51
	 *  @Description: 临时用的map,用来作数据去重
	 */
	ContentMap map[string]string

	//  Char
	/**
	 *  @Author: rym 2022-11-16 09:01:47
	 *  @Description: 该节点的字符
	 */
	Char string

	//  ContentList
	/**
	 *  @Author: rym 2022-11-16 09:10:54
	 *  @Description:
	 */
	Content []string `json:"content"`

	//  Code
	/**
	 *  @Author: rym 2022-11-16 09:08:38
	 *  @Description: 改节点的unicode
	 */
	Code rune
}

Node *

  • @Author: rym 2022-11-16 09:01:35
  • @Description: 数据结构节点对象

type Trie

type Trie struct {
	//  Root
	/**
	 *  @Author: rym 2022-11-16 09:14:41
	 *  @Description: 根节点
	 */
	Root *Node
	// contains filtered or unexported fields
}

Trie *

  • @Author: rym 2022-11-16 09:18:42
  • @Description:Trie Map 数据结构对象

func NewTrie

func NewTrie() *Trie

func (*Trie) Add

func (t *Trie) Add(keyword, content string)

Add *

  • @Author: rym 2022-11-16 17:39:14
  • @Description: 根据关键词添加节点,并下挂相关内容 对外方法
  • @Description: 创建普通的树节点 例如: 碳中和 通过 碳、碳中、碳中和 可以查找到对应的内容列表
  • @receiver t
  • @param keyword
  • @param content

func (*Trie) AddFull

func (t *Trie) AddFull(keyword, content string)

AddFull *

  • @Author: rym 2022-11-16 17:32:32
  • @Description: 根据关键词添加节点,并下挂相关内容 对外方法
  • @Description: 创建详细的树节点 例如:碳中和 通过 碳、碳中、碳中和、中、中和、和 都可以查找到对应的内容列表
  • @Description: 此方式创建的树,会更多消耗内存
  • @receiver t
  • @param keyword
  • @param content

func (*Trie) AutoAdd

func (t *Trie) AutoAdd(list []string)

AutoAdd *

  • @Author: rym 2023-01-31 17:26:29
  • @Description:自动添加非全词搜索
  • @receiver t
  • @param list

func (*Trie) AutoAddFull

func (t *Trie) AutoAddFull(list []string)

AutoAddFull *

  • @Author: rym 2023-01-31 17:24:56
  • @Description:自动添加全词搜索
  • @receiver t
  • @param list

func (*Trie) Find

func (t *Trie) Find(keyword string) (bool, []string)

Find *

  • @Author: rym 2022-11-16 09:44:22
  • @Description: 根据关键词,从树中找相关内容列表
  • @receiver t
  • @param keyword
  • @return bool
  • @return []string

func (*Trie) GC

func (t *Trie) GC()

GC *

  • @Author: rym 2023-03-09 16:11:00
  • @Description: 清除临时数据
  • @receiver t

func (*Trie) SetDepth

func (t *Trie) SetDepth(n int8)

SetDepth *

  • @Author: rym 2022-11-16 09:41:27
  • @Description: 设置树的最大深度 深度越大 查找速度越慢
  • @receiver t
  • @param n

Jump to

Keyboard shortcuts

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