Add files via upload

This commit is contained in:
方柳煜 2026-02-01 23:44:26 +08:00 committed by GitHub
parent 1f74485f28
commit 3eb2a36f3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 7 deletions

View File

@ -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

View File

@ -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() }()

View File

@ -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)
}