parent
184886d2c8
commit
60c0098cfb
@ -0,0 +1,32 @@
|
||||
package flashtext
|
||||
|
||||
type Node struct {
|
||||
children map[rune]*Node // 使用 map 存储叶子节点,key:'char' ,value: *Node
|
||||
exist map[int]struct{} // 关键词节点是一个完整的匹配词,记录其长度
|
||||
failure *Node // 记录失败指针
|
||||
}
|
||||
|
||||
func newNode() *Node {
|
||||
return &Node{
|
||||
children: make(map[rune]*Node),
|
||||
exist: make(map[int]struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
type Match struct {
|
||||
match string
|
||||
start int
|
||||
end int
|
||||
}
|
||||
|
||||
func (m *Match) MatchString() string {
|
||||
return m.match
|
||||
}
|
||||
|
||||
func (m *Match) Start() int {
|
||||
return m.start
|
||||
}
|
||||
|
||||
func (m *Match) End() int {
|
||||
return m.end
|
||||
}
|
Loading…
Reference in New Issue