Skip to content

Refactor: Integrate with the official R calculation #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
# 🚀 用法
1. 安装LMS插件. 初始在LeetCode / 力扣页面右下角点击`rate`按钮(可拖动位置),为题目掌握情况打分,算法参考打分情况实时调整复习计划。
2. 插件主页自动评估每道题的可检索性优先级(能够回忆起来的概率),用户可根据时间安排,灵活调整每日的复习量。
3. FSRS算法允许休息和提前突击复习,其算法会随时间流逝,自动推理整体题目的会回忆概率,动态调整下一次复习时间,以适应你的学习节奏。
4. 可在插件的`popup`弹窗中打勾完成复习;也可点击进入题目页面,通过`rate it`按钮完成复习。
3. FSRS算法允许休息和提前突击复习,其算法会随时间流逝,自动推理整体题目的回忆概率,动态调整下一次复习时间,以适应你的学习节奏。
4. 可在插件的`popup`弹窗中打勾完成复习;也可点击进入题目页面,通过`rate`按钮完成复习。
5. 打开题目列表,查看当前复习规划的所有题目
6. 刷题快乐,速成的本质在于不要遗忘!

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"jszip": "^3.10.1",
"style-loader": "^3.3.3",
"sweetalert2": "^11.15.10",
"ts-fsrs": "^4.6.0",
"ts-fsrs": "^4.7.0",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
Expand Down
11 changes: 3 additions & 8 deletions src/popup/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import localStorageDelegate from "../delegate/localStorageDelegate";
import cloudStorageDelegate from "../delegate/cloudStorageDelegate";
import { store } from "../store";
import { COMPILE_ERROR_AND_TLE_CLASSNAME, COMPILE_ERROR_AND_TLE_CLASSNAME_CN, COMPILE_ERROR_AND_TLE_CLASSNAME_NEW, PAGE_SIZE, SUBMIT_BUTTON_ATTRIBUTE_NAME, SUBMIT_BUTTON_ATTRIBUTE_VALUE, SUCCESS_CLASSNAME, SUCCESS_CLASSNAME_CN, SUCCESS_CLASSNAME_NEW, WRONG_ANSWER_CLASSNAME, WRONG_ANSWER_CLASSNAME_CN, WRONG_ANSWER_CLASSNAME_NEW, forggettingCurve } from "./constants";
import { forgetting_curve, dateDiffInDays } from "ts-fsrs"

export const needReview = (problem) => {
if (problem.proficiency >= forggettingCurve.length) {
Expand Down Expand Up @@ -169,12 +170,6 @@ export const getCurrentRetrievability = (problem) => {
return 1;
}

const now = Date.now();
const elapsedDays = (now - problem.fsrsState.lastReview) / (24 * 60 * 60 * 1000);
return calculateRetrievability(problem.fsrsState.stability, elapsedDays);
};

// 计算可检索性的辅助函数
const calculateRetrievability = (stability, elapsedDays) => {
return Math.exp(Math.log(0.9) * elapsedDays / stability);
const elapsedDays = dateDiffInDays(new Date(problem.fsrsState.lastReview), new Date());
return forgetting_curve(elapsedDays, problem.fsrsState.stability);
};