@@ -11,27 +11,30 @@ import (
1111 "sync"
1212 "time"
1313
14+ "github.com/go-ego/gse"
15+ "github.com/golang/freetype"
16+ "github.com/sirupsen/logrus"
17+ "github.com/tidwall/gjson"
18+ "github.com/wcharczuk/go-chart/v2"
19+
1420 "github.com/FloatTech/floatbox/binary"
1521 fcext "github.com/FloatTech/floatbox/ctxext"
1622 "github.com/FloatTech/floatbox/file"
1723 ctrl "github.com/FloatTech/zbpctrl"
1824 "github.com/FloatTech/zbputils/control"
1925 "github.com/FloatTech/zbputils/ctxext"
2026 "github.com/FloatTech/zbputils/img/text"
21- "github.com/go-ego/gse"
22- "github.com/golang/freetype"
23- "github.com/sirupsen/logrus"
24- "github.com/tidwall/gjson"
25- "github.com/wcharczuk/go-chart/v2"
27+
2628 zero "github.com/wdvxdr1123/ZeroBot"
2729 "github.com/wdvxdr1123/ZeroBot/message"
30+ "github.com/wdvxdr1123/ZeroBot/utils/helper"
2831)
2932
3033var (
3134 re = regexp .MustCompile (`^[一-龥]+$` )
3235 stopwords []string
36+ seg gse.Segmenter
3337)
34- var seg gse.Segmenter
3538
3639func init () {
3740 engine := control .AutoRegister (& ctrl.Options [* zero.Ctx ]{
@@ -42,7 +45,10 @@ func init() {
4245 })
4346 cachePath := engine .DataFolder () + "cache/"
4447 // 读取gse内置中文词典
45- _ = seg .LoadDictEmbed ("zh_s" )
48+ err := seg .LoadDictEmbed ()
49+ if err != nil {
50+ panic (err )
51+ }
4652 _ = os .RemoveAll (cachePath )
4753 _ = os .MkdirAll (cachePath , 0755 )
4854 engine .OnRegex (`^热词\s?(\d*)\s?(\d*)$` , zero .OnlyGroup , fcext .DoOnceOnSuccess (func (ctx * zero.Ctx ) bool {
@@ -124,7 +130,7 @@ func init() {
124130 if tex == "" {
125131 continue
126132 }
127- segments := seg .Segment ([] byte (tex ))
133+ segments := seg .Segment (helper . StringToBytes (tex ))
128134 words := gse .ToSlice (segments , true )
129135 for _ , word := range words {
130136 word = strings .TrimSpace (word )
0 commit comments