Documentation ¶
Overview ¶
Package wordfilter 单词过滤
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterText ¶
FilterText we use a dictionary file to filter text,all separator in text will be bypassed,and matched words will be replace by rep
func LoadDicFiles ¶
func LoadDicFiles(dicFiles []string)
Types ¶
type ChildNodeType ¶
type ChildNodeType []*Node
ChildNodeType In a trie, each node has many child nodes
func (ChildNodeType) Len ¶
func (c ChildNodeType) Len() int
Len Implement the interface which is needed by STL sort function
func (ChildNodeType) Less ¶
func (c ChildNodeType) Less(i, j int) bool
Less Implement the interface which is needed by STL sort function
func (ChildNodeType) Swap ¶
func (c ChildNodeType) Swap(i, j int)
Swap Implement the interface which is needed by STL sort function
type Node ¶
type Node struct { Val rune // val from the parent to the node,or edge, utf-8 encode Depth int // depth of the node from root,root's depth is 0 ParentNode *Node // parent node used to trace back to the root ChildNodes ChildNodeType // child node slice SuffixNode *Node // suffix node of the node's longest postfix, represented by root->node1->node2....->suffix EOW bool // end-of-word tag }
Node used to build trie structure
func (*Node) BinGetChildNodeByVal ¶
BinGetChildNodeByVal binary search childnodes with given val
func (*Node) GetChildNodeByVal ¶
GetChildNodeByVal get child node by given val
func (*Node) InsertChildNodeByVal ¶
InsertChildNodeByVal simplly insert a child node
type Seps ¶
type Seps []rune
Seps separator charactors,if we want to match "abcde" in "abc112312de" ,separator charactors can be set to "123"
type Trie ¶
type Trie struct {
RootNode *Node // root
}
Trie
func (*Trie) FindNodeByPath ¶
FindNodeByPath find a node the path to which can be represented by value of nodes arr
func (*Trie) InitRootNode ¶
func (trie *Trie) InitRootNode()
func (*Trie) TraceBackToRoot ¶
TraceBackToRoot trace from a node to root, root and the node are both contained in return