henkan 2.2.4 → 2.2.5
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/index.cjs.js +144 -81
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.mjs +138 -78
- package/dist/index.mjs.map +3 -3
- package/dist/types/types.d.ts +6 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/docs/api/functions/convertJawiktionaryAsync.md +1 -1
- package/docs/api/functions/convertJawiktionarySync.md +1 -1
- package/docs/api/functions/generateAnkiNote.md +1 -1
- package/docs/api/functions/generateAnkiNotesFile.md +1 -1
- package/docs/api/functions/getKanji.md +1 -1
- package/docs/api/functions/getKanjiExtended.md +1 -1
- package/docs/api/functions/getWord.md +1 -1
- package/docs/api/functions/getWordDefinitions.md +1 -1
- package/docs/api/functions/getWordDefinitionsWithFurigana.md +1 -1
- package/docs/api/interfaces/DefaultNoteInfo.md +4 -4
- package/docs/api/interfaces/Grammar.md +15 -15
- package/docs/api/interfaces/GrammarMeaning.md +3 -3
- package/docs/api/interfaces/Kana.md +11 -11
- package/docs/api/interfaces/Kanji.md +23 -23
- package/docs/api/interfaces/KanjiComponent.md +3 -3
- package/docs/api/interfaces/KanjiForm.md +4 -4
- package/docs/api/interfaces/NoteAndTag.md +3 -3
- package/docs/api/interfaces/NoteHeaderKeys.md +7 -7
- package/docs/api/interfaces/Phrase.md +5 -5
- package/docs/api/interfaces/Radical.md +16 -16
- package/docs/api/interfaces/Reading.md +5 -5
- package/docs/api/interfaces/ResultEntry.md +7 -7
- package/docs/api/interfaces/Translation.md +3 -3
- package/docs/api/interfaces/UsefulRegExps.md +8 -8
- package/docs/api/interfaces/Word.md +15 -15
- package/docs/api/interfaces/WordDefinitionPair.md +12 -0
- package/docs/api/type-aliases/Dict.md +1 -1
- package/docs/api/type-aliases/EntryType.md +1 -1
- package/docs/api/type-aliases/Result.md +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1678,11 +1678,10 @@ function createEntryMaps(jmDict, kanjiDic, tanakaExamples, wordDefinitionPairs,
|
|
|
1678
1678
|
word.isCommon
|
|
1679
1679
|
);
|
|
1680
1680
|
const localPartParts = /* @__PURE__ */ new Set();
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
}
|
|
1681
|
+
for (const reading of rkf.readings) {
|
|
1682
|
+
entryParts.add(reading.reading);
|
|
1683
|
+
localPartParts.add(reading.reading);
|
|
1684
|
+
}
|
|
1686
1685
|
if (rkf.kanjiForms && rkf.kanjiForms.length > 0)
|
|
1687
1686
|
for (const kanjiForm of rkf.kanjiForms) {
|
|
1688
1687
|
entryParts.add(kanjiForm.form);
|
|
@@ -1846,12 +1845,11 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1846
1845
|
word.kanjiForms,
|
|
1847
1846
|
word.isCommon
|
|
1848
1847
|
);
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
}
|
|
1848
|
+
for (const r of rkf.readings) {
|
|
1849
|
+
validReadings.add(r.reading);
|
|
1850
|
+
wordReadings.add(r.reading);
|
|
1851
|
+
validForms.add(r.reading);
|
|
1852
|
+
}
|
|
1855
1853
|
if (rkf.kanjiForms && rkf.kanjiForms.length > 0)
|
|
1856
1854
|
for (const kf of rkf.kanjiForms) {
|
|
1857
1855
|
validKanjiForms.add(kf.form);
|
|
@@ -1875,7 +1873,7 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1875
1873
|
if (validKanjiForms && validKanjiForms.has(entry.word)) {
|
|
1876
1874
|
valid = true;
|
|
1877
1875
|
for (const sense of entry.senses) {
|
|
1878
|
-
if (sense.form_of && sense.form_of.some((form) =>
|
|
1876
|
+
if (sense.form_of && sense.form_of.some((form) => validForms.has(form)))
|
|
1879
1877
|
validFormOfEntries.add(entry.word);
|
|
1880
1878
|
for (const gloss of sense.glosses) {
|
|
1881
1879
|
let hasForm = false;
|
|
@@ -1891,10 +1889,10 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1891
1889
|
}
|
|
1892
1890
|
if (entry.forms) {
|
|
1893
1891
|
for (const form of entry.forms)
|
|
1894
|
-
if (
|
|
1892
|
+
if (validForms.has(form)) validFormsEntries.add(entry.word);
|
|
1895
1893
|
}
|
|
1896
1894
|
}
|
|
1897
|
-
if (
|
|
1895
|
+
if (validForms.has(entry.word)) {
|
|
1898
1896
|
valid = true;
|
|
1899
1897
|
const ftEntry = entriesWithFormTitlesGlobal.get(entry.word);
|
|
1900
1898
|
if (ftEntry) ftEntry.push(entry);
|
|
@@ -1905,9 +1903,7 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1905
1903
|
if (tEntry) tEntry.push(entry);
|
|
1906
1904
|
else validTitleEntries.set(entry.word, [entry]);
|
|
1907
1905
|
}
|
|
1908
|
-
if (entry.forms &&
|
|
1909
|
-
(form) => validKanjiForms.has(form) || validReadings.has(form)
|
|
1910
|
-
)) {
|
|
1906
|
+
if (entry.forms && validForms.has(entry.word) && entry.forms.some((form) => validForms.has(form))) {
|
|
1911
1907
|
const wfEntry = entriesWithFormsGlobal.get(entry.word);
|
|
1912
1908
|
if (wfEntry) wfEntry.push(entry);
|
|
1913
1909
|
else entriesWithFormsGlobal.set(entry.word, [entry]);
|
|
@@ -2034,7 +2030,10 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2034
2030
|
entriesWithForms.push(
|
|
2035
2031
|
...fe.filter(
|
|
2036
2032
|
(ent) => ent.forms && ent.forms.some(
|
|
2037
|
-
(form) =>
|
|
2033
|
+
(form) => {
|
|
2034
|
+
var _a2;
|
|
2035
|
+
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2036
|
+
}
|
|
2038
2037
|
)
|
|
2039
2038
|
)
|
|
2040
2039
|
);
|
|
@@ -2046,16 +2045,22 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2046
2045
|
if (te)
|
|
2047
2046
|
entriesWithTitles.push(
|
|
2048
2047
|
...te.filter(
|
|
2049
|
-
(ent) => ent.forms &&
|
|
2050
|
-
(form) =>
|
|
2051
|
-
|
|
2048
|
+
(ent) => ent.forms && ent.forms.some(
|
|
2049
|
+
(form) => {
|
|
2050
|
+
var _a2;
|
|
2051
|
+
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2052
|
+
}
|
|
2053
|
+
)
|
|
2052
2054
|
)
|
|
2053
2055
|
);
|
|
2054
2056
|
if (fe)
|
|
2055
2057
|
entriesWithForms.push(
|
|
2056
2058
|
...fe.filter(
|
|
2057
2059
|
(ent) => ent.forms && ent.forms.some(
|
|
2058
|
-
(form) =>
|
|
2060
|
+
(form) => {
|
|
2061
|
+
var _a2;
|
|
2062
|
+
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2063
|
+
}
|
|
2059
2064
|
)
|
|
2060
2065
|
)
|
|
2061
2066
|
);
|
|
@@ -2077,7 +2082,10 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2077
2082
|
entriesWithForms.push(
|
|
2078
2083
|
...fe.filter(
|
|
2079
2084
|
(ent) => ent.forms && ent.forms.some(
|
|
2080
|
-
(form) =>
|
|
2085
|
+
(form) => {
|
|
2086
|
+
var _a2;
|
|
2087
|
+
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2088
|
+
}
|
|
2081
2089
|
)
|
|
2082
2090
|
)
|
|
2083
2091
|
);
|
|
@@ -2089,16 +2097,22 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2089
2097
|
if (te)
|
|
2090
2098
|
entriesWithTitles.push(
|
|
2091
2099
|
...te.filter(
|
|
2092
|
-
(ent) => ent.forms &&
|
|
2093
|
-
(form) =>
|
|
2094
|
-
|
|
2100
|
+
(ent) => ent.forms && ent.forms.some(
|
|
2101
|
+
(form) => {
|
|
2102
|
+
var _a2;
|
|
2103
|
+
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2104
|
+
}
|
|
2105
|
+
)
|
|
2095
2106
|
)
|
|
2096
2107
|
);
|
|
2097
2108
|
if (fe)
|
|
2098
2109
|
entriesWithForms.push(
|
|
2099
2110
|
...fe.filter(
|
|
2100
2111
|
(ent) => ent.forms && ent.forms.some(
|
|
2101
|
-
(form) =>
|
|
2112
|
+
(form) => {
|
|
2113
|
+
var _a2;
|
|
2114
|
+
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2115
|
+
}
|
|
2102
2116
|
)
|
|
2103
2117
|
)
|
|
2104
2118
|
);
|
|
@@ -2123,19 +2137,19 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2123
2137
|
const readingEntries = [];
|
|
2124
2138
|
const titleFormMap = /* @__PURE__ */ new Map();
|
|
2125
2139
|
const refsMap = /* @__PURE__ */ new Map();
|
|
2126
|
-
const
|
|
2140
|
+
const forms = /* @__PURE__ */ new Set();
|
|
2127
2141
|
for (const ent of pair.entriesWithTitles) {
|
|
2128
2142
|
const validFormOf = validFormOfEntries.has(ent.word);
|
|
2129
2143
|
const validGlosses = validGlossesEntries.has(ent.word);
|
|
2130
2144
|
const validForms2 = validFormsEntries.has(ent.word);
|
|
2131
|
-
const
|
|
2145
|
+
const hasForms = ent.forms !== void 0 && ent.forms.some((form) => pair.forms.has(form));
|
|
2132
2146
|
if (pair.kanjiForms && pair.kanjiForms.has(ent.word) && (validFormOf || validGlosses || validForms2)) {
|
|
2133
2147
|
kanjiFormEntries.push(ent);
|
|
2134
2148
|
if ((validFormOf || validGlosses) && ent.senses)
|
|
2135
2149
|
for (const sense of ent.senses) {
|
|
2136
2150
|
if (validFormOf && sense.form_of) {
|
|
2137
2151
|
for (const form of sense.form_of)
|
|
2138
|
-
if (pair.
|
|
2152
|
+
if (pair.forms.has(form)) {
|
|
2139
2153
|
const elem = titleFormMap.get(form);
|
|
2140
2154
|
if (!elem)
|
|
2141
2155
|
titleFormMap.set(form, /* @__PURE__ */ new Set([ent.word]));
|
|
@@ -2156,11 +2170,10 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2156
2170
|
}
|
|
2157
2171
|
if (validForms2 && ent.forms) {
|
|
2158
2172
|
for (const form of ent.forms)
|
|
2159
|
-
if (pair.
|
|
2173
|
+
if (pair.forms.has(form)) forms.add(form);
|
|
2160
2174
|
}
|
|
2161
2175
|
}
|
|
2162
|
-
if (pair.readings.has(ent.word) &&
|
|
2163
|
-
entriesWithForms.push(ent);
|
|
2176
|
+
if (pair.readings.has(ent.word) && hasForms) entriesWithForms.push(ent);
|
|
2164
2177
|
if (pair.kanjiForms === void 0 && pair.readings.has(ent.word))
|
|
2165
2178
|
readingEntries.push(ent);
|
|
2166
2179
|
}
|
|
@@ -2170,7 +2183,7 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2170
2183
|
entriesWithForms.push(entry);
|
|
2171
2184
|
}
|
|
2172
2185
|
for (const entry of pair.entriesWithFormTitles) {
|
|
2173
|
-
if (
|
|
2186
|
+
if (forms.has(entry.word)) {
|
|
2174
2187
|
entriesWithForms.push(entry);
|
|
2175
2188
|
continue;
|
|
2176
2189
|
}
|
|
@@ -2191,7 +2204,8 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2191
2204
|
if (definitions.length > 0)
|
|
2192
2205
|
japaneseDefinitions.push({
|
|
2193
2206
|
wordID: pair.word.id,
|
|
2194
|
-
definitions
|
|
2207
|
+
definitions,
|
|
2208
|
+
wordForms: pair.forms
|
|
2195
2209
|
});
|
|
2196
2210
|
}
|
|
2197
2211
|
for (let i = 0; i < japaneseDefinitions.length; i++) {
|
|
@@ -2200,9 +2214,17 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2200
2214
|
const defCount = definitionMap.get(
|
|
2201
2215
|
pair.definitions[j].definition
|
|
2202
2216
|
);
|
|
2203
|
-
if (defCount && defCount.count > 1)
|
|
2204
|
-
|
|
2217
|
+
if (defCount && defCount.count > 1) {
|
|
2218
|
+
let mnba = true;
|
|
2219
|
+
for (const f of pair.wordForms)
|
|
2220
|
+
if (pair.definitions[j].definition.includes(f)) {
|
|
2221
|
+
mnba = false;
|
|
2222
|
+
break;
|
|
2223
|
+
}
|
|
2224
|
+
if (mnba) pair.definitions[j].mayNotBeAccurate = true;
|
|
2225
|
+
}
|
|
2205
2226
|
}
|
|
2227
|
+
delete pair.wordForms;
|
|
2206
2228
|
japaneseDefinitions[i] = pair;
|
|
2207
2229
|
}
|
|
2208
2230
|
return japaneseDefinitions;
|
|
@@ -2443,6 +2465,9 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2443
2465
|
let wordExamples = [
|
|
2444
2466
|
...includeKanjiFormExamples ? [...readingMatchingKanjiFormExamples, ...kanjiFormExamples] : readingExamples
|
|
2445
2467
|
];
|
|
2468
|
+
wordExamples.sort(
|
|
2469
|
+
(a, b) => a.ex.phrase.length - b.ex.phrase.length
|
|
2470
|
+
);
|
|
2446
2471
|
readingMatchingKanjiForms.clear();
|
|
2447
2472
|
const glossSpecificExamples = [];
|
|
2448
2473
|
const seenPhrases = /* @__PURE__ */ new Set();
|
|
@@ -2464,18 +2489,17 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2464
2489
|
}
|
|
2465
2490
|
}
|
|
2466
2491
|
if (glossSpecificExamples.length > 0) {
|
|
2467
|
-
|
|
2468
|
-
if (exes.length < 5) {
|
|
2492
|
+
if (glossSpecificExamples.length < 5) {
|
|
2469
2493
|
wordExamples = wordExamples.filter(
|
|
2470
2494
|
(ex) => !seenPhrases.has(ex.ex.phrase)
|
|
2471
2495
|
);
|
|
2472
2496
|
if (wordExamples.length > 0)
|
|
2473
2497
|
for (const ex of wordExamples) {
|
|
2474
|
-
|
|
2475
|
-
if (
|
|
2498
|
+
glossSpecificExamples.push(ex);
|
|
2499
|
+
if (glossSpecificExamples.length === 5) break;
|
|
2476
2500
|
}
|
|
2477
2501
|
}
|
|
2478
|
-
wordExamples =
|
|
2502
|
+
wordExamples = glossSpecificExamples;
|
|
2479
2503
|
}
|
|
2480
2504
|
if (wordExamples.length > 0) {
|
|
2481
2505
|
word2.phrases = (glossSpecificExamples.length === 0 ? wordExamples.slice(0, 5) : wordExamples).map((ex) => {
|
|
@@ -2494,7 +2518,12 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2494
2518
|
}
|
|
2495
2519
|
if (definitions) {
|
|
2496
2520
|
const defs = Array.isArray(definitions) ? (_b = definitions.find((wdp) => wdp.wordID === word2.id)) == null ? void 0 : _b.definitions : definitions.get(word2.id);
|
|
2497
|
-
if (defs)
|
|
2521
|
+
if (defs)
|
|
2522
|
+
word2.definitions = [
|
|
2523
|
+
...defs.toSorted(
|
|
2524
|
+
(a, b) => Number(Boolean(a.mayNotBeAccurate)) - Number(Boolean(b.mayNotBeAccurate))
|
|
2525
|
+
)
|
|
2526
|
+
];
|
|
2498
2527
|
}
|
|
2499
2528
|
return word2;
|
|
2500
2529
|
} else return void 0;
|
|
@@ -2670,8 +2699,8 @@ function isGrammar(entry) {
|
|
|
2670
2699
|
}
|
|
2671
2700
|
var createNotes = (notes, phrase) => `${phrase === true ? "<details><summary>Show translation</summary>" : ""}<ul class="note-list">${notes.map((note) => `<li class="note">${note}</li>`).join("")}</ul>${phrase === true ? "</details>" : ""}`;
|
|
2672
2701
|
var createEntry = (entry, notes, phrase, glossSpecific) => `<div class="entry${glossSpecific ? " gloss-specific" : ""}">${entry}${notes && notes.length > 0 ? createNotes(notes, phrase) : ""}</div>`;
|
|
2673
|
-
var noKanjiForms = '<span class="word word-kanjiform">(no kanji forms)</span>';
|
|
2674
2702
|
function generateAnkiNote(entry) {
|
|
2703
|
+
var _a, _b;
|
|
2675
2704
|
const fields = [];
|
|
2676
2705
|
if (isWord(entry)) {
|
|
2677
2706
|
const firstReading = createEntry(
|
|
@@ -2683,10 +2712,8 @@ function generateAnkiNote(entry) {
|
|
|
2683
2712
|
`<span class="word word-reading">${readingEntry.reading}${readingEntry.audio !== void 0 ? `<br>[sound:${readingEntry.audio}]` : ""}</span>`,
|
|
2684
2713
|
readingEntry.notes
|
|
2685
2714
|
)
|
|
2686
|
-
).join("")}</details>` :
|
|
2687
|
-
const readingsField =
|
|
2688
|
-
""
|
|
2689
|
-
);
|
|
2715
|
+
).join("")}</details>` : "";
|
|
2716
|
+
const readingsField = `${firstReading}${otherReadings}`;
|
|
2690
2717
|
const firstKanjiForm = entry.kanjiForms ? createEntry(
|
|
2691
2718
|
`<span class="word word-kanjiform"><ruby><rb>${entry.kanjiForms[0].kanjiForm}</rb><rt>${entry.readings[0].reading}</rt></ruby></span>`,
|
|
2692
2719
|
entry.kanjiForms[0].notes
|
|
@@ -2698,42 +2725,78 @@ function generateAnkiNote(entry) {
|
|
|
2698
2725
|
)
|
|
2699
2726
|
);
|
|
2700
2727
|
return `${createEntry(`<span class="word word-kanjiform">${restrictedReading ? "<ruby><rb>" : ""}${kanjiFormEntry.kanjiForm}${restrictedReading ? `</rb><rt>${restrictedReading.reading}</rt></ruby>` : ""}</span>`, kanjiFormEntry.notes)}`;
|
|
2701
|
-
}).join("")}</details>` :
|
|
2702
|
-
const kanjiFormsField = firstKanjiForm ?
|
|
2728
|
+
}).join("")}</details>` : "";
|
|
2729
|
+
const kanjiFormsField = firstKanjiForm ? `${firstKanjiForm}${otherKanjiForms}` : '<span class="word word-kanjiform">(no kanji forms)</span>';
|
|
2703
2730
|
const firstThreeTranslations = entry.translations.slice(0, 3).map(
|
|
2704
|
-
(translationEntry, index) =>
|
|
2731
|
+
(translationEntry, index) => {
|
|
2732
|
+
var _a2;
|
|
2733
|
+
return createEntry(
|
|
2734
|
+
`<span class="word word-translation">${translationEntry.translation}</span>`,
|
|
2735
|
+
translationEntry.notes,
|
|
2736
|
+
void 0,
|
|
2737
|
+
((_a2 = entry.phrases) == null ? void 0 : _a2.some(
|
|
2738
|
+
(phrase, index2) => index === index2 && phrase.glossNumber && phrase.glossNumber.wordId === entry.id && phrase.glossNumber.glossNumber === index + 1
|
|
2739
|
+
)) ? true : void 0
|
|
2740
|
+
);
|
|
2741
|
+
}
|
|
2742
|
+
).join("");
|
|
2743
|
+
const otherTranslations = entry.translations.length > 3 ? `<details><summary>Show other translations</summary>${entry.translations.map((translationEntry, index) => {
|
|
2744
|
+
var _a2;
|
|
2745
|
+
if (index < 3) return "null";
|
|
2746
|
+
return createEntry(
|
|
2747
|
+
`<span class="word word-translation">${translationEntry.translation}</span>`,
|
|
2748
|
+
translationEntry.notes,
|
|
2749
|
+
void 0,
|
|
2750
|
+
((_a2 = entry.phrases) == null ? void 0 : _a2.some(
|
|
2751
|
+
(phrase, index2) => index === index2 && phrase.glossNumber && phrase.glossNumber.wordId === entry.id && phrase.glossNumber.glossNumber === index + 1
|
|
2752
|
+
)) ? true : void 0
|
|
2753
|
+
);
|
|
2754
|
+
}).filter((translation) => translation !== "null").join("")}</details>` : "";
|
|
2755
|
+
const translationsField = `${firstThreeTranslations}${otherTranslations}`;
|
|
2756
|
+
const firstFivePhrases = (_a = entry.phrases) == null ? void 0 : _a.slice(0, 5).map(
|
|
2757
|
+
(phraseEntry, index) => createEntry(
|
|
2758
|
+
`<span class="word word-phrase"><span class="word word-phrase-original">${phraseEntry.originalPhrase}</span><span class="word word-phrase-furigana">${phraseEntry.phrase}</span></span>`,
|
|
2759
|
+
[phraseEntry.translation],
|
|
2760
|
+
true,
|
|
2761
|
+
entry.translations.some(
|
|
2762
|
+
(_translation, index2) => index === index2 && phraseEntry.glossNumber && phraseEntry.glossNumber.wordId === entry.id && phraseEntry.glossNumber.glossNumber === index2 + 1
|
|
2763
|
+
) ? true : void 0
|
|
2764
|
+
)
|
|
2765
|
+
).join("");
|
|
2766
|
+
const otherPhrases = entry.phrases !== void 0 && entry.phrases.length > 5 ? `<details><summary>Show other phrases</summary>${entry.phrases.map((phraseEntry, index) => {
|
|
2767
|
+
if (index < 5) return "null";
|
|
2768
|
+
return createEntry(
|
|
2769
|
+
`<span class="word word-phrase"><span class="word word-phrase-original">${phraseEntry.originalPhrase}</span><span class="word word-phrase-furigana">${phraseEntry.phrase}</span></span>`,
|
|
2770
|
+
[phraseEntry.translation],
|
|
2771
|
+
true,
|
|
2772
|
+
entry.translations.some(
|
|
2773
|
+
(_translation, index2) => index === index2 && phraseEntry.glossNumber && phraseEntry.glossNumber.wordId === entry.id && phraseEntry.glossNumber.glossNumber === index2 + 1
|
|
2774
|
+
) ? true : void 0
|
|
2775
|
+
);
|
|
2776
|
+
}).filter((phrase) => phrase !== "null").join("")}</details>` : "";
|
|
2777
|
+
const phrasesField = firstFivePhrases ? `${firstFivePhrases}${otherPhrases}` : '<span class="word word-phrase">(no phrases) (Search on dictionaries!)</span>';
|
|
2778
|
+
const firstThreeDefinitions = (_b = entry.definitions) == null ? void 0 : _b.slice(0, 3).map(
|
|
2779
|
+
(definitionEntry) => {
|
|
2780
|
+
var _a2;
|
|
2781
|
+
return createEntry(
|
|
2782
|
+
`<span class="word word-definition${definitionEntry.mayNotBeAccurate === true ? " mnba" : ""}"><span class="word word-definition-original">${definitionEntry.definition}</span><span class="word word-definition-furigana">${(_a2 = definitionEntry.furigana) != null ? _a2 : definitionEntry.definition}</span></span>`
|
|
2783
|
+
);
|
|
2784
|
+
}
|
|
2705
2785
|
).join("");
|
|
2706
|
-
const
|
|
2707
|
-
(
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2786
|
+
const otherDefinitions = entry.definitions !== void 0 && entry.definitions.length > 3 ? `<details><summary>Show other definitions</summary>${entry.definitions.map(
|
|
2787
|
+
(definitionEntry, index) => {
|
|
2788
|
+
var _a2;
|
|
2789
|
+
return index > 2 ? `${createEntry(
|
|
2790
|
+
`<span class="word word-definition${definitionEntry.mayNotBeAccurate === true ? " mnba" : ""}"><span class="word word-definition-original">${definitionEntry.definition}</span><span class="word word-definition-furigana">${(_a2 = definitionEntry.furigana) != null ? _a2 : definitionEntry.definition}</span></span>`
|
|
2791
|
+
)}` : "null";
|
|
2792
|
+
}
|
|
2793
|
+
).filter((definition) => definition !== "null").join("")}</details>` : "";
|
|
2794
|
+
const definitionsField = firstThreeDefinitions ? `${firstThreeDefinitions}${otherDefinitions}` : '<span class="word word-definition">(no definitions)</span>';
|
|
2713
2795
|
fields.push(
|
|
2714
|
-
...entry.kanjiForms &&
|
|
2715
|
-
readingsField,
|
|
2716
|
-
entry.kanjiForms && kanjiFormsField ? kanjiFormsField : noKanjiForms
|
|
2717
|
-
],
|
|
2796
|
+
...entry.kanjiForms && !entry.usuallyInKana ? [kanjiFormsField, readingsField] : [readingsField, kanjiFormsField],
|
|
2718
2797
|
translationsField,
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
`<span class="word word-phrase"><span class="word word-phrase-original">${phraseEntry.originalPhrase}</span><span class="word word-phrase-furigana">${phraseEntry.phrase}</span></span>`,
|
|
2722
|
-
[phraseEntry.translation],
|
|
2723
|
-
true,
|
|
2724
|
-
entry.translations.some(
|
|
2725
|
-
(_translation, index2) => index === index2 && phraseEntry.glossNumber && phraseEntry.glossNumber.wordId === entry.id && phraseEntry.glossNumber.glossNumber === index2 + 1
|
|
2726
|
-
) ? true : void 0
|
|
2727
|
-
)
|
|
2728
|
-
).join("") : '<span class="word word-phrase">(no phrases) (Search on dictionaries!)</span>',
|
|
2729
|
-
entry.definitions ? entry.definitions.map(
|
|
2730
|
-
(definitionEntry) => {
|
|
2731
|
-
var _a;
|
|
2732
|
-
return createEntry(
|
|
2733
|
-
`<span class="word word-definition${definitionEntry.mayNotBeAccurate === true ? " mnba" : ""}"><span class="word word-definition-original">${definitionEntry.definition}</span><span class="word word-definition-furigana">${(_a = definitionEntry.furigana) != null ? _a : definitionEntry.definition}</span></span>`
|
|
2734
|
-
);
|
|
2735
|
-
}
|
|
2736
|
-
).join("") : '<span class="word word-definition">(no definitions)</span>',
|
|
2798
|
+
phrasesField,
|
|
2799
|
+
definitionsField,
|
|
2737
2800
|
entry.kanji ? entry.kanji.map(
|
|
2738
2801
|
(kanjiEntry) => createEntry(
|
|
2739
2802
|
`<span class="word word-kanji">${kanjiEntry.kanji}${kanjiEntry.meanings === void 0 ? " (no meanings)" : ""}</span>`,
|
|
@@ -2790,7 +2853,7 @@ function generateAnkiNote(entry) {
|
|
|
2790
2853
|
(onyomiEntry) => createEntry(
|
|
2791
2854
|
`<span class="kanji kanji-onyomi">${onyomiEntry}</span>`
|
|
2792
2855
|
)
|
|
2793
|
-
).join("") : `<span class="kanji kanji-onyomi">(no onyomi) ${entry.kokuji === true ? "(kokuji)" : ""}</span
|
|
2856
|
+
).join("") : `<span class="kanji kanji-onyomi">(no onyomi) ${entry.kokuji === true ? "(kokuji)" : ""}</span>`,
|
|
2794
2857
|
entry.kunyomi ? entry.kunyomi.map(
|
|
2795
2858
|
(kunyomiEntry) => createEntry(
|
|
2796
2859
|
`<span class="kanji kanji-kunyomi">${kunyomiEntry}</span>`
|