Skip to content

Commit

Permalink
add new vocab count
Browse files Browse the repository at this point in the history
  • Loading branch information
kampffrosch94 committed Nov 25, 2024
1 parent 2b9b2b1 commit 470eb45
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/components/CoverageOverview/CODeckList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@
export let decks: DeckWithVocabState[];
export let startTime: number;
function compute_new_count(deck: DeckWithVocabState): number {
let count = 0;
for (const v of deck.vocabs) {
if (v.state[0] === "new") {
count++;
}
}
return count;
}
let min_coverage = 0;
let absolute_min_words = 0;
let absolute_max_words = 0;
let absolute_min_vocabs = 0;
let absolute_max_vocabs = 0;
let absolute_max_new = 0;
let custom_learnahead = 200;
let decks_with_coverage = decks.map((deck) => {
let lc_custom = learnAheadCoverage(deck.vocabs, custom_learnahead);
Expand All @@ -23,6 +34,7 @@
lc_100: learnAheadCoverage(deck.vocabs, 100),
lc_custom: lc_custom,
cliff: lc_custom - deck.learning_coverage,
new_count: compute_new_count(deck),
};
});
console.log(`[${Date.now() - startTime}] Done with coverage prediction`);
Expand All @@ -40,6 +52,7 @@
lc_100: learnAheadCoverage(deck.vocabs, 100),
lc_custom: lc_custom,
cliff: lc_custom - deck.learning_coverage,
new_count: compute_new_count(deck),
};
});
handler = new DataHandler(decks_with_coverage);
Expand All @@ -58,6 +71,9 @@
absolute_max_vocabs = decks_with_coverage
.map((it) => it.vocab_count)
.reduce((acc, curr) => Math.max(acc, curr));
absolute_max_new = decks_with_coverage
.map((it) => it.new_count)
.reduce((acc, curr) => Math.max(acc, curr));
}
</script>

Expand All @@ -74,6 +90,7 @@ Custom learnahead:
<Th {handler} orderBy="name">Name</Th>
<Th {handler} orderBy="vocab_count">Vocab</Th>
<Th {handler} orderBy="word_count">Words</Th>
<Th {handler} orderBy="new_count">New<br>Count</Th>
<Th {handler} orderBy="known_coverage">Coverage</Th>
<Th {handler} orderBy="learning_coverage">
Learning
Expand All @@ -99,6 +116,7 @@ Custom learnahead:
min={absolute_min_words}
max={absolute_max_words}
/>
<ThFilterMinMax {handler} filterBy="new_count" max={absolute_max_new}/>
<ThFilterMinMax {handler} filterBy="known_coverage" />
<ThFilterMinMax {handler} filterBy="learning_coverage" />
<ThFilterMinMax {handler} filterBy="lc_50" />
Expand All @@ -113,6 +131,7 @@ Custom learnahead:
<td>{row.name}</td>
<td>{row.vocab_count}</td>
<td>{row.word_count}</td>
<td>{row.new_count}</td>
<td>{row.known_coverage.toFixed(2)}</td>
<td>{row.learning_coverage.toFixed(2)}</td>
<td>{row.lc_50.toFixed(2)}</td>
Expand Down

0 comments on commit 470eb45

Please sign in to comment.