From 3eb2a36f3b7eb97053c7095c46e091dc3e0a9ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E6=9F=B3=E7=85=9C?= <101934327+fangliuyu@users.noreply.github.com> Date: Sun, 1 Feb 2026 23:44:26 +0800 Subject: [PATCH] Add files via upload --- plugin/handou/baiAPI.go | 2 +- plugin/handou/game.go | 4 ++-- plugin/handou/habits.go | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/plugin/handou/baiAPI.go b/plugin/handou/baiAPI.go index 86ceeb9d..6004e892 100644 --- a/plugin/handou/baiAPI.go +++ b/plugin/handou/baiAPI.go @@ -103,7 +103,7 @@ type baiduAPIData struct { func geiAPIdata(s string) (*idiomJSON, error) { url := "https://hanyuapp.baidu.com/dictapp/swan/termdetail?wd=" + url.QueryEscape(s) + "&client=pc&source_tag=2&lesson_from=xiaodu" - logrus.Warningln(url) + logrus.Debugln(url) data, err := web.GetData(url) if err != nil { return nil, err diff --git a/plugin/handou/game.go b/plugin/handou/game.go index d2e44248..81ff2524 100644 --- a/plugin/handou/game.go +++ b/plugin/handou/game.go @@ -289,11 +289,11 @@ func newHandouGame(target idiomJSON) func(string) (bool, []byte, error) { if !ok { newIdiom, err1 := geiAPIdata(s) if err1 != nil { - logrus.Warningln("通过API获取成语信息时发生错误: ", err1) + logrus.Debugln("通过API获取成语信息时发生错误: ", err1) err = errUnknownWord return } - logrus.Warningln("通过API获取成语信息: ", newIdiom.Word) + logrus.Debugln("通过API获取成语信息: ", newIdiom.Word) if newIdiom.Word != "" { idiomInfoMap[newIdiom.Word] = *newIdiom go func() { _ = saveIdiomJSON() }() diff --git a/plugin/handou/habits.go b/plugin/handou/habits.go index 209fd6c8..0fa66414 100644 --- a/plugin/handou/habits.go +++ b/plugin/handou/habits.go @@ -156,7 +156,7 @@ func updateHabits(input string) error { // 异步保存到文件 go func() { if err := saveHabits(); err != nil { - logrus.Warn("保存用户习惯时发生错误: ", err) + logrus.Debugln("保存用户习惯时发生错误: ", err) } }() @@ -210,10 +210,11 @@ func calculatePriorityScore(idiom string) float64 { // 4. 考虑成语长度, 让长成语也有机会被选中 idiomScore := 0.0 - if rand.Intn(100) < 80 { + if rand.Intn(100) < 60 { idiomScore = 20 / (1 + 1*math.Abs(float64(charsLenght)-4)) } else { - idiomScore = float64(charsLenght) * 10 + count := 2.0 + float64(rand.Intn(18)) + idiomScore = 100 / (1 + 1*math.Abs(float64(charsLenght)-count)) } finalScore := charsScore + bigramScore + penaltyScore + idiomScore @@ -272,7 +273,7 @@ func prioritizeData(data []string) []string { prioritized := make([]string, limit) for i := range limit { prioritized[i] = idiomScores[startIndex+i].idiom - logrus.Warningf("成语 '%s' 分数=%.2f", + logrus.Debugf("成语 '%s' 分数=%.2f", idiomScores[startIndex+i].idiom, idiomScores[startIndex+i].score) }