slaypni / sm-15 Goto Github PK
View Code? Open in Web Editor NEWSpaced repetition for memorizing tons of things.
License: MIT License
Spaced repetition for memorizing tons of things.
License: MIT License
sorry I am a rookie ,I don't know how to import is as a JavaScript library,could you give me any advices
Hello Slaypni,
This is really amazing that seeing someone able to reverse engineering SM algo. Are you able to reverse engineering SM-18 algo? I am willing to pay for it. Please contact me on telegram at @habibi4898
Hi @slaypni ,
Thanks for writing out this implementation, I have used it as a reference when I try to implement the algorithm.
There are several initial "tweaks" to make the algorithm work properly, such as AF range, REP range etc. I found your implementation follows the description quite well. But for the forgetting curve initialization, I cannot found any relevant description about supermemo site. The closet I could find is:
At the beginning of the learning process, there is no repetition history and no repetition data to compute R-Factors. It will take some time before your first forgetting curves are plotted. For that reason, the initial value of the RF matrix is taken from the model of a less-than-average student.
I am curious about how you choose to setup that curve ?
Best,
I'm using the algorithm as a backend to an application with about 5-6000 items in it. I've noticed on any item if I answer an item with values 5, then 0, then 5, the data in the algorithm gets into a state where any answer of 5 on any item results in a null value from OFM.of which then results in different NaN or null values and eventually results in the dueDate being "Invalid Date." There is seemingly no way to recover from this state.
Here is a video of my app showing the problem. In the lower right is the item.data() of the item being answered. "Remember" translates to an answer of 5 and "I don't know" translates to an answer of 0.
https://youtu.be/OdpKgqCOEFM
Here is the results of SM.data(), JSON.stringify-ed so you can try for yourself:
On first initializing the app, which just involves instantiation SM and adding each item using addItem. The value of the item is just an ID, since I'm just using sm.js as a backend: https://gist.github.com/meelash/7d9ef5c9cd5cf3743abcbc00ffbe0622
After answering with "5" to any random item (this is sm.data() but I deleted the .q array to make it more manageable): https://gist.github.com/meelash/119cf9deb2b33743ff0bb4d8742af1e3
After answering with "0" to that same item. At this point sm.js is in an unrecoverable broken state: https://gist.github.com/meelash/78189f7a9e26f632a11eabb3040716b7
Which becomes apparent after answering with "5" to that item or any other item: https://gist.github.com/meelash/df09618cdfebfa7623e106532f049a5e
I can supply these as the raw output as well, that has the quotation marks escaped.
Any help or any clue in what could be going wrong or if I'm missing something in my usage would be highly appreciated.
I'd like to make a SM-17 npm package.
Trying to instantiate an SM
produces a type error. For some reason, points
is undefined.
C:\Users\shodan\Desktop>coffee --version
CoffeeScript version 2.7.0
C:\Users\shodan\Desktop>coffee supermemo.coffee
(a)add, (n)next, (N)next advanceably, (s)save, (l)load, (e)exit
TypeError: Cannot read properties of undefined (reading 'length')
at exponentialRegression (C:\Users\shodan\Desktop\supermemo.coffee:314:14)
at ForgettingCurve.uf (C:\Users\shodan\Desktop\supermemo.coffee:252:18)
at RFM.rf (C:\Users\shodan\Desktop\supermemo.coffee:261:61)
at OFM.<anonymous> (C:\Users\shodan\Desktop\supermemo.coffee:277:68)
at OFM.<anonymous> (C:\Users\shodan\Desktop\supermemo.coffee:542:16)
at OFM.update (C:\Users\shodan\Desktop\supermemo.coffee:277:12)
at new OFM (C:\Users\shodan\Desktop\supermemo.coffee:272:6)
at new SM (C:\Users\shodan\Desktop\supermemo.coffee:16:12)
at main (C:\Users\shodan\Desktop\supermemo.coffee:443:8)
at Object.<anonymous> (C:\Users\shodan\Desktop\supermemo.coffee:540:1)
at Object.<anonymous> (C:\Users\shodan\Desktop\supermemo.coffee:5:4)
at Module._compile (node:internal/modules/cjs/loader:1275:14)
at Object.CoffeeScript.run (C:\Users\shodan\AppData\Roaming\npm\node_modules\coffeescript\lib\coffeescript\index.js:67:23)
at compileScript (C:\Users\shodan\AppData\Roaming\npm\node_modules\coffeescript\lib\coffeescript\command.js:285:29)
at compilePath (C:\Users\shodan\AppData\Roaming\npm\node_modules\coffeescript\lib\coffeescript\command.js:237:14)
at Object.exports.run (C:\Users\shodan\AppData\Roaming\npm\node_modules\coffeescript\lib\coffeescript\command.js:158:20)
at Object.<anonymous> (C:\Users\shodan\AppData\Roaming\npm\node_modules\coffeescript\bin\coffee:22:45)
at Module._compile (node:internal/modules/cjs/loader:1275:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
at Module.load (node:internal/modules/cjs/loader:1133:32)
at Function.Module._load (node:internal/modules/cjs/loader:972:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47
I want to use this project as a js library, but I found the output optimumInterval sometimes can be a NaN value:
When I put three review histories into it:
mark=5,date=now
mark=3,date=now+10days
mark=3,date=now+100days
the final optimumInterval will be a NaN value:
repetition:0,date:2021-01-01,mark:5,optimumInterval:4.0 hour
repetition:1,date:2021-01-11,mark:3,optimumInterval:59.2 days
repetition:2,date:2021-04-11,mark:3,optimumInterval:NaN days
code to reproduce this issue:
const sm_util = require("./sm.js")
const sm = new sm_util.SM()
const ONE_DAY = 24 * 3600 * 1000
function mytest() {
const now = new Date().getTime()
const item = sm.addItem("")
answer_core(5, item, new Date(now))
answer_core(3, item, new Date(now + ONE_DAY * 10))
answer_core(3, item, new Date(now + ONE_DAY * 100))
}
function answer_core(mark, item, date) {
sm.answer(mark, item, date)
const data = item.data()
const optimumInterval = format_interval(data["optimumInterval"])
const repetition = data["repetition"]
console.log(`repetition:${repetition},date:${formatDate(date)},mark:${mark},optimumInterval:${optimumInterval}`)
}
function format_interval(optimumInterval) {
let days = optimumInterval / 24 / 3600 / 1000
if (days < 1.0) {
days = (optimumInterval / 1000 / 3600).toFixed(1) + " hour"
} else {
days = days.toFixed(1) + " days"
}
return days
}
function formatDate(date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2)
month = '0' + month;
if (day.length < 2)
day = '0' + day;
return [year, month, day].join('-');
}
mytest()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.