@shaxpir/duiduidui-models 1.5.0 → 1.5.2

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.
@@ -15,7 +15,7 @@ export declare class BayesianScoreModel {
15
15
  * Calculate uncertainty for a given Bayesian score.
16
16
  * Higher values indicate less confidence in the theta estimate.
17
17
  */
18
- static getUncertainty(score: BayesianScore): number;
18
+ static calculateUncertainty(alpha: number, beta: number): number;
19
19
  /**
20
20
  * Calculate confidence interval for theta estimate.
21
21
  * Uses properties of the Beta distribution to estimate bounds.
@@ -21,15 +21,15 @@ class BayesianScoreModel {
21
21
  nextScore.beta += (weight * 1.0);
22
22
  }
23
23
  nextScore.theta = nextScore.alpha / (nextScore.alpha + nextScore.beta);
24
- nextScore.uncertainty = BayesianScoreModel.getUncertainty(nextScore);
24
+ nextScore.uncertainty = BayesianScoreModel.calculateUncertainty(nextScore.alpha, nextScore.beta);
25
25
  return nextScore;
26
26
  }
27
27
  /**
28
28
  * Calculate uncertainty for a given Bayesian score.
29
29
  * Higher values indicate less confidence in the theta estimate.
30
30
  */
31
- static getUncertainty(score) {
32
- return 1 / (score.alpha + score.beta + 1);
31
+ static calculateUncertainty(alpha, beta) {
32
+ return 1 / (alpha + beta + 1);
33
33
  }
34
34
  /**
35
35
  * Calculate confidence interval for theta estimate.
@@ -34,6 +34,7 @@ export interface AnnotatedPhrase extends Phrase {
34
34
  starred_at: CompactDateTime | null;
35
35
  alpha: number;
36
36
  beta: number;
37
- proficiency: number;
37
+ theta: number;
38
+ uncertainty: number;
38
39
  reviews: ReviewLike[];
39
40
  }
@@ -5,12 +5,33 @@ import { Content, ContentBody, ContentId, ContentMeta } from "./Content";
5
5
  import { BuiltInPhrase, Phrase, PhraseExample } from './Phrase';
6
6
  import { ReviewLike } from "./Review";
7
7
  import { ShareSync } from '../repo';
8
+ export interface TermSummary {
9
+ text: string;
10
+ sense_rank: number;
11
+ difficulty: number;
12
+ phrase_id: number | null;
13
+ starred_at: CompactDateTime | null;
14
+ alpha: number;
15
+ beta: number;
16
+ theta: number;
17
+ uncertainty: number;
18
+ review_count: number;
19
+ last_review_utc: CompactDateTime;
20
+ }
8
21
  export interface TermPayload extends BayesianScore {
9
22
  text: string;
10
23
  sense_rank: number;
11
24
  difficulty: number;
12
25
  phrase_id: number | null;
13
26
  starred_at: CompactDateTime | null;
27
+ alpha: number;
28
+ beta: number;
29
+ theta: number;
30
+ uncertainty: number;
31
+ tags: string[];
32
+ reviews: ReviewLike[];
33
+ review_count: number;
34
+ last_review_utc: CompactDateTime;
14
35
  hanzi_count?: number;
15
36
  pinyin?: string;
16
37
  pinyin_tokenized?: string;
@@ -20,10 +41,6 @@ export interface TermPayload extends BayesianScore {
20
41
  components?: PhraseExample[];
21
42
  examples?: PhraseExample[];
22
43
  keywords?: string[];
23
- tags: string[];
24
- reviews: ReviewLike[];
25
- review_count: number;
26
- last_review_utc: CompactDateTime;
27
44
  }
28
45
  export interface TermBody extends ContentBody {
29
46
  meta: ContentMeta;
@@ -68,7 +68,7 @@ class Term extends Content_1.Content {
68
68
  alpha: 0.5,
69
69
  beta: 0.5,
70
70
  theta: 0.5,
71
- uncertainty: BayesianScore_1.BayesianScoreModel.getUncertainty({ alpha: 0.5, beta: 0.5, theta: 0.5, uncertainty: 0 }),
71
+ uncertainty: BayesianScore_1.BayesianScoreModel.calculateUncertainty(0.5, 0.5),
72
72
  reviews: [],
73
73
  review_count: 0,
74
74
  last_review_utc: null
@@ -97,7 +97,7 @@ class Term extends Content_1.Content {
97
97
  alpha: 0.5,
98
98
  beta: 0.5,
99
99
  theta: 0.5,
100
- uncertainty: BayesianScore_1.BayesianScoreModel.getUncertainty({ alpha: 0.5, beta: 0.5, theta: 0.5, uncertainty: 0 }),
100
+ uncertainty: BayesianScore_1.BayesianScoreModel.calculateUncertainty(0.5, 0.5),
101
101
  reviews: [],
102
102
  review_count: 0,
103
103
  last_review_utc: null
@@ -158,7 +158,7 @@ class Term extends Content_1.Content {
158
158
  batch.setPathValue(['payload', 'alpha'], alpha);
159
159
  batch.setPathValue(['payload', 'beta'], beta);
160
160
  batch.setPathValue(['payload', 'theta'], theta);
161
- batch.setPathValue(['payload', 'uncertainty'], BayesianScore_1.BayesianScoreModel.getUncertainty({ alpha, beta, theta, uncertainty: 0 }));
161
+ batch.setPathValue(['payload', 'uncertainty'], BayesianScore_1.BayesianScoreModel.calculateUncertainty(alpha, beta));
162
162
  batch.commit();
163
163
  }
164
164
  addReview(review) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"