Skip to content

Commit

Permalink
add alias term frequncy & pitch accent anki
Browse files Browse the repository at this point in the history
  • Loading branch information
khaitruong922 committed Jul 30, 2024
1 parent 55bda55 commit 2863a8e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ext/js/data/anki-note-data-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,12 +614,13 @@ function addScopeToCss(css, scopeSelector) {
function getTermFrequencies(dictionaryEntry) {
const results = [];
const {headwords} = dictionaryEntry;
for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, hasReading, frequency, displayValue} of dictionaryEntry.frequencies) {
for (const {headwordIndex, dictionary, dictionaryAlias, dictionaryIndex, dictionaryPriority, hasReading, frequency, displayValue} of dictionaryEntry.frequencies) {
const {term, reading} = headwords[headwordIndex];
results.push({
index: results.length,
expressionIndex: headwordIndex,
dictionary,
dictionaryAlias,
dictionaryOrder: {
index: dictionaryIndex,
priority: dictionaryPriority,
Expand All @@ -640,14 +641,15 @@ function getTermFrequencies(dictionaryEntry) {
function getTermPitches(dictionaryEntry) {
const results = [];
const {headwords} = dictionaryEntry;
for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations} of dictionaryEntry.pronunciations) {
for (const {headwordIndex, dictionary, dictionaryAlias, dictionaryIndex, dictionaryPriority, pronunciations} of dictionaryEntry.pronunciations) {
const {term, reading} = headwords[headwordIndex];
const pitches = getPronunciationsOfType(pronunciations, 'pitch-accent');
const cachedPitches = createCachedValue(getTermPitchesInner.bind(null, pitches));
results.push({
index: results.length,
expressionIndex: headwordIndex,
dictionary,
dictionaryAlias,
dictionaryOrder: {
index: dictionaryIndex,
priority: dictionaryPriority,
Expand Down Expand Up @@ -758,13 +760,14 @@ function getTermExpressions(dictionaryEntry) {
function getTermExpressionFrequencies(dictionaryEntry, i) {
const results = [];
const {headwords, frequencies} = dictionaryEntry;
for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, hasReading, frequency, displayValue} of frequencies) {
for (const {headwordIndex, dictionary, dictionaryAlias, dictionaryIndex, dictionaryPriority, hasReading, frequency, displayValue} of frequencies) {
if (headwordIndex !== i) { continue; }
const {term, reading} = headwords[headwordIndex];
results.push({
index: results.length,
expressionIndex: headwordIndex,
dictionary,
dictionaryAlias,
dictionaryOrder: {
index: dictionaryIndex,
priority: dictionaryPriority,
Expand All @@ -786,7 +789,7 @@ function getTermExpressionFrequencies(dictionaryEntry, i) {
function getTermExpressionPitches(dictionaryEntry, i) {
const results = [];
const {headwords, pronunciations: termPronunciations} = dictionaryEntry;
for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations} of termPronunciations) {
for (const {headwordIndex, dictionary, dictionaryAlias, dictionaryIndex, dictionaryPriority, pronunciations} of termPronunciations) {
if (headwordIndex !== i) { continue; }
const {term, reading} = headwords[headwordIndex];
const pitches = getPronunciationsOfType(pronunciations, 'pitch-accent');
Expand All @@ -795,6 +798,7 @@ function getTermExpressionPitches(dictionaryEntry, i) {
index: results.length,
expressionIndex: headwordIndex,
dictionary,
dictionaryAlias,
dictionaryOrder: {
index: dictionaryIndex,
priority: dictionaryPriority,
Expand Down
2 changes: 2 additions & 0 deletions types/ext/anki-templates.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export type TermFrequency = {
index: number;
expressionIndex: number;
dictionary: string;
dictionaryAlias: string;
dictionaryOrder: {
index: number;
priority: number;
Expand All @@ -256,6 +257,7 @@ export type TermPitchAccent = {
index: number;
expressionIndex: number;
dictionary: string;
dictionaryAlias: string;
dictionaryOrder: {
index: number;
priority: number;
Expand Down

0 comments on commit 2863a8e

Please sign in to comment.