mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-26 08:54:07 +01:00
🎨 Apply result optimized by FSRS optimizer https://github.com/siyuan-note/siyuan/issues/9309
This commit is contained in:
parent
b2a27bb54c
commit
6354d04e4b
10 changed files with 104 additions and 10 deletions
|
|
@ -16,6 +16,12 @@
|
|||
|
||||
package conf
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/open-spaced-repetition/go-fsrs"
|
||||
)
|
||||
|
||||
type Flashcard struct {
|
||||
NewCardLimit int `json:"newCardLimit"` // 新卡上限 https://github.com/siyuan-note/siyuan/issues/7695
|
||||
ReviewCardLimit int `json:"reviewCardLimit"` // 复习卡上限 https://github.com/siyuan-note/siyuan/issues/7703
|
||||
|
|
@ -23,15 +29,32 @@ type Flashcard struct {
|
|||
List bool `json:"list"` // 是否启用列表块制卡 https://github.com/siyuan-note/siyuan/issues/7701
|
||||
SuperBlock bool `json:"superBlock"` // 是否启用超级块制卡 https://github.com/siyuan-note/siyuan/issues/7702
|
||||
Deck bool `json:"deck"` // 是否启用卡包制卡 https://github.com/siyuan-note/siyuan/issues/7724
|
||||
|
||||
// Apply result optimized by FSRS optimizer https://github.com/siyuan-note/siyuan/issues/9309
|
||||
RequestRetention float64 `json:"requestRetention"`
|
||||
MaximumInterval float64 `json:"maximumInterval"`
|
||||
Weights string `json:"weights"`
|
||||
}
|
||||
|
||||
func NewFlashcard() *Flashcard {
|
||||
param := fsrs.DefaultParam()
|
||||
weightsBuilder := bytes.Buffer{}
|
||||
for i, w := range param.W {
|
||||
weightsBuilder.WriteString(fmt.Sprintf("%.2f", w))
|
||||
if i < len(param.W)-1 {
|
||||
weightsBuilder.WriteString(", ")
|
||||
}
|
||||
}
|
||||
|
||||
return &Flashcard{
|
||||
NewCardLimit: 20,
|
||||
ReviewCardLimit: 200,
|
||||
Mark: true,
|
||||
List: true,
|
||||
SuperBlock: true,
|
||||
Deck: false,
|
||||
NewCardLimit: 20,
|
||||
ReviewCardLimit: 200,
|
||||
Mark: true,
|
||||
List: true,
|
||||
SuperBlock: true,
|
||||
Deck: false,
|
||||
RequestRetention: param.RequestRetention,
|
||||
MaximumInterval: param.MaximumInterval,
|
||||
Weights: weightsBuilder.String(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,6 +350,15 @@ func InitConf() {
|
|||
if 0 > Conf.Flashcard.ReviewCardLimit {
|
||||
Conf.Flashcard.ReviewCardLimit = 200
|
||||
}
|
||||
if 0 >= Conf.Flashcard.RequestRetention || 1 <= Conf.Flashcard.RequestRetention {
|
||||
Conf.Flashcard.RequestRetention = conf.NewFlashcard().RequestRetention
|
||||
}
|
||||
if 0 >= Conf.Flashcard.MaximumInterval || 36500 <= Conf.Flashcard.MaximumInterval {
|
||||
Conf.Flashcard.MaximumInterval = conf.NewFlashcard().MaximumInterval
|
||||
}
|
||||
if "" == Conf.Flashcard.Weights || 17 != len(strings.Split(Conf.Flashcard.Weights, ",")) {
|
||||
Conf.Flashcard.Weights = conf.NewFlashcard().Weights
|
||||
}
|
||||
|
||||
if nil == Conf.AI {
|
||||
Conf.AI = conf.NewAI()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue