@vue-skuilder/db 0.1.29 → 0.1.31-a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +5 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +5 -4
- package/dist/core/index.mjs.map +1 -1
- package/dist/impl/couch/index.js +5 -4
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +5 -4
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.js +5 -4
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +5 -4
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/navigators/generators/elo.ts +17 -6
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.31-a",
|
|
8
8
|
"description": "Database layer for vue-skuilder",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"module": "dist/index.mjs",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@nilock2/pouchdb-authentication": "^1.0.2",
|
|
51
|
-
"@vue-skuilder/common": "0.1.
|
|
51
|
+
"@vue-skuilder/common": "0.1.31-a",
|
|
52
52
|
"cross-fetch": "^4.1.0",
|
|
53
53
|
"moment": "^2.29.4",
|
|
54
54
|
"pouchdb": "^9.0.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"vite": "^7.0.0",
|
|
63
63
|
"vitest": "^4.0.15"
|
|
64
64
|
},
|
|
65
|
-
"stableVersion": "0.1.
|
|
65
|
+
"stableVersion": "0.1.31a"
|
|
66
66
|
}
|
|
@@ -88,30 +88,41 @@ export default class ELONavigator extends ContentNavigator implements CardGenera
|
|
|
88
88
|
const cardIds = newCards.map((c) => c.cardID);
|
|
89
89
|
const cardEloData = await this.course.getCardEloData(cardIds);
|
|
90
90
|
|
|
91
|
-
// Score new cards by ELO distance
|
|
91
|
+
// Score new cards by ELO distance, then apply weighted sampling without
|
|
92
|
+
// replacement using the Efraimidis-Spirakis (A-Res) algorithm:
|
|
93
|
+
//
|
|
94
|
+
// key = U ^ (1 / rawScore) where U ~ Uniform(0, 1)
|
|
95
|
+
//
|
|
96
|
+
// Sorting by key descending produces a weighted random sample: high-score
|
|
97
|
+
// cards are still preferred, but cards with equal scores are shuffled
|
|
98
|
+
// uniformly rather than deterministically. This prevents the same failed
|
|
99
|
+
// cards from looping back every session when many cards share similar ELO.
|
|
100
|
+
//
|
|
101
|
+
// Edge case: rawScore=0 → key=0, never selected (correct exclusion).
|
|
92
102
|
const scored: WeightedCard[] = newCards.map((c, i) => {
|
|
93
103
|
const cardElo = cardEloData[i]?.global?.score ?? 1000;
|
|
94
104
|
const distance = Math.abs(cardElo - userGlobalElo);
|
|
95
|
-
const
|
|
105
|
+
const rawScore = Math.max(0, 1 - distance / 500);
|
|
106
|
+
const samplingKey = rawScore > 0 ? Math.random() ** (1 / rawScore) : 0;
|
|
96
107
|
|
|
97
108
|
return {
|
|
98
109
|
cardId: c.cardID,
|
|
99
110
|
courseId: c.courseID,
|
|
100
|
-
score,
|
|
111
|
+
score: samplingKey,
|
|
101
112
|
provenance: [
|
|
102
113
|
{
|
|
103
114
|
strategy: 'elo',
|
|
104
115
|
strategyName: this.strategyName || this.name,
|
|
105
116
|
strategyId: this.strategyId || 'NAVIGATION_STRATEGY-ELO-default',
|
|
106
117
|
action: 'generated',
|
|
107
|
-
score,
|
|
108
|
-
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}),
|
|
118
|
+
score: samplingKey,
|
|
119
|
+
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), raw ${rawScore.toFixed(3)}, key ${samplingKey.toFixed(3)}`,
|
|
109
120
|
},
|
|
110
121
|
],
|
|
111
122
|
};
|
|
112
123
|
});
|
|
113
124
|
|
|
114
|
-
// Sort by
|
|
125
|
+
// Sort by sampling key descending (weighted sample without replacement)
|
|
115
126
|
scored.sort((a, b) => b.score - a.score);
|
|
116
127
|
|
|
117
128
|
const result = scored.slice(0, limit);
|