@shaxpir/duiduidui-models 1.4.29 → 1.5.0
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/models/Progress.d.ts +1 -12
- package/dist/models/Progress.js +0 -19
- package/dist/models/Term.d.ts +4 -0
- package/dist/models/Term.js +31 -2
- package/package.json +1 -1
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { Doc } from '@shaxpir/sharedb/lib/client';
|
|
2
|
-
import { CompactDateTime } from "@shaxpir/shaxpir-common";
|
|
3
2
|
import { ShareSync } from '../repo';
|
|
4
|
-
import {
|
|
3
|
+
import { Bounds } from './BayesianScore';
|
|
5
4
|
import { Content, ContentBody, ContentId, ContentMeta } from "./Content";
|
|
6
|
-
export interface PhraseProgress extends BayesianScore {
|
|
7
|
-
text: string;
|
|
8
|
-
sense_rank: number;
|
|
9
|
-
difficulty: number;
|
|
10
|
-
last_review_utc?: CompactDateTime;
|
|
11
|
-
}
|
|
12
5
|
export interface UncertainValue {
|
|
13
6
|
value: number;
|
|
14
7
|
uncertainty: number;
|
|
@@ -16,7 +9,6 @@ export interface UncertainValue {
|
|
|
16
9
|
}
|
|
17
10
|
export interface ProgressPayload {
|
|
18
11
|
skill_level: UncertainValue;
|
|
19
|
-
phrases: Record<string, PhraseProgress>;
|
|
20
12
|
cognitive_load: number;
|
|
21
13
|
}
|
|
22
14
|
export interface ProgressBody extends ContentBody {
|
|
@@ -35,13 +27,10 @@ export declare class Progress extends Content {
|
|
|
35
27
|
getSkillLevelUpperBound(): number;
|
|
36
28
|
needsCalibration(): boolean;
|
|
37
29
|
getCognitiveLoad(): number;
|
|
38
|
-
getPhrases(): Record<string, PhraseProgress>;
|
|
39
30
|
setSkillLevel(uncertainValue: UncertainValue): void;
|
|
40
31
|
setSkillLevelValue(value: number): void;
|
|
41
32
|
setSkillLevelUncertainty(uncertainty: number): void;
|
|
42
33
|
setSkillLevelLowerBound(lowerBound: number): void;
|
|
43
34
|
setSkillLevelUpperBound(upperBound: number): void;
|
|
44
35
|
setCognitiveLoad(value: number): void;
|
|
45
|
-
updatePhraseProgress(phraseId: string, progress: PhraseProgress): void;
|
|
46
|
-
updateMultiplePhrases(updates: Record<string, PhraseProgress>): void;
|
|
47
36
|
}
|
package/dist/models/Progress.js
CHANGED
|
@@ -31,7 +31,6 @@ class Progress extends Content_1.Content {
|
|
|
31
31
|
upper: 1000 // Could potentially be advanced
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
phrases: {},
|
|
35
34
|
cognitive_load: 0
|
|
36
35
|
}
|
|
37
36
|
});
|
|
@@ -72,10 +71,6 @@ class Progress extends Content_1.Content {
|
|
|
72
71
|
this.checkDisposed("Progress.getCognitiveLoad");
|
|
73
72
|
return this.payload.cognitive_load;
|
|
74
73
|
}
|
|
75
|
-
getPhrases() {
|
|
76
|
-
this.checkDisposed("Progress.getPhrases");
|
|
77
|
-
return this.payload.phrases;
|
|
78
|
-
}
|
|
79
74
|
setSkillLevel(uncertainValue) {
|
|
80
75
|
this.checkDisposed("Progress.setSkillLevel");
|
|
81
76
|
if (!shaxpir_common_1.Struct.equals(this.payload.skill_level, uncertainValue)) {
|
|
@@ -127,19 +122,5 @@ class Progress extends Content_1.Content {
|
|
|
127
122
|
batch.commit();
|
|
128
123
|
}
|
|
129
124
|
}
|
|
130
|
-
updatePhraseProgress(phraseId, progress) {
|
|
131
|
-
this.checkDisposed("Progress.updatePhraseProgress");
|
|
132
|
-
const batch = new Operation_1.BatchOperation(this);
|
|
133
|
-
batch.setPathValue(['payload', 'phrases', phraseId], progress);
|
|
134
|
-
batch.commit();
|
|
135
|
-
}
|
|
136
|
-
updateMultiplePhrases(updates) {
|
|
137
|
-
this.checkDisposed("Progress.updateMultiplePhrases");
|
|
138
|
-
const batch = new Operation_1.BatchOperation(this);
|
|
139
|
-
for (const [phraseId, progress] of Object.entries(updates)) {
|
|
140
|
-
batch.setPathValue(['payload', 'phrases', phraseId], progress);
|
|
141
|
-
}
|
|
142
|
-
batch.commit();
|
|
143
|
-
}
|
|
144
125
|
}
|
|
145
126
|
exports.Progress = Progress;
|
package/dist/models/Term.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export interface TermPayload extends BayesianScore {
|
|
|
22
22
|
keywords?: string[];
|
|
23
23
|
tags: string[];
|
|
24
24
|
reviews: ReviewLike[];
|
|
25
|
+
review_count: number;
|
|
26
|
+
last_review_utc: CompactDateTime;
|
|
25
27
|
}
|
|
26
28
|
export interface TermBody extends ContentBody {
|
|
27
29
|
meta: ContentMeta;
|
|
@@ -47,4 +49,6 @@ export declare class Term extends Content {
|
|
|
47
49
|
setStarredAt(value: CompactDateTime | null): void;
|
|
48
50
|
updateBayesianScore(alpha: number, beta: number, theta: number): void;
|
|
49
51
|
addReview(review: ReviewLike): void;
|
|
52
|
+
getReviewCount(): number;
|
|
53
|
+
getLastReviewUtc(): CompactDateTime | null;
|
|
50
54
|
}
|
package/dist/models/Term.js
CHANGED
|
@@ -69,7 +69,9 @@ class Term extends Content_1.Content {
|
|
|
69
69
|
beta: 0.5,
|
|
70
70
|
theta: 0.5,
|
|
71
71
|
uncertainty: BayesianScore_1.BayesianScoreModel.getUncertainty({ alpha: 0.5, beta: 0.5, theta: 0.5, uncertainty: 0 }),
|
|
72
|
-
reviews: []
|
|
72
|
+
reviews: [],
|
|
73
|
+
review_count: 0,
|
|
74
|
+
last_review_utc: null
|
|
73
75
|
}
|
|
74
76
|
});
|
|
75
77
|
}
|
|
@@ -96,7 +98,9 @@ class Term extends Content_1.Content {
|
|
|
96
98
|
beta: 0.5,
|
|
97
99
|
theta: 0.5,
|
|
98
100
|
uncertainty: BayesianScore_1.BayesianScoreModel.getUncertainty({ alpha: 0.5, beta: 0.5, theta: 0.5, uncertainty: 0 }),
|
|
99
|
-
reviews: []
|
|
101
|
+
reviews: [],
|
|
102
|
+
review_count: 0,
|
|
103
|
+
last_review_utc: null
|
|
100
104
|
}
|
|
101
105
|
});
|
|
102
106
|
}
|
|
@@ -160,6 +164,31 @@ class Term extends Content_1.Content {
|
|
|
160
164
|
addReview(review) {
|
|
161
165
|
this.checkDisposed("Term.addReview");
|
|
162
166
|
this._reviewsView.push(review);
|
|
167
|
+
// Count reviews again.
|
|
168
|
+
let reviewCount = 0;
|
|
169
|
+
let lastReviewUtc = null;
|
|
170
|
+
this._reviewsView.forEach((idx, r) => {
|
|
171
|
+
// We only count *actual* reviews, not implied reviews...
|
|
172
|
+
if (!r.hasOwnProperty('context') && !r.hasOwnProperty('weight')) {
|
|
173
|
+
const reviewUtc = r.at.utc_time;
|
|
174
|
+
if (!lastReviewUtc || shaxpir_common_1.Time.isDateTimeAfter(reviewUtc, lastReviewUtc)) {
|
|
175
|
+
lastReviewUtc = reviewUtc;
|
|
176
|
+
}
|
|
177
|
+
reviewCount++;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
181
|
+
batch.setPathValue(['payload', 'review_count'], reviewCount);
|
|
182
|
+
batch.setPathValue(['payload', 'last_review_utc'], lastReviewUtc);
|
|
183
|
+
batch.commit();
|
|
184
|
+
}
|
|
185
|
+
getReviewCount() {
|
|
186
|
+
this.checkDisposed("Term.getReviewCount");
|
|
187
|
+
return this.payload.review_count;
|
|
188
|
+
}
|
|
189
|
+
getLastReviewUtc() {
|
|
190
|
+
this.checkDisposed("Term.getLastReviewUtc");
|
|
191
|
+
return this.payload.last_review_utc;
|
|
163
192
|
}
|
|
164
193
|
}
|
|
165
194
|
exports.Term = Term;
|