Skip to content

Commit 3eb2a36

Browse files
authored
Add files via upload
1 parent 1f74485 commit 3eb2a36

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

plugin/handou/baiAPI.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ type baiduAPIData struct {
103103

104104
func geiAPIdata(s string) (*idiomJSON, error) {
105105
url := "https://hanyuapp.baidu.com/dictapp/swan/termdetail?wd=" + url.QueryEscape(s) + "&client=pc&source_tag=2&lesson_from=xiaodu"
106-
logrus.Warningln(url)
106+
logrus.Debugln(url)
107107
data, err := web.GetData(url)
108108
if err != nil {
109109
return nil, err

plugin/handou/game.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,11 @@ func newHandouGame(target idiomJSON) func(string) (bool, []byte, error) {
289289
if !ok {
290290
newIdiom, err1 := geiAPIdata(s)
291291
if err1 != nil {
292-
logrus.Warningln("通过API获取成语信息时发生错误: ", err1)
292+
logrus.Debugln("通过API获取成语信息时发生错误: ", err1)
293293
err = errUnknownWord
294294
return
295295
}
296-
logrus.Warningln("通过API获取成语信息: ", newIdiom.Word)
296+
logrus.Debugln("通过API获取成语信息: ", newIdiom.Word)
297297
if newIdiom.Word != "" {
298298
idiomInfoMap[newIdiom.Word] = *newIdiom
299299
go func() { _ = saveIdiomJSON() }()

plugin/handou/habits.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func updateHabits(input string) error {
156156
// 异步保存到文件
157157
go func() {
158158
if err := saveHabits(); err != nil {
159-
logrus.Warn("保存用户习惯时发生错误: ", err)
159+
logrus.Debugln("保存用户习惯时发生错误: ", err)
160160
}
161161
}()
162162

@@ -210,10 +210,11 @@ func calculatePriorityScore(idiom string) float64 {
210210

211211
// 4. 考虑成语长度, 让长成语也有机会被选中
212212
idiomScore := 0.0
213-
if rand.Intn(100) < 80 {
213+
if rand.Intn(100) < 60 {
214214
idiomScore = 20 / (1 + 1*math.Abs(float64(charsLenght)-4))
215215
} else {
216-
idiomScore = float64(charsLenght) * 10
216+
count := 2.0 + float64(rand.Intn(18))
217+
idiomScore = 100 / (1 + 1*math.Abs(float64(charsLenght)-count))
217218
}
218219

219220
finalScore := charsScore + bigramScore + penaltyScore + idiomScore
@@ -272,7 +273,7 @@ func prioritizeData(data []string) []string {
272273
prioritized := make([]string, limit)
273274
for i := range limit {
274275
prioritized[i] = idiomScores[startIndex+i].idiom
275-
logrus.Warningf("成语 '%s' 分数=%.2f",
276+
logrus.Debugf("成语 '%s' 分数=%.2f",
276277
idiomScores[startIndex+i].idiom, idiomScores[startIndex+i].score)
277278
}
278279

0 commit comments

Comments
 (0)