henkan 2.2.3 → 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 +150 -85
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.mjs +144 -82
- 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/convertJMdict.md +1 -1
- package/docs/api/functions/convertJawiktionaryAsync.md +1 -1
- package/docs/api/functions/convertJawiktionarySync.md +1 -1
- package/docs/api/functions/convertKanjiDic.md +1 -1
- package/docs/api/functions/convertKradFile.md +1 -1
- package/docs/api/functions/convertRadkFile.md +1 -1
- package/docs/api/functions/convertTanakaCorpus.md +1 -1
- package/docs/api/functions/convertTanakaCorpusWithFurigana.md +1 -1
- package/docs/api/functions/createEntryMaps.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
|
@@ -1273,7 +1273,8 @@ function shuffleArray(arr) {
|
|
|
1273
1273
|
function getValidForms(readings, kanjiForms, wordIsCommon) {
|
|
1274
1274
|
const kanjiFormRestrictions = /* @__PURE__ */ new Set();
|
|
1275
1275
|
const validReadings = readings.filter(
|
|
1276
|
-
(reading) => {
|
|
1276
|
+
(reading, index) => {
|
|
1277
|
+
if (index === 0) return true;
|
|
1277
1278
|
if (reading.notes === void 0 || !reading.notes.some((note) => notSearchedForms.has(note))) {
|
|
1278
1279
|
if (reading.kanjiFormRestrictions) {
|
|
1279
1280
|
for (const kfr of reading.kanjiFormRestrictions)
|
|
@@ -1286,10 +1287,11 @@ function getValidForms(readings, kanjiForms, wordIsCommon) {
|
|
|
1286
1287
|
return false;
|
|
1287
1288
|
}
|
|
1288
1289
|
);
|
|
1289
|
-
const existValidKf = kanjiForms ? kanjiForms.some(
|
|
1290
|
-
(kf) => (kf.notes === void 0 || !kf.notes.some((note) => notSearchedForms.has(note))) && (wordIsCommon === void 0 || kf.commonness !== void 0) || kanjiFormRestrictions.has(kf.form)
|
|
1290
|
+
const existValidKf = kanjiForms !== void 0 ? kanjiForms.some(
|
|
1291
|
+
(kf, index) => index !== 0 && ((kf.notes === void 0 || !kf.notes.some((note) => notSearchedForms.has(note))) && (wordIsCommon === void 0 || kf.commonness !== void 0) || kanjiFormRestrictions.has(kf.form))
|
|
1291
1292
|
) : void 0;
|
|
1292
|
-
const validKanjiForms = kanjiForms ? kanjiForms.filter((kanjiForm) => {
|
|
1293
|
+
const validKanjiForms = kanjiForms !== void 0 ? kanjiForms.filter((kanjiForm, index) => {
|
|
1294
|
+
if (index === 0) return true;
|
|
1293
1295
|
if (existValidKf === true)
|
|
1294
1296
|
return (kanjiForm.notes === void 0 || !kanjiForm.notes.some(
|
|
1295
1297
|
(note) => notSearchedForms.has(note)
|
|
@@ -1676,11 +1678,10 @@ function createEntryMaps(jmDict, kanjiDic, tanakaExamples, wordDefinitionPairs,
|
|
|
1676
1678
|
word.isCommon
|
|
1677
1679
|
);
|
|
1678
1680
|
const localPartParts = /* @__PURE__ */ new Set();
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
}
|
|
1681
|
+
for (const reading of rkf.readings) {
|
|
1682
|
+
entryParts.add(reading.reading);
|
|
1683
|
+
localPartParts.add(reading.reading);
|
|
1684
|
+
}
|
|
1684
1685
|
if (rkf.kanjiForms && rkf.kanjiForms.length > 0)
|
|
1685
1686
|
for (const kanjiForm of rkf.kanjiForms) {
|
|
1686
1687
|
entryParts.add(kanjiForm.form);
|
|
@@ -1844,12 +1845,11 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1844
1845
|
word.kanjiForms,
|
|
1845
1846
|
word.isCommon
|
|
1846
1847
|
);
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
}
|
|
1848
|
+
for (const r of rkf.readings) {
|
|
1849
|
+
validReadings.add(r.reading);
|
|
1850
|
+
wordReadings.add(r.reading);
|
|
1851
|
+
validForms.add(r.reading);
|
|
1852
|
+
}
|
|
1853
1853
|
if (rkf.kanjiForms && rkf.kanjiForms.length > 0)
|
|
1854
1854
|
for (const kf of rkf.kanjiForms) {
|
|
1855
1855
|
validKanjiForms.add(kf.form);
|
|
@@ -1873,7 +1873,7 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1873
1873
|
if (validKanjiForms && validKanjiForms.has(entry.word)) {
|
|
1874
1874
|
valid = true;
|
|
1875
1875
|
for (const sense of entry.senses) {
|
|
1876
|
-
if (sense.form_of && sense.form_of.some((form) =>
|
|
1876
|
+
if (sense.form_of && sense.form_of.some((form) => validForms.has(form)))
|
|
1877
1877
|
validFormOfEntries.add(entry.word);
|
|
1878
1878
|
for (const gloss of sense.glosses) {
|
|
1879
1879
|
let hasForm = false;
|
|
@@ -1889,10 +1889,10 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1889
1889
|
}
|
|
1890
1890
|
if (entry.forms) {
|
|
1891
1891
|
for (const form of entry.forms)
|
|
1892
|
-
if (
|
|
1892
|
+
if (validForms.has(form)) validFormsEntries.add(entry.word);
|
|
1893
1893
|
}
|
|
1894
1894
|
}
|
|
1895
|
-
if (
|
|
1895
|
+
if (validForms.has(entry.word)) {
|
|
1896
1896
|
valid = true;
|
|
1897
1897
|
const ftEntry = entriesWithFormTitlesGlobal.get(entry.word);
|
|
1898
1898
|
if (ftEntry) ftEntry.push(entry);
|
|
@@ -1903,9 +1903,7 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1903
1903
|
if (tEntry) tEntry.push(entry);
|
|
1904
1904
|
else validTitleEntries.set(entry.word, [entry]);
|
|
1905
1905
|
}
|
|
1906
|
-
if (entry.forms &&
|
|
1907
|
-
(form) => validKanjiForms.has(form) || validReadings.has(form)
|
|
1908
|
-
)) {
|
|
1906
|
+
if (entry.forms && validForms.has(entry.word) && entry.forms.some((form) => validForms.has(form))) {
|
|
1909
1907
|
const wfEntry = entriesWithFormsGlobal.get(entry.word);
|
|
1910
1908
|
if (wfEntry) wfEntry.push(entry);
|
|
1911
1909
|
else entriesWithFormsGlobal.set(entry.word, [entry]);
|
|
@@ -2032,7 +2030,10 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2032
2030
|
entriesWithForms.push(
|
|
2033
2031
|
...fe.filter(
|
|
2034
2032
|
(ent) => ent.forms && ent.forms.some(
|
|
2035
|
-
(form) =>
|
|
2033
|
+
(form) => {
|
|
2034
|
+
var _a2;
|
|
2035
|
+
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2036
|
+
}
|
|
2036
2037
|
)
|
|
2037
2038
|
)
|
|
2038
2039
|
);
|
|
@@ -2044,16 +2045,22 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2044
2045
|
if (te)
|
|
2045
2046
|
entriesWithTitles.push(
|
|
2046
2047
|
...te.filter(
|
|
2047
|
-
(ent) => ent.forms &&
|
|
2048
|
-
(form) =>
|
|
2049
|
-
|
|
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
|
+
)
|
|
2050
2054
|
)
|
|
2051
2055
|
);
|
|
2052
2056
|
if (fe)
|
|
2053
2057
|
entriesWithForms.push(
|
|
2054
2058
|
...fe.filter(
|
|
2055
2059
|
(ent) => ent.forms && ent.forms.some(
|
|
2056
|
-
(form) =>
|
|
2060
|
+
(form) => {
|
|
2061
|
+
var _a2;
|
|
2062
|
+
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2063
|
+
}
|
|
2057
2064
|
)
|
|
2058
2065
|
)
|
|
2059
2066
|
);
|
|
@@ -2075,7 +2082,10 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2075
2082
|
entriesWithForms.push(
|
|
2076
2083
|
...fe.filter(
|
|
2077
2084
|
(ent) => ent.forms && ent.forms.some(
|
|
2078
|
-
(form) =>
|
|
2085
|
+
(form) => {
|
|
2086
|
+
var _a2;
|
|
2087
|
+
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2088
|
+
}
|
|
2079
2089
|
)
|
|
2080
2090
|
)
|
|
2081
2091
|
);
|
|
@@ -2087,16 +2097,22 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2087
2097
|
if (te)
|
|
2088
2098
|
entriesWithTitles.push(
|
|
2089
2099
|
...te.filter(
|
|
2090
|
-
(ent) => ent.forms &&
|
|
2091
|
-
(form) =>
|
|
2092
|
-
|
|
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
|
+
)
|
|
2093
2106
|
)
|
|
2094
2107
|
);
|
|
2095
2108
|
if (fe)
|
|
2096
2109
|
entriesWithForms.push(
|
|
2097
2110
|
...fe.filter(
|
|
2098
2111
|
(ent) => ent.forms && ent.forms.some(
|
|
2099
|
-
(form) =>
|
|
2112
|
+
(form) => {
|
|
2113
|
+
var _a2;
|
|
2114
|
+
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2115
|
+
}
|
|
2100
2116
|
)
|
|
2101
2117
|
)
|
|
2102
2118
|
);
|
|
@@ -2121,19 +2137,19 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2121
2137
|
const readingEntries = [];
|
|
2122
2138
|
const titleFormMap = /* @__PURE__ */ new Map();
|
|
2123
2139
|
const refsMap = /* @__PURE__ */ new Map();
|
|
2124
|
-
const
|
|
2140
|
+
const forms = /* @__PURE__ */ new Set();
|
|
2125
2141
|
for (const ent of pair.entriesWithTitles) {
|
|
2126
2142
|
const validFormOf = validFormOfEntries.has(ent.word);
|
|
2127
2143
|
const validGlosses = validGlossesEntries.has(ent.word);
|
|
2128
2144
|
const validForms2 = validFormsEntries.has(ent.word);
|
|
2129
|
-
const
|
|
2145
|
+
const hasForms = ent.forms !== void 0 && ent.forms.some((form) => pair.forms.has(form));
|
|
2130
2146
|
if (pair.kanjiForms && pair.kanjiForms.has(ent.word) && (validFormOf || validGlosses || validForms2)) {
|
|
2131
2147
|
kanjiFormEntries.push(ent);
|
|
2132
2148
|
if ((validFormOf || validGlosses) && ent.senses)
|
|
2133
2149
|
for (const sense of ent.senses) {
|
|
2134
2150
|
if (validFormOf && sense.form_of) {
|
|
2135
2151
|
for (const form of sense.form_of)
|
|
2136
|
-
if (pair.
|
|
2152
|
+
if (pair.forms.has(form)) {
|
|
2137
2153
|
const elem = titleFormMap.get(form);
|
|
2138
2154
|
if (!elem)
|
|
2139
2155
|
titleFormMap.set(form, /* @__PURE__ */ new Set([ent.word]));
|
|
@@ -2154,11 +2170,10 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2154
2170
|
}
|
|
2155
2171
|
if (validForms2 && ent.forms) {
|
|
2156
2172
|
for (const form of ent.forms)
|
|
2157
|
-
if (pair.
|
|
2173
|
+
if (pair.forms.has(form)) forms.add(form);
|
|
2158
2174
|
}
|
|
2159
2175
|
}
|
|
2160
|
-
if (pair.readings.has(ent.word) &&
|
|
2161
|
-
entriesWithForms.push(ent);
|
|
2176
|
+
if (pair.readings.has(ent.word) && hasForms) entriesWithForms.push(ent);
|
|
2162
2177
|
if (pair.kanjiForms === void 0 && pair.readings.has(ent.word))
|
|
2163
2178
|
readingEntries.push(ent);
|
|
2164
2179
|
}
|
|
@@ -2168,7 +2183,7 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2168
2183
|
entriesWithForms.push(entry);
|
|
2169
2184
|
}
|
|
2170
2185
|
for (const entry of pair.entriesWithFormTitles) {
|
|
2171
|
-
if (
|
|
2186
|
+
if (forms.has(entry.word)) {
|
|
2172
2187
|
entriesWithForms.push(entry);
|
|
2173
2188
|
continue;
|
|
2174
2189
|
}
|
|
@@ -2189,7 +2204,8 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2189
2204
|
if (definitions.length > 0)
|
|
2190
2205
|
japaneseDefinitions.push({
|
|
2191
2206
|
wordID: pair.word.id,
|
|
2192
|
-
definitions
|
|
2207
|
+
definitions,
|
|
2208
|
+
wordForms: pair.forms
|
|
2193
2209
|
});
|
|
2194
2210
|
}
|
|
2195
2211
|
for (let i = 0; i < japaneseDefinitions.length; i++) {
|
|
@@ -2198,9 +2214,17 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2198
2214
|
const defCount = definitionMap.get(
|
|
2199
2215
|
pair.definitions[j].definition
|
|
2200
2216
|
);
|
|
2201
|
-
if (defCount && defCount.count > 1)
|
|
2202
|
-
|
|
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
|
+
}
|
|
2203
2226
|
}
|
|
2227
|
+
delete pair.wordForms;
|
|
2204
2228
|
japaneseDefinitions[i] = pair;
|
|
2205
2229
|
}
|
|
2206
2230
|
return japaneseDefinitions;
|
|
@@ -2441,6 +2465,9 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2441
2465
|
let wordExamples = [
|
|
2442
2466
|
...includeKanjiFormExamples ? [...readingMatchingKanjiFormExamples, ...kanjiFormExamples] : readingExamples
|
|
2443
2467
|
];
|
|
2468
|
+
wordExamples.sort(
|
|
2469
|
+
(a, b) => a.ex.phrase.length - b.ex.phrase.length
|
|
2470
|
+
);
|
|
2444
2471
|
readingMatchingKanjiForms.clear();
|
|
2445
2472
|
const glossSpecificExamples = [];
|
|
2446
2473
|
const seenPhrases = /* @__PURE__ */ new Set();
|
|
@@ -2462,18 +2489,17 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2462
2489
|
}
|
|
2463
2490
|
}
|
|
2464
2491
|
if (glossSpecificExamples.length > 0) {
|
|
2465
|
-
|
|
2466
|
-
if (exes.length < 5) {
|
|
2492
|
+
if (glossSpecificExamples.length < 5) {
|
|
2467
2493
|
wordExamples = wordExamples.filter(
|
|
2468
2494
|
(ex) => !seenPhrases.has(ex.ex.phrase)
|
|
2469
2495
|
);
|
|
2470
2496
|
if (wordExamples.length > 0)
|
|
2471
2497
|
for (const ex of wordExamples) {
|
|
2472
|
-
|
|
2473
|
-
if (
|
|
2498
|
+
glossSpecificExamples.push(ex);
|
|
2499
|
+
if (glossSpecificExamples.length === 5) break;
|
|
2474
2500
|
}
|
|
2475
2501
|
}
|
|
2476
|
-
wordExamples =
|
|
2502
|
+
wordExamples = glossSpecificExamples;
|
|
2477
2503
|
}
|
|
2478
2504
|
if (wordExamples.length > 0) {
|
|
2479
2505
|
word2.phrases = (glossSpecificExamples.length === 0 ? wordExamples.slice(0, 5) : wordExamples).map((ex) => {
|
|
@@ -2492,7 +2518,12 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2492
2518
|
}
|
|
2493
2519
|
if (definitions) {
|
|
2494
2520
|
const defs = Array.isArray(definitions) ? (_b = definitions.find((wdp) => wdp.wordID === word2.id)) == null ? void 0 : _b.definitions : definitions.get(word2.id);
|
|
2495
|
-
if (defs)
|
|
2521
|
+
if (defs)
|
|
2522
|
+
word2.definitions = [
|
|
2523
|
+
...defs.toSorted(
|
|
2524
|
+
(a, b) => Number(Boolean(a.mayNotBeAccurate)) - Number(Boolean(b.mayNotBeAccurate))
|
|
2525
|
+
)
|
|
2526
|
+
];
|
|
2496
2527
|
}
|
|
2497
2528
|
return word2;
|
|
2498
2529
|
} else return void 0;
|
|
@@ -2668,8 +2699,8 @@ function isGrammar(entry) {
|
|
|
2668
2699
|
}
|
|
2669
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>" : ""}`;
|
|
2670
2701
|
var createEntry = (entry, notes, phrase, glossSpecific) => `<div class="entry${glossSpecific ? " gloss-specific" : ""}">${entry}${notes && notes.length > 0 ? createNotes(notes, phrase) : ""}</div>`;
|
|
2671
|
-
var noKanjiForms = '<span class="word word-kanjiform">(no kanji forms)</span>';
|
|
2672
2702
|
function generateAnkiNote(entry) {
|
|
2703
|
+
var _a, _b;
|
|
2673
2704
|
const fields = [];
|
|
2674
2705
|
if (isWord(entry)) {
|
|
2675
2706
|
const firstReading = createEntry(
|
|
@@ -2681,10 +2712,8 @@ function generateAnkiNote(entry) {
|
|
|
2681
2712
|
`<span class="word word-reading">${readingEntry.reading}${readingEntry.audio !== void 0 ? `<br>[sound:${readingEntry.audio}]` : ""}</span>`,
|
|
2682
2713
|
readingEntry.notes
|
|
2683
2714
|
)
|
|
2684
|
-
).join("")}</details>` :
|
|
2685
|
-
const readingsField =
|
|
2686
|
-
""
|
|
2687
|
-
);
|
|
2715
|
+
).join("")}</details>` : "";
|
|
2716
|
+
const readingsField = `${firstReading}${otherReadings}`;
|
|
2688
2717
|
const firstKanjiForm = entry.kanjiForms ? createEntry(
|
|
2689
2718
|
`<span class="word word-kanjiform"><ruby><rb>${entry.kanjiForms[0].kanjiForm}</rb><rt>${entry.readings[0].reading}</rt></ruby></span>`,
|
|
2690
2719
|
entry.kanjiForms[0].notes
|
|
@@ -2696,42 +2725,78 @@ function generateAnkiNote(entry) {
|
|
|
2696
2725
|
)
|
|
2697
2726
|
);
|
|
2698
2727
|
return `${createEntry(`<span class="word word-kanjiform">${restrictedReading ? "<ruby><rb>" : ""}${kanjiFormEntry.kanjiForm}${restrictedReading ? `</rb><rt>${restrictedReading.reading}</rt></ruby>` : ""}</span>`, kanjiFormEntry.notes)}`;
|
|
2699
|
-
}).join("")}</details>` :
|
|
2700
|
-
const kanjiFormsField = firstKanjiForm ?
|
|
2728
|
+
}).join("")}</details>` : "";
|
|
2729
|
+
const kanjiFormsField = firstKanjiForm ? `${firstKanjiForm}${otherKanjiForms}` : '<span class="word word-kanjiform">(no kanji forms)</span>';
|
|
2701
2730
|
const firstThreeTranslations = entry.translations.slice(0, 3).map(
|
|
2702
|
-
(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
|
+
}
|
|
2703
2785
|
).join("");
|
|
2704
|
-
const
|
|
2705
|
-
(
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
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>';
|
|
2711
2795
|
fields.push(
|
|
2712
|
-
...entry.kanjiForms &&
|
|
2713
|
-
readingsField,
|
|
2714
|
-
entry.kanjiForms && kanjiFormsField ? kanjiFormsField : noKanjiForms
|
|
2715
|
-
],
|
|
2796
|
+
...entry.kanjiForms && !entry.usuallyInKana ? [kanjiFormsField, readingsField] : [readingsField, kanjiFormsField],
|
|
2716
2797
|
translationsField,
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
`<span class="word word-phrase"><span class="word word-phrase-original">${phraseEntry.originalPhrase}</span><span class="word word-phrase-furigana">${phraseEntry.phrase}</span></span>`,
|
|
2720
|
-
[phraseEntry.translation],
|
|
2721
|
-
true,
|
|
2722
|
-
entry.translations.some(
|
|
2723
|
-
(_translation, index2) => index === index2 && phraseEntry.glossNumber && phraseEntry.glossNumber.wordId === entry.id && phraseEntry.glossNumber.glossNumber === index2 + 1
|
|
2724
|
-
) ? true : void 0
|
|
2725
|
-
)
|
|
2726
|
-
).join("") : '<span class="word word-phrase">(no phrases) (Search on dictionaries!)</span>',
|
|
2727
|
-
entry.definitions ? entry.definitions.map(
|
|
2728
|
-
(definitionEntry) => {
|
|
2729
|
-
var _a;
|
|
2730
|
-
return createEntry(
|
|
2731
|
-
`<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>`
|
|
2732
|
-
);
|
|
2733
|
-
}
|
|
2734
|
-
).join("") : '<span class="word word-definition">(no definitions)</span>',
|
|
2798
|
+
phrasesField,
|
|
2799
|
+
definitionsField,
|
|
2735
2800
|
entry.kanji ? entry.kanji.map(
|
|
2736
2801
|
(kanjiEntry) => createEntry(
|
|
2737
2802
|
`<span class="word word-kanji">${kanjiEntry.kanji}${kanjiEntry.meanings === void 0 ? " (no meanings)" : ""}</span>`,
|
|
@@ -2788,7 +2853,7 @@ function generateAnkiNote(entry) {
|
|
|
2788
2853
|
(onyomiEntry) => createEntry(
|
|
2789
2854
|
`<span class="kanji kanji-onyomi">${onyomiEntry}</span>`
|
|
2790
2855
|
)
|
|
2791
|
-
).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>`,
|
|
2792
2857
|
entry.kunyomi ? entry.kunyomi.map(
|
|
2793
2858
|
(kunyomiEntry) => createEntry(
|
|
2794
2859
|
`<span class="kanji kanji-kunyomi">${kunyomiEntry}</span>`
|