
为了在Android中创建词汇练习应用程序,我想在Java中实现SuperMemo (SM-2) algorithm.这是间隔重复软件的流行选择,Anki甚至按照我的理解采用它.给出here的源代码示例很难(对我而言)因为缺少代码格式化而且因为它是用Delphi编写的.
SuperMemo states的作者:
Split the kNowledge into smallest possible items.With all items associate an E-Factor equal to 2.5.Repeat items using the following intervals:
I(1):=1
I(2):=6
for n>2: I(n):=I(n-1)*EF
where:
I(n) – inter-repetition interval after the n-th repetition (in days),
EF – E-Factor of a given item
If interval is a fraction, round it up to the nearest integer. After each repetition assess the quality of repetition response in 0-5 grade scale:
5 – perfect response
4 – correct response after a hesitation
3 – correct response recalled with serIoUs difficulty
2 – incorrect response; where the correct one seemed easy to recall
1 – incorrect response; the correct one remembered
0 – complete blackout. After each repetition modify the E-Factor of the recently repeated item according to the formula:
EF’:=EF+(0.1-(5-q)*(0.08+(5-q)*0.02))
where:
EF’ – new value of the E-Factor,
EF – old value of the E-Factor,
q – quality of the response in the 0-5 grade scale.
If EF is less than 1.3 then let EF be 1.3. If the quality response was lower than 3 then start repetitions for the item from the beginning without changing the E-Factor (i.e. use
intervals I(1), I(2) etc. as if the item was memorized anew).After each repetition session of a given day repeat again all items that scored below four in the quality assessment. Continue the
repetitions until all of these items score at least four.
以下是Stack Overflow的一些相关(但不同)的问题:
> What is the spaced repetition algorithm to generate the day intervals?
> Open Source implementation of a Spaced Repetition Algorithm in Java
> Spaced repetition (SRS) for learning
你是如何用Java实现的?
(我最近一直在研究这个问题,我想我有一个答案,所以我将它作为Q& A对提交,以帮助其他人做同样的事情.)
解决方法:
SuperMemo算法
以下是在强制执行spaced repetition的SuperMemo (SM-2) algorithm时我们将要处理的一些术语.
>重复 – 这是用户看到闪卡的次数. 0表示他们尚未研究过,1表示这是他们的第一次,依此类推.在一些文档中它也被称为n.
>质量 – 也称为评估质量.这是闪存卡的难度(由用户定义).比例从0到5.
> easyiness – 这也称为easyiness factor或EFactor或EF.它是乘数,用于增加间隔重复的“空间”.范围从1.3到2.5.
> interval – 这是重复之间的时间长度(以天为单位).它是间隔重复的“空间”.
> nextPractice – 这是闪卡随后再次审核的date/time.
默认值
@H_419_72@int repetitions = 0;int interval = 1;float easiness = 2.5;码
我发现this Python implementation比SuperMemo example source code更容易理解,所以我或多或少跟着它.
@H_419_72@private voID calculateSuperMemo2Algorithm(FlashCard card, int quality) { if (quality < 0 || quality > 5) { // throw error here or ensure elsewhere that quality is always within 0-5 } // retrIEve the stored values (default values if new cards) int repetitions = card.getRepetitions(); float easiness = card.getEasinessFactor(); int interval = card.getInterval(); // easiness factor easiness = (float) Math.max(1.3, easiness + 0.1 - (5.0 - quality) * (0.08 + (5.0 - quality) * 0.02)); // repetitions if (quality < 3) { repetitions = 0; } else { repetitions += 1; } // interval if (repetitions <= 1) { interval = 1; } else if (repetitions == 2) { interval = 6; } else { interval = Math.round(interval * easiness); } // next practice int secondsInDay = 60 * 60 * 24; long Now = System.currentTimeMillis(); long nextPracticeDate = Now + secondsInDay*interval; // Store the nextPracticeDate in the database // ...}笔记
>上面的代码没有设置容易度的上限.应该是2.5吗?文档和源代码似乎互相矛盾.
>如果质量评估小于3,文档也听起来似乎不应该更新容易因素,但这似乎与源代码相矛盾.在我看来,更新它更有意义(只要它保持在1.3以上).无论如何,我每次都在更新它.
> Anki源代码是here.虽然这是一个很大的项目,但我还没有深入挖掘它们的算法版本.
> This post讨论了SM-2的一些问题以及这些问题的解决方案.
以上是内存溢出为你收集整理的java – SuperMemo(SM-2)的间隔重复算法全部内容,希望文章能够帮你解决java – SuperMemo(SM-2)的间隔重复算法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)