|
|
@ -2,6 +2,7 @@ package danmaku
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"git.noahlan.cn/northlan/ntools-go/stringn/ac"
|
|
|
|
"git.noahlan.cn/northlan/ntools-go/stringn/ac"
|
|
|
|
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
type (
|
|
|
@ -36,7 +37,9 @@ func (p *Parser) ParseTest(content string) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (p *Parser) Parse(content string) *CMD {
|
|
|
|
func (p *Parser) Parse(content string) *CMD {
|
|
|
|
matches := p.trie.MatchString(content)
|
|
|
|
// 移除多余空格,小写
|
|
|
|
|
|
|
|
tmpContent := strings.ToLower(strings.TrimSpace(content))
|
|
|
|
|
|
|
|
matches := p.trie.MatchString(tmpContent)
|
|
|
|
|
|
|
|
|
|
|
|
allKeyLen := 0
|
|
|
|
allKeyLen := 0
|
|
|
|
matchedKeyMap := make(map[string]struct{})
|
|
|
|
matchedKeyMap := make(map[string]struct{})
|
|
|
@ -45,7 +48,7 @@ func (p *Parser) Parse(content string) *CMD {
|
|
|
|
matchedKeyMap[tmp] = struct{}{}
|
|
|
|
matchedKeyMap[tmp] = struct{}{}
|
|
|
|
allKeyLen += len(tmp)
|
|
|
|
allKeyLen += len(tmp)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isCMD := len(content) <= allKeyLen
|
|
|
|
isCMD := len(tmpContent) <= allKeyLen
|
|
|
|
|
|
|
|
|
|
|
|
// 避免同类型指令重复
|
|
|
|
// 避免同类型指令重复
|
|
|
|
arrMap := make(map[rune]struct{})
|
|
|
|
arrMap := make(map[rune]struct{})
|
|
|
@ -61,7 +64,7 @@ func (p *Parser) Parse(content string) *CMD {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return &CMD{
|
|
|
|
return &CMD{
|
|
|
|
IsCMD: len(content) <= allKeyLen,
|
|
|
|
IsCMD: len(tmpContent) <= allKeyLen,
|
|
|
|
Arr: matchedCmdArr,
|
|
|
|
Arr: matchedCmdArr,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|