22package thesaurus
33
44import (
5- "bytes"
65 "math/rand"
76 "strings"
87
9- "github.com/fumiama/jieba "
8+ "github.com/go-ego/gse "
109 "github.com/sirupsen/logrus"
1110 "gopkg.in/yaml.v3"
1211
@@ -55,11 +54,8 @@ func init() {
5554 ctx .SendChain (message .Text ("成功!" ))
5655 })
5756 go func () {
58- data , err := engine .GetLazyData ("dict.txt" , false )
59- if err != nil {
60- panic (err )
61- }
62- seg , err := jieba .LoadDictionary (bytes .NewReader (data ))
57+ var seg gse.Segmenter
58+ err := seg .LoadDictEmbed ()
6359 if err != nil {
6460 panic (err )
6561 }
@@ -102,10 +98,10 @@ func init() {
10298 ctx .SendChain (message .Text (r .Reply ))
10399 }
104100 })
105- engine .OnMessage (zero .OnlyToMe , canmatch (tDERE ), match (chatListD , seg )).
101+ engine .OnMessage (zero .OnlyToMe , canmatch (tDERE ), match (chatListD , & seg )).
106102 SetBlock (false ).
107103 Handle (randreply (sm .D ))
108- engine .OnMessage (zero .OnlyToMe , canmatch (tKAWA ), match (chatListK , seg )).
104+ engine .OnMessage (zero .OnlyToMe , canmatch (tKAWA ), match (chatListK , & seg )).
109105 SetBlock (false ).
110106 Handle (randreply (sm .K ))
111107 }()
@@ -122,7 +118,7 @@ const (
122118 tKAWA
123119)
124120
125- func match (l []string , seg * jieba .Segmenter ) zero.Rule {
121+ func match (l []string , seg * gse .Segmenter ) zero.Rule {
126122 return func (ctx * zero.Ctx ) bool {
127123 return ctxext .JiebaSimilarity (0.66 , seg , func (ctx * zero.Ctx ) string {
128124 return ctx .ExtractPlainText ()
0 commit comments