henkan 2.2.5 → 2.3.0
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 +587 -571
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.mjs +581 -571
- package/dist/index.mjs.map +3 -3
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/types.d.ts +16 -12
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +34 -22
- package/dist/types/utils.d.ts.map +1 -1
- package/docs/api/README.md +2 -0
- 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 +4 -4
- package/docs/api/functions/getKanjiExtended.md +1 -1
- package/docs/api/functions/getValidForms.md +1 -1
- package/docs/api/functions/getWord.md +4 -4
- package/docs/api/functions/getWordDefinitions.md +4 -4
- package/docs/api/functions/getWordDefinitionsWithFurigana.md +1 -1
- package/docs/api/functions/hiraganaToKatakana.md +27 -0
- package/docs/api/functions/katakanaToHiragana.md +27 -0
- package/docs/api/interfaces/DefaultNoteInfo.md +4 -4
- package/docs/api/interfaces/Definition.md +6 -2
- package/docs/api/interfaces/DictKanjiMisc.md +1 -1
- package/docs/api/interfaces/DictWord.md +3 -3
- package/docs/api/interfaces/Grammar.md +16 -16
- package/docs/api/interfaces/GrammarMeaning.md +3 -3
- package/docs/api/interfaces/JaWiktionaryEntry.md +2 -2
- package/docs/api/interfaces/Kana.md +11 -11
- package/docs/api/interfaces/Kanji.md +24 -24
- 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 +10 -10
- 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 +4 -4
- package/docs/api/type-aliases/Dict.md +1 -1
- package/docs/api/type-aliases/EntryType.md +1 -1
- package/docs/api/type-aliases/JLPT.md +1 -1
- package/docs/api/type-aliases/Result.md +1 -1
- package/package.json +7 -4
- package/src/constants.ts +1225 -0
- package/src/index.ts +3 -0
- package/src/types.ts +1056 -0
- package/src/utils.ts +3018 -0
package/dist/index.cjs.js
CHANGED
|
@@ -48,6 +48,7 @@ __export(index_exports, {
|
|
|
48
48
|
getWord: () => getWord,
|
|
49
49
|
getWordDefinitions: () => getWordDefinitions,
|
|
50
50
|
getWordDefinitionsWithFurigana: () => getWordDefinitionsWithFurigana,
|
|
51
|
+
hiraganaToKatakana: () => hiraganaToKatakana,
|
|
51
52
|
isGrammar: () => isGrammar,
|
|
52
53
|
isKana: () => isKana,
|
|
53
54
|
isKanji: () => isKanji,
|
|
@@ -56,9 +57,11 @@ __export(index_exports, {
|
|
|
56
57
|
isStringArray: () => isStringArray,
|
|
57
58
|
isValidArrayWithFirstElement: () => isValidArrayWithFirstElement,
|
|
58
59
|
isWord: () => isWord,
|
|
60
|
+
katakanaToHiragana: () => katakanaToHiragana,
|
|
59
61
|
notSearchedForms: () => notSearchedForms,
|
|
60
62
|
noteHeaderKeys: () => noteHeaderKeys,
|
|
61
63
|
noteMap: () => noteMap,
|
|
64
|
+
posList: () => posList,
|
|
62
65
|
regexps: () => regexps,
|
|
63
66
|
shuffleArray: () => shuffleArray
|
|
64
67
|
});
|
|
@@ -99,6 +102,43 @@ var notSearchedForms = /* @__PURE__ */ new Set([
|
|
|
99
102
|
"word containing out-dated kanji or kanji usage",
|
|
100
103
|
"Out-dated kanji or kanji usage"
|
|
101
104
|
]);
|
|
105
|
+
var posList = [
|
|
106
|
+
"\u540D\u8A5E",
|
|
107
|
+
"\u52D5\u8A5E",
|
|
108
|
+
"\u6210\u53E5",
|
|
109
|
+
"\u526F\u8A5E",
|
|
110
|
+
"\u5F62\u5BB9\u52D5\u8A5E",
|
|
111
|
+
"\u52A9\u8A5E",
|
|
112
|
+
"\u611F\u52D5\u8A5E",
|
|
113
|
+
"\u4EE3\u540D\u8A5E",
|
|
114
|
+
"\u63A5\u5C3E\u8F9E",
|
|
115
|
+
"\u63A5\u982D\u8A9E",
|
|
116
|
+
"\u9020\u8A9E\u6210\u5206",
|
|
117
|
+
"\u7565\u8A9E",
|
|
118
|
+
"\u56FA\u6709\u540D\u8A5E",
|
|
119
|
+
"\u4EBA\u79F0\u4EE3\u540D\u8A5E",
|
|
120
|
+
"\u63A5\u982D\u8F9E",
|
|
121
|
+
"\u63A5\u7D9A\u52A9\u8A5E",
|
|
122
|
+
"\u9593\u6295\u8A5E",
|
|
123
|
+
"\u52A9\u52D5\u8A5E",
|
|
124
|
+
"\u5F62\u5BB9\u8A5E",
|
|
125
|
+
"\u7E2E\u7D04\u5F62",
|
|
126
|
+
"\u63A5\u8F9E",
|
|
127
|
+
"\u63A5\u7D9A\u8A5E",
|
|
128
|
+
"\u9023\u4F53\u8A5E",
|
|
129
|
+
"\u4EBA\u540D",
|
|
130
|
+
"\u8A18\u53F7",
|
|
131
|
+
"\u6570\u8A5E",
|
|
132
|
+
"\u6163\u7528\u53E5",
|
|
133
|
+
"\u3053\u3068\u308F\u3056",
|
|
134
|
+
"\u52A9\u6570\u8A5E",
|
|
135
|
+
"\u82F1\u6570\u5B57\u6DF7\u5408\u8868\u8A18",
|
|
136
|
+
"\u52D5\u8A5E\u53E5",
|
|
137
|
+
"\u6210\u8A9E",
|
|
138
|
+
"\u610F\u7FA9",
|
|
139
|
+
"\u982D\u5B57\u8A9E",
|
|
140
|
+
"\u63A5\u5C3E\u8A9E"
|
|
141
|
+
];
|
|
102
142
|
var noteMap = /* @__PURE__ */ new Map([
|
|
103
143
|
["brazilian", ["dialect::brazilian", "Dialect: Brazilian"]],
|
|
104
144
|
["hokkaido-ben", ["dialect::hokkaido-ben", "Dialect: Hokkaid\u014D-ben"]],
|
|
@@ -1242,10 +1282,10 @@ var noteMap = /* @__PURE__ */ new Map([
|
|
|
1242
1282
|
]);
|
|
1243
1283
|
|
|
1244
1284
|
// src/utils.ts
|
|
1285
|
+
var import_readline = require("readline");
|
|
1245
1286
|
var import_libxmljs2 = __toESM(require("libxmljs2"));
|
|
1246
1287
|
var import_xml2js = __toESM(require("xml2js"));
|
|
1247
1288
|
var import_iconv_lite = __toESM(require("iconv-lite"));
|
|
1248
|
-
var import_readline = require("readline");
|
|
1249
1289
|
var Kuroshiro = require("kuroshiro");
|
|
1250
1290
|
var KuromojiAnalyzer = require("kuroshiro-analyzer-kuromoji");
|
|
1251
1291
|
function capitalizeString(value) {
|
|
@@ -1261,7 +1301,7 @@ function isObjectArray(arg) {
|
|
|
1261
1301
|
return isValidArrayWithFirstElement(arg) && arg.every((element) => typeof element === "object");
|
|
1262
1302
|
}
|
|
1263
1303
|
function shuffleArray(arr) {
|
|
1264
|
-
const a =
|
|
1304
|
+
const a = Array.from(arr);
|
|
1265
1305
|
for (let i = a.length - 1; i > 0; i--) {
|
|
1266
1306
|
const j = Math.floor(Math.random() * (i + 1));
|
|
1267
1307
|
const tmp = a[i];
|
|
@@ -1270,13 +1310,43 @@ function shuffleArray(arr) {
|
|
|
1270
1310
|
}
|
|
1271
1311
|
return a;
|
|
1272
1312
|
}
|
|
1313
|
+
function hiraganaToKatakana(input) {
|
|
1314
|
+
const decomposed = input.normalize("NFD");
|
|
1315
|
+
const output = [];
|
|
1316
|
+
for (const ch of decomposed.split("")) {
|
|
1317
|
+
const cp = ch.codePointAt(0);
|
|
1318
|
+
if (cp === 12441 || cp === 12442) {
|
|
1319
|
+
output.push(ch);
|
|
1320
|
+
continue;
|
|
1321
|
+
}
|
|
1322
|
+
if (cp >= 12352 && cp <= 12447)
|
|
1323
|
+
output.push(String.fromCodePoint(cp + 96));
|
|
1324
|
+
else output.push(ch);
|
|
1325
|
+
}
|
|
1326
|
+
return output.join("").normalize("NFC");
|
|
1327
|
+
}
|
|
1328
|
+
function katakanaToHiragana(input) {
|
|
1329
|
+
const decomposed = input.normalize("NFD");
|
|
1330
|
+
const output = [];
|
|
1331
|
+
for (const ch of decomposed.split("")) {
|
|
1332
|
+
const cp = ch.codePointAt(0);
|
|
1333
|
+
if (cp === 12441 || cp === 12442) {
|
|
1334
|
+
output.push(ch);
|
|
1335
|
+
continue;
|
|
1336
|
+
}
|
|
1337
|
+
if (cp >= 12448 && cp <= 12543)
|
|
1338
|
+
output.push(String.fromCodePoint(cp - 96));
|
|
1339
|
+
else output.push(ch);
|
|
1340
|
+
}
|
|
1341
|
+
return output.join("").normalize("NFC");
|
|
1342
|
+
}
|
|
1273
1343
|
function getValidForms(readings, kanjiForms, wordIsCommon) {
|
|
1274
1344
|
const kanjiFormRestrictions = /* @__PURE__ */ new Set();
|
|
1275
1345
|
const validReadings = readings.filter(
|
|
1276
1346
|
(reading, index) => {
|
|
1277
1347
|
if (index === 0) return true;
|
|
1278
1348
|
if (reading.notes === void 0 || !reading.notes.some((note) => notSearchedForms.has(note))) {
|
|
1279
|
-
if (reading.kanjiFormRestrictions) {
|
|
1349
|
+
if (reading.kanjiFormRestrictions !== void 0) {
|
|
1280
1350
|
for (const kfr of reading.kanjiFormRestrictions)
|
|
1281
1351
|
kanjiFormRestrictions.add(kfr);
|
|
1282
1352
|
return true;
|
|
@@ -1287,20 +1357,22 @@ function getValidForms(readings, kanjiForms, wordIsCommon) {
|
|
|
1287
1357
|
return false;
|
|
1288
1358
|
}
|
|
1289
1359
|
);
|
|
1290
|
-
const existValidKf = kanjiForms
|
|
1291
|
-
(kf, index) => index !== 0 && (
|
|
1292
|
-
)
|
|
1293
|
-
const validKanjiForms = kanjiForms
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1360
|
+
const existValidKf = kanjiForms == null ? void 0 : kanjiForms.some(
|
|
1361
|
+
(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))
|
|
1362
|
+
);
|
|
1363
|
+
const validKanjiForms = kanjiForms == null ? void 0 : kanjiForms.filter(
|
|
1364
|
+
(kanjiForm, index) => {
|
|
1365
|
+
if (index === 0) return true;
|
|
1366
|
+
if (existValidKf === true)
|
|
1367
|
+
return kanjiForm.notes === void 0 || !kanjiForm.notes.some(
|
|
1368
|
+
(note) => notSearchedForms.has(note)
|
|
1369
|
+
) && (wordIsCommon === void 0 || kanjiForm.commonness !== void 0) || kanjiFormRestrictions.has(kanjiForm.form);
|
|
1370
|
+
else return true;
|
|
1371
|
+
}
|
|
1372
|
+
);
|
|
1301
1373
|
return {
|
|
1302
1374
|
readings: validReadings,
|
|
1303
|
-
...validKanjiForms ? { kanjiForms: validKanjiForms } : {}
|
|
1375
|
+
...validKanjiForms !== void 0 ? { kanjiForms: validKanjiForms } : {}
|
|
1304
1376
|
};
|
|
1305
1377
|
}
|
|
1306
1378
|
function convertJMdict(xmlString, examples) {
|
|
@@ -1312,13 +1384,13 @@ function convertJMdict(xmlString, examples) {
|
|
|
1312
1384
|
});
|
|
1313
1385
|
const dict = [];
|
|
1314
1386
|
import_xml2js.default.parseString(dictParsed, (_err, result) => {
|
|
1315
|
-
const tanakaParts = examples && examples.length > 0 ? new Set(
|
|
1387
|
+
const tanakaParts = examples !== void 0 && examples.length > 0 ? new Set(
|
|
1316
1388
|
examples.flatMap(
|
|
1317
1389
|
(example) => example.parts.flatMap((part) => [
|
|
1318
1390
|
part.baseForm,
|
|
1319
|
-
...part.reading ? [part.reading] : [],
|
|
1320
|
-
...part.inflectedForm ? [part.inflectedForm] : [],
|
|
1321
|
-
...part.referenceID ? [part.referenceID] : []
|
|
1391
|
+
...part.reading !== void 0 ? [part.reading] : [],
|
|
1392
|
+
...part.inflectedForm !== void 0 ? [part.inflectedForm] : [],
|
|
1393
|
+
...part.referenceID !== void 0 ? [part.referenceID] : []
|
|
1322
1394
|
])
|
|
1323
1395
|
)
|
|
1324
1396
|
) : void 0;
|
|
@@ -1365,7 +1437,7 @@ function convertJMdict(xmlString, examples) {
|
|
|
1365
1437
|
meaningObj.translations = [];
|
|
1366
1438
|
for (const gloss of meaning.gloss)
|
|
1367
1439
|
if (typeof gloss === "string") meaningObj.translations.push(gloss);
|
|
1368
|
-
else if (typeof gloss === "object" &&
|
|
1440
|
+
else if (typeof gloss === "object" && typeof gloss._ === "string" && typeof gloss.$ === "object" && (gloss.$.g_type === "lit" || gloss.$.g_type === "expl" || gloss.$.g_type === "tm"))
|
|
1369
1441
|
meaningObj.translations.push({
|
|
1370
1442
|
translation: gloss._,
|
|
1371
1443
|
type: gloss.$.g_type
|
|
@@ -1380,7 +1452,7 @@ function convertJMdict(xmlString, examples) {
|
|
|
1380
1452
|
if (isStringArray(meaning.s_inf)) meaningObj.info = meaning.s_inf;
|
|
1381
1453
|
if (isStringArray(meaning.misc)) {
|
|
1382
1454
|
meaningObj.misc = meaning.misc;
|
|
1383
|
-
if (meaningObj.misc && meaningObj.misc.includes("word usually written using kana alone"))
|
|
1455
|
+
if (meaningObj.misc !== void 0 && meaningObj.misc.includes("word usually written using kana alone"))
|
|
1384
1456
|
usuallyInKanaMeanings++;
|
|
1385
1457
|
}
|
|
1386
1458
|
if (isStringArray(meaning.dial)) meaningObj.dialects = meaning.dial;
|
|
@@ -1388,30 +1460,31 @@ function convertJMdict(xmlString, examples) {
|
|
|
1388
1460
|
}
|
|
1389
1461
|
if (entryObj.meanings.length === usuallyInKanaMeanings)
|
|
1390
1462
|
entryObj.usuallyInKana = true;
|
|
1391
|
-
if (examples) {
|
|
1463
|
+
if (examples !== void 0) {
|
|
1392
1464
|
let existsExample = false;
|
|
1393
|
-
if (tanakaParts && tanakaParts.has(entryObj.id))
|
|
1465
|
+
if (tanakaParts !== void 0 && tanakaParts.has(entryObj.id))
|
|
1466
|
+
existsExample = true;
|
|
1394
1467
|
if (!existsExample) {
|
|
1395
1468
|
const rkf = getValidForms(
|
|
1396
1469
|
entryObj.readings,
|
|
1397
1470
|
entryObj.kanjiForms,
|
|
1398
1471
|
entryObj.isCommon
|
|
1399
1472
|
);
|
|
1400
|
-
const
|
|
1473
|
+
const validReadings = new Set(
|
|
1401
1474
|
rkf.readings.map((r) => r.reading)
|
|
1402
1475
|
);
|
|
1403
|
-
const
|
|
1476
|
+
const validKanjiForms = rkf.kanjiForms !== void 0 ? new Set(
|
|
1404
1477
|
rkf.kanjiForms.map((kf) => kf.form)
|
|
1405
1478
|
) : void 0;
|
|
1406
|
-
if (
|
|
1407
|
-
for (const kf of
|
|
1479
|
+
if (validKanjiForms !== void 0 && validKanjiForms.size > 0 && tanakaParts !== void 0) {
|
|
1480
|
+
for (const kf of validKanjiForms)
|
|
1408
1481
|
if (tanakaParts.has(kf)) {
|
|
1409
1482
|
existsExample = true;
|
|
1410
1483
|
break;
|
|
1411
1484
|
}
|
|
1412
1485
|
}
|
|
1413
|
-
if (entryObj.kanjiForms === void 0 &&
|
|
1414
|
-
for (const r of
|
|
1486
|
+
if (entryObj.kanjiForms === void 0 && validReadings.size > 0 && tanakaParts !== void 0) {
|
|
1487
|
+
for (const r of validReadings)
|
|
1415
1488
|
if (tanakaParts.has(r)) {
|
|
1416
1489
|
existsExample = true;
|
|
1417
1490
|
break;
|
|
@@ -1445,7 +1518,7 @@ function convertKanjiDic(xmlString) {
|
|
|
1445
1518
|
if (isStringArray(misc.grade)) kanjiObj.misc.grade = misc.grade[0];
|
|
1446
1519
|
if (isStringArray(misc.freq)) kanjiObj.misc.frequency = misc.freq[0];
|
|
1447
1520
|
if (isStringArray(misc.jlpt) && ["5", "4", "3", "2", "1"].includes(misc.jlpt[0]))
|
|
1448
|
-
kanjiObj.misc.jlpt = `N${misc.jlpt[0]}`;
|
|
1521
|
+
kanjiObj.misc.jlpt = `N${Number(String(misc.jlpt[0]))}`;
|
|
1449
1522
|
if (isObjectArray(entry.reading_meaning))
|
|
1450
1523
|
for (const rm of entry.reading_meaning) {
|
|
1451
1524
|
const rmObj = { groups: [] };
|
|
@@ -1456,7 +1529,7 @@ function convertKanjiDic(xmlString) {
|
|
|
1456
1529
|
};
|
|
1457
1530
|
if (isObjectArray(group.reading)) {
|
|
1458
1531
|
for (const reading of group.reading)
|
|
1459
|
-
if (
|
|
1532
|
+
if (typeof reading._ === "string" && typeof reading.$ === "object" && (reading.$.r_type === "ja_on" || reading.$.r_type === "ja_kun"))
|
|
1460
1533
|
groupObj.readings.push({
|
|
1461
1534
|
reading: reading._,
|
|
1462
1535
|
type: reading.$.r_type
|
|
@@ -1480,7 +1553,7 @@ function convertKanjiDic(xmlString) {
|
|
|
1480
1553
|
}
|
|
1481
1554
|
if (isStringArray(rm.nanori) && rm.nanori.length > 0)
|
|
1482
1555
|
rmObj.nanori = rm.nanori;
|
|
1483
|
-
if (rmObj.groups.length > 0 || rmObj.nanori)
|
|
1556
|
+
if (rmObj.groups.length > 0 || rmObj.nanori !== void 0)
|
|
1484
1557
|
kanjiObj.readingMeaning.push(rmObj);
|
|
1485
1558
|
}
|
|
1486
1559
|
dict.push(kanjiObj);
|
|
@@ -1490,16 +1563,18 @@ function convertKanjiDic(xmlString) {
|
|
|
1490
1563
|
return dict;
|
|
1491
1564
|
}
|
|
1492
1565
|
function convertTanakaCorpus(tanakaString) {
|
|
1493
|
-
var _a;
|
|
1566
|
+
var _a, _b;
|
|
1494
1567
|
const tanakaArray = [];
|
|
1495
1568
|
const tanakaParsed = tanakaString.split("\n");
|
|
1496
1569
|
for (let i = 0; i <= tanakaParsed.length; i += 2) {
|
|
1497
1570
|
let a = tanakaParsed[i];
|
|
1498
1571
|
let b = tanakaParsed[i + 1];
|
|
1499
|
-
if (a && b && a.startsWith("A: ") && b.startsWith("B: ")) {
|
|
1572
|
+
if (a !== void 0 && b !== void 0 && a.startsWith("A: ") && b.startsWith("B: ")) {
|
|
1500
1573
|
a = a.replace("A: ", "");
|
|
1501
1574
|
b = b.replace("B: ", "");
|
|
1502
|
-
const idMatch = regexps.tanakaID.exec(a);
|
|
1575
|
+
const idMatch = (_b = (_a = regexps.tanakaID.exec(a)) == null ? void 0 : _a.groups["id"]) == null ? void 0 : _b.trim();
|
|
1576
|
+
const idParts = String(idMatch).split("_");
|
|
1577
|
+
const id = `${Number(idParts[0])}_${Number(idParts[1])}`;
|
|
1503
1578
|
const aParts = a.replace(regexps.tanakaID, "").split(" ");
|
|
1504
1579
|
const bRawParts = b.split(" ").filter((part) => part.trim().length !== 0);
|
|
1505
1580
|
const bParts = [];
|
|
@@ -1510,14 +1585,17 @@ function convertTanakaCorpus(tanakaString) {
|
|
|
1510
1585
|
const reading = partMatches == null ? void 0 : partMatches.groups["reading"];
|
|
1511
1586
|
const glossNumber = partMatches == null ? void 0 : partMatches.groups["glossnum"];
|
|
1512
1587
|
const inflectedForm = partMatches == null ? void 0 : partMatches.groups["inflection"];
|
|
1513
|
-
if (reading)
|
|
1588
|
+
if (reading !== void 0)
|
|
1514
1589
|
if (regexps.tanakaReferenceID.test(reading)) {
|
|
1515
1590
|
const referenceID = regexps.tanakaReferenceID.exec(reading);
|
|
1516
|
-
examplePart.referenceID =
|
|
1591
|
+
examplePart.referenceID = `${Number(
|
|
1592
|
+
referenceID == null ? void 0 : referenceID.groups["entryid"]
|
|
1593
|
+
)}`;
|
|
1517
1594
|
} else examplePart.reading = reading;
|
|
1518
|
-
if (glossNumber)
|
|
1595
|
+
if (glossNumber !== void 0)
|
|
1519
1596
|
examplePart.glossNumber = glossNumber.startsWith("0") ? Number.parseInt(glossNumber.substring(1)) : Number.parseInt(glossNumber);
|
|
1520
|
-
if (inflectedForm
|
|
1597
|
+
if (inflectedForm !== void 0)
|
|
1598
|
+
examplePart.inflectedForm = inflectedForm;
|
|
1521
1599
|
if (baseForm.endsWith("~")) {
|
|
1522
1600
|
examplePart.edited = true;
|
|
1523
1601
|
examplePart.baseForm = examplePart.baseForm.replace("~", "");
|
|
@@ -1527,7 +1605,7 @@ function convertTanakaCorpus(tanakaString) {
|
|
|
1527
1605
|
const phrase = aParts[0];
|
|
1528
1606
|
const translation = aParts[1];
|
|
1529
1607
|
tanakaArray.push({
|
|
1530
|
-
id
|
|
1608
|
+
id,
|
|
1531
1609
|
phrase: phrase.trim(),
|
|
1532
1610
|
translation: translation.trim(),
|
|
1533
1611
|
parts: bParts
|
|
@@ -1537,34 +1615,26 @@ function convertTanakaCorpus(tanakaString) {
|
|
|
1537
1615
|
return tanakaArray;
|
|
1538
1616
|
}
|
|
1539
1617
|
async function convertTanakaCorpusWithFurigana(tanakaString) {
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
tanakaArray =
|
|
1547
|
-
tanakaArray.
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
furigana = await convert(ex.phrase, {
|
|
1551
|
-
to: "hiragana",
|
|
1552
|
-
mode: "furigana"
|
|
1553
|
-
});
|
|
1554
|
-
if (furigana) ex.furigana = furigana;
|
|
1555
|
-
return ex;
|
|
1618
|
+
const tanakaArray = convertTanakaCorpus(tanakaString);
|
|
1619
|
+
const kuroshiro = new Kuroshiro.default();
|
|
1620
|
+
await kuroshiro.init(new KuromojiAnalyzer());
|
|
1621
|
+
const convert = kuroshiro.convert.bind(kuroshiro);
|
|
1622
|
+
for (let i = 0; i < tanakaArray.length; i++)
|
|
1623
|
+
if (!tanakaArray[i].phrase.includes("\u30FB"))
|
|
1624
|
+
tanakaArray[i].furigana = String(
|
|
1625
|
+
await convert(tanakaArray[i].phrase, {
|
|
1626
|
+
to: "hiragana",
|
|
1627
|
+
mode: "furigana"
|
|
1556
1628
|
})
|
|
1557
1629
|
);
|
|
1558
|
-
|
|
1559
|
-
}
|
|
1560
|
-
);
|
|
1630
|
+
return tanakaArray;
|
|
1561
1631
|
}
|
|
1562
1632
|
function convertRadkFile(radkBuffer, kanjiDic) {
|
|
1563
1633
|
const fileParsed = import_iconv_lite.default.decode(radkBuffer, "euc-jp").split("\n").filter((line) => !line.startsWith("#"));
|
|
1564
1634
|
const radicals = [];
|
|
1565
1635
|
for (let i = 0; i < fileParsed.length; i++) {
|
|
1566
1636
|
const line = fileParsed[i];
|
|
1567
|
-
if (line && line.startsWith("$ ")) {
|
|
1637
|
+
if (line !== void 0 && line.startsWith("$ ")) {
|
|
1568
1638
|
const radical = {
|
|
1569
1639
|
radical: line.charAt(2).trim(),
|
|
1570
1640
|
strokes: line.substring(4).trim()
|
|
@@ -1572,7 +1642,7 @@ function convertRadkFile(radkBuffer, kanjiDic) {
|
|
|
1572
1642
|
let j = i + 1;
|
|
1573
1643
|
let kanjiLine = fileParsed[j];
|
|
1574
1644
|
const kanjiList = [];
|
|
1575
|
-
while (kanjiLine && !kanjiLine.startsWith("$ ")) {
|
|
1645
|
+
while (kanjiLine !== void 0 && !kanjiLine.startsWith("$ ")) {
|
|
1576
1646
|
const kanjis = kanjiLine.split("");
|
|
1577
1647
|
for (const kanji of kanjis) {
|
|
1578
1648
|
const foundKanji = kanjiDic.find(
|
|
@@ -1583,7 +1653,7 @@ function convertRadkFile(radkBuffer, kanjiDic) {
|
|
|
1583
1653
|
kanjiList.push(kanjiObj);
|
|
1584
1654
|
}
|
|
1585
1655
|
kanjiLine = fileParsed[++j];
|
|
1586
|
-
if (
|
|
1656
|
+
if (kanjiLine === void 0) continue;
|
|
1587
1657
|
if (kanjiLine.startsWith("$ ")) i = j - 1;
|
|
1588
1658
|
}
|
|
1589
1659
|
if (kanjiList.length > 0) radical.kanji = kanjiList;
|
|
@@ -1595,7 +1665,7 @@ function convertRadkFile(radkBuffer, kanjiDic) {
|
|
|
1595
1665
|
function convertKradFile(kradBuffer, kanjiDic, katakanaList) {
|
|
1596
1666
|
const fileParsed = import_iconv_lite.default.decode(kradBuffer, "euc-jp").split("\n").filter((line) => !line.startsWith("#"));
|
|
1597
1667
|
const kanjiWithRadicals = [];
|
|
1598
|
-
for (const line of fileParsed)
|
|
1668
|
+
for (const line of fileParsed)
|
|
1599
1669
|
if (line.length > 0) {
|
|
1600
1670
|
const split = line.split(" : ");
|
|
1601
1671
|
const kanjiChar = split[0];
|
|
@@ -1610,11 +1680,11 @@ function convertKradFile(kradBuffer, kanjiDic, katakanaList) {
|
|
|
1610
1680
|
(dictKanji) => dictKanji.kanji === radical
|
|
1611
1681
|
);
|
|
1612
1682
|
let radicalObj = foundRadical != null ? foundRadical : { kanji: radical };
|
|
1613
|
-
if (
|
|
1683
|
+
if (foundRadical === void 0) {
|
|
1614
1684
|
const katakanaChar = katakanaList.find(
|
|
1615
1685
|
(kana) => kana.kana === radical
|
|
1616
1686
|
);
|
|
1617
|
-
if (
|
|
1687
|
+
if (katakanaChar === void 0) continue;
|
|
1618
1688
|
radicalObj = {
|
|
1619
1689
|
kanji: katakanaChar.kana,
|
|
1620
1690
|
readingMeaning: [
|
|
@@ -1634,7 +1704,6 @@ function convertKradFile(kradBuffer, kanjiDic, katakanaList) {
|
|
|
1634
1704
|
if (kanji.kanji.length === 1 && kanji.radicals.length > 0)
|
|
1635
1705
|
kanjiWithRadicals.push(kanji);
|
|
1636
1706
|
}
|
|
1637
|
-
}
|
|
1638
1707
|
return kanjiWithRadicals;
|
|
1639
1708
|
}
|
|
1640
1709
|
function createEntryMaps(jmDict, kanjiDic, tanakaExamples, wordDefinitionPairs, svgList) {
|
|
@@ -1648,30 +1717,29 @@ function createEntryMaps(jmDict, kanjiDic, tanakaExamples, wordDefinitionPairs,
|
|
|
1648
1717
|
const wordPartsMap = /* @__PURE__ */ new Map();
|
|
1649
1718
|
const partExamplesMap = /* @__PURE__ */ new Map();
|
|
1650
1719
|
const entryParts = /* @__PURE__ */ new Set();
|
|
1651
|
-
if (kanjiDic)
|
|
1720
|
+
if (kanjiDic !== void 0)
|
|
1652
1721
|
for (const kanji of kanjiDic) kanjiEntryMap.set(kanji.kanji, kanji);
|
|
1653
|
-
if (wordDefinitionPairs)
|
|
1722
|
+
if (wordDefinitionPairs !== void 0)
|
|
1654
1723
|
for (const pair of wordDefinitionPairs)
|
|
1655
1724
|
wordDefinitionsMap.set(pair.wordID, pair.definitions);
|
|
1656
|
-
if (kanjiDic && svgList)
|
|
1725
|
+
if (kanjiDic !== void 0 && svgList !== void 0)
|
|
1657
1726
|
for (const kanji of kanjiDic) {
|
|
1658
1727
|
const codePoint = kanji.kanji.codePointAt(0).toString(16).toLowerCase();
|
|
1659
1728
|
const svg = svgList.find((file) => {
|
|
1660
1729
|
const baseName = file.split(".")[0].toLowerCase();
|
|
1661
1730
|
return baseName === codePoint || baseName === `0${codePoint}`;
|
|
1662
1731
|
});
|
|
1663
|
-
if (svg) kanjiSVGMap.set(kanji.kanji, svg);
|
|
1732
|
+
if (svg !== void 0) kanjiSVGMap.set(kanji.kanji, svg);
|
|
1664
1733
|
}
|
|
1665
|
-
if (jmDict) {
|
|
1734
|
+
if (jmDict !== void 0) {
|
|
1666
1735
|
for (const word of jmDict) {
|
|
1667
1736
|
wordIDEntryMap.set(word.id, word);
|
|
1668
|
-
if (word.kanjiForms)
|
|
1737
|
+
if (word.kanjiForms !== void 0)
|
|
1669
1738
|
for (const kf of word.kanjiForms)
|
|
1670
|
-
for (const char of kf.form.split("").filter((c) => regexps.kanji.test(c)))
|
|
1739
|
+
for (const char of kf.form.split("").filter((c) => regexps.kanji.test(c)))
|
|
1671
1740
|
if (!kanjiWordsMap.has(char)) kanjiWordsMap.set(char, [word]);
|
|
1672
1741
|
else kanjiWordsMap.get(char).push(word);
|
|
1673
|
-
|
|
1674
|
-
if (tanakaExamples) {
|
|
1742
|
+
if (tanakaExamples !== void 0) {
|
|
1675
1743
|
const rkf = getValidForms(
|
|
1676
1744
|
word.readings,
|
|
1677
1745
|
word.kanjiForms,
|
|
@@ -1682,7 +1750,7 @@ function createEntryMaps(jmDict, kanjiDic, tanakaExamples, wordDefinitionPairs,
|
|
|
1682
1750
|
entryParts.add(reading.reading);
|
|
1683
1751
|
localPartParts.add(reading.reading);
|
|
1684
1752
|
}
|
|
1685
|
-
if (rkf.kanjiForms && rkf.kanjiForms.length > 0)
|
|
1753
|
+
if (rkf.kanjiForms !== void 0 && rkf.kanjiForms.length > 0)
|
|
1686
1754
|
for (const kanjiForm of rkf.kanjiForms) {
|
|
1687
1755
|
entryParts.add(kanjiForm.form);
|
|
1688
1756
|
localPartParts.add(kanjiForm.form);
|
|
@@ -1692,58 +1760,56 @@ function createEntryMaps(jmDict, kanjiDic, tanakaExamples, wordDefinitionPairs,
|
|
|
1692
1760
|
wordPartsMap.set(word.id, localPartParts);
|
|
1693
1761
|
}
|
|
1694
1762
|
}
|
|
1695
|
-
if (tanakaExamples) {
|
|
1696
|
-
for (const ex of tanakaExamples)
|
|
1763
|
+
if (tanakaExamples !== void 0) {
|
|
1764
|
+
for (const ex of tanakaExamples)
|
|
1697
1765
|
for (const part of ex.parts) {
|
|
1698
1766
|
if (entryParts.has(part.baseForm)) {
|
|
1699
1767
|
let exList = partExamplesMap.get(
|
|
1700
1768
|
part.baseForm
|
|
1701
1769
|
);
|
|
1702
|
-
if (
|
|
1770
|
+
if (exList === void 0) {
|
|
1703
1771
|
exList = [];
|
|
1704
1772
|
partExamplesMap.set(part.baseForm, exList);
|
|
1705
1773
|
}
|
|
1706
1774
|
exList.push(ex);
|
|
1707
1775
|
}
|
|
1708
|
-
if (part.reading && entryParts.has(part.reading)) {
|
|
1776
|
+
if (part.reading !== void 0 && entryParts.has(part.reading)) {
|
|
1709
1777
|
let exList = partExamplesMap.get(
|
|
1710
1778
|
part.reading
|
|
1711
1779
|
);
|
|
1712
|
-
if (
|
|
1780
|
+
if (exList === void 0) {
|
|
1713
1781
|
exList = [];
|
|
1714
1782
|
partExamplesMap.set(part.reading, exList);
|
|
1715
1783
|
}
|
|
1716
1784
|
exList.push(ex);
|
|
1717
1785
|
}
|
|
1718
|
-
if (part.inflectedForm && entryParts.has(part.inflectedForm)) {
|
|
1786
|
+
if (part.inflectedForm !== void 0 && entryParts.has(part.inflectedForm)) {
|
|
1719
1787
|
let exList = partExamplesMap.get(
|
|
1720
1788
|
part.inflectedForm
|
|
1721
1789
|
);
|
|
1722
|
-
if (
|
|
1790
|
+
if (exList === void 0) {
|
|
1723
1791
|
exList = [];
|
|
1724
1792
|
partExamplesMap.set(part.inflectedForm, exList);
|
|
1725
1793
|
}
|
|
1726
1794
|
exList.push(ex);
|
|
1727
1795
|
}
|
|
1728
|
-
if (part.referenceID && entryParts.has(part.referenceID)) {
|
|
1796
|
+
if (part.referenceID !== void 0 && entryParts.has(part.referenceID)) {
|
|
1729
1797
|
let exList = partExamplesMap.get(
|
|
1730
1798
|
part.referenceID
|
|
1731
1799
|
);
|
|
1732
|
-
if (
|
|
1800
|
+
if (exList === void 0) {
|
|
1733
1801
|
exList = [];
|
|
1734
1802
|
partExamplesMap.set(part.referenceID, exList);
|
|
1735
1803
|
}
|
|
1736
1804
|
exList.push(ex);
|
|
1737
1805
|
}
|
|
1738
1806
|
}
|
|
1739
|
-
}
|
|
1740
1807
|
for (const word of jmDict) {
|
|
1741
|
-
const entryParts2 = wordPartsMap.get(word.id);
|
|
1742
1808
|
const seenEx = /* @__PURE__ */ new Set();
|
|
1743
1809
|
const validExamples = [];
|
|
1744
|
-
for (const p of
|
|
1810
|
+
for (const p of wordPartsMap.get(word.id)) {
|
|
1745
1811
|
const examplesForPart = (_a = partExamplesMap.get(p)) == null ? void 0 : _a.filter((ex) => !seenEx.has(ex.id));
|
|
1746
|
-
if (
|
|
1812
|
+
if (examplesForPart === void 0) continue;
|
|
1747
1813
|
for (const ex of examplesForPart) {
|
|
1748
1814
|
seenEx.add(ex.id);
|
|
1749
1815
|
validExamples.push(ex);
|
|
@@ -1768,49 +1834,44 @@ function mapEntry(entry) {
|
|
|
1768
1834
|
word: entry.word,
|
|
1769
1835
|
pos_title: entry.pos_title,
|
|
1770
1836
|
senses: entry.senses.filter(
|
|
1771
|
-
(sense) => isObjectArray(sense.form_of)
|
|
1772
|
-
(form) => form.word && typeof form.word === "string"
|
|
1773
|
-
) || isStringArray(sense.glosses)
|
|
1837
|
+
(sense) => (isObjectArray(sense.form_of) ? sense.form_of.every((form) => typeof form.word === "string") : isStringArray(sense.glosses)) === true || isStringArray(sense.glosses)
|
|
1774
1838
|
).map((sense) => ({
|
|
1775
|
-
...sense.form_of ? {
|
|
1776
|
-
form_of: sense.form_of.map((form) => form.word)
|
|
1839
|
+
...isObjectArray(sense.form_of) ? {
|
|
1840
|
+
form_of: sense.form_of.map((form) => String(form.word))
|
|
1777
1841
|
} : {},
|
|
1778
1842
|
glosses: sense.glosses
|
|
1779
1843
|
})),
|
|
1780
|
-
...isObjectArray(entry.forms) && entry.forms.every((form) => typeof form.form === "string") ? { forms: entry.forms.map((form) => form.form) } : {}
|
|
1844
|
+
...isObjectArray(entry.forms) && entry.forms.every((form) => typeof form.form === "string") === true ? { forms: entry.forms.map((form) => String(form.form)) } : {}
|
|
1781
1845
|
};
|
|
1782
1846
|
}
|
|
1783
1847
|
function convertJawiktionarySync(buffer) {
|
|
1848
|
+
var _a;
|
|
1784
1849
|
const lines = buffer.toString("utf-8").split("\n");
|
|
1785
1850
|
const entries = [];
|
|
1786
1851
|
for (let i = 0; i < lines.length; i++) {
|
|
1787
|
-
const line = lines[i];
|
|
1788
|
-
if (
|
|
1852
|
+
const line = (_a = lines[i]) == null ? void 0 : _a.trim();
|
|
1853
|
+
if (line === void 0 || line.length === 0) continue;
|
|
1789
1854
|
const obj = JSON.parse(line);
|
|
1790
|
-
if (
|
|
1855
|
+
if (typeof obj === "object" && (obj.lang === "\u65E5\u672C\u8A9E" || obj.lang === "\u53E4\u5178\u65E5\u672C\u8A9E"))
|
|
1791
1856
|
entries.push(mapEntry(obj));
|
|
1792
1857
|
}
|
|
1793
1858
|
return entries;
|
|
1794
1859
|
}
|
|
1795
1860
|
async function convertJawiktionaryAsync(stream) {
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
stream.destroy();
|
|
1811
|
-
resolve(entries);
|
|
1812
|
-
}
|
|
1813
|
-
);
|
|
1861
|
+
const rl = (0, import_readline.createInterface)({
|
|
1862
|
+
input: stream,
|
|
1863
|
+
crlfDelay: Infinity
|
|
1864
|
+
});
|
|
1865
|
+
const entries = [];
|
|
1866
|
+
for await (const line of rl) {
|
|
1867
|
+
const obj = JSON.parse(line.trim());
|
|
1868
|
+
if (typeof obj === "object" && (obj.lang === "\u65E5\u672C\u8A9E" || obj.lang === "\u53E4\u5178\u65E5\u672C\u8A9E"))
|
|
1869
|
+
entries.push(mapEntry(obj));
|
|
1870
|
+
}
|
|
1871
|
+
rl.close();
|
|
1872
|
+
stream.close();
|
|
1873
|
+
stream.destroy();
|
|
1874
|
+
return entries;
|
|
1814
1875
|
}
|
|
1815
1876
|
function parseEntry(entry, definitions, definitionMap) {
|
|
1816
1877
|
for (const sense of entry.senses) {
|
|
@@ -1823,12 +1884,12 @@ function parseEntry(entry, definitions, definitionMap) {
|
|
|
1823
1884
|
}
|
|
1824
1885
|
}
|
|
1825
1886
|
}
|
|
1826
|
-
function getWordDefinitions(
|
|
1887
|
+
function getWordDefinitions(wiktionaryEntries, jmDict) {
|
|
1827
1888
|
var _a, _b, _c, _d, _e;
|
|
1828
1889
|
const entries = /* @__PURE__ */ new Map();
|
|
1829
|
-
for (const entry of
|
|
1890
|
+
for (const entry of wiktionaryEntries) {
|
|
1830
1891
|
const ent = entries.get(entry.word);
|
|
1831
|
-
if (ent) ent.push(entry);
|
|
1892
|
+
if (ent !== void 0) ent.push(entry);
|
|
1832
1893
|
else entries.set(entry.word, [entry]);
|
|
1833
1894
|
}
|
|
1834
1895
|
const japaneseDefinitions = [];
|
|
@@ -1842,15 +1903,14 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1842
1903
|
const wordKanjiForms = /* @__PURE__ */ new Set();
|
|
1843
1904
|
const rkf = getValidForms(
|
|
1844
1905
|
word.readings,
|
|
1845
|
-
word.kanjiForms
|
|
1846
|
-
word.isCommon
|
|
1906
|
+
word.kanjiForms
|
|
1847
1907
|
);
|
|
1848
1908
|
for (const r of rkf.readings) {
|
|
1849
1909
|
validReadings.add(r.reading);
|
|
1850
1910
|
wordReadings.add(r.reading);
|
|
1851
1911
|
validForms.add(r.reading);
|
|
1852
1912
|
}
|
|
1853
|
-
if (rkf.kanjiForms && rkf.kanjiForms.length > 0)
|
|
1913
|
+
if (rkf.kanjiForms !== void 0 && rkf.kanjiForms.length > 0)
|
|
1854
1914
|
for (const kf of rkf.kanjiForms) {
|
|
1855
1915
|
validKanjiForms.add(kf.form);
|
|
1856
1916
|
wordKanjiForms.add(kf.form);
|
|
@@ -1870,24 +1930,22 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1870
1930
|
const ents = Array.from(entries.values()).flat();
|
|
1871
1931
|
for (const entry of ents) {
|
|
1872
1932
|
let valid = false;
|
|
1873
|
-
if (validKanjiForms
|
|
1933
|
+
if (validKanjiForms.has(entry.word)) {
|
|
1874
1934
|
valid = true;
|
|
1875
1935
|
for (const sense of entry.senses) {
|
|
1876
|
-
if (sense.form_of && sense.form_of.some((form) => validForms.has(form)))
|
|
1936
|
+
if (sense.form_of !== void 0 && sense.form_of.some((form) => validForms.has(form)))
|
|
1877
1937
|
validFormOfEntries.add(entry.word);
|
|
1878
1938
|
for (const gloss of sense.glosses) {
|
|
1879
1939
|
let hasForm = false;
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1940
|
+
for (const r of validForms)
|
|
1941
|
+
if (gloss.includes(r)) {
|
|
1942
|
+
hasForm = true;
|
|
1943
|
+
break;
|
|
1944
|
+
}
|
|
1887
1945
|
if (hasForm) validGlossesEntries.add(entry.word);
|
|
1888
1946
|
}
|
|
1889
1947
|
}
|
|
1890
|
-
if (entry.forms) {
|
|
1948
|
+
if (entry.forms !== void 0) {
|
|
1891
1949
|
for (const form of entry.forms)
|
|
1892
1950
|
if (validForms.has(form)) validFormsEntries.add(entry.word);
|
|
1893
1951
|
}
|
|
@@ -1895,17 +1953,19 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1895
1953
|
if (validForms.has(entry.word)) {
|
|
1896
1954
|
valid = true;
|
|
1897
1955
|
const ftEntry = entriesWithFormTitlesGlobal.get(entry.word);
|
|
1898
|
-
if (ftEntry) ftEntry.push(entry);
|
|
1956
|
+
if (ftEntry !== void 0) ftEntry.push(entry);
|
|
1899
1957
|
else entriesWithFormTitlesGlobal.set(entry.word, [entry]);
|
|
1900
1958
|
}
|
|
1901
1959
|
if (valid) {
|
|
1902
|
-
const tEntry = validTitleEntries.get(
|
|
1903
|
-
|
|
1960
|
+
const tEntry = validTitleEntries.get(
|
|
1961
|
+
entry.word
|
|
1962
|
+
);
|
|
1963
|
+
if (tEntry !== void 0) tEntry.push(entry);
|
|
1904
1964
|
else validTitleEntries.set(entry.word, [entry]);
|
|
1905
1965
|
}
|
|
1906
|
-
if (entry.forms && validForms.has(entry.word) && entry.forms.some((form) => validForms.has(form))) {
|
|
1966
|
+
if (entry.forms !== void 0 && validForms.has(entry.word) && entry.forms.some((form) => validForms.has(form))) {
|
|
1907
1967
|
const wfEntry = entriesWithFormsGlobal.get(entry.word);
|
|
1908
|
-
if (wfEntry) wfEntry.push(entry);
|
|
1968
|
+
if (wfEntry !== void 0) wfEntry.push(entry);
|
|
1909
1969
|
else entriesWithFormsGlobal.set(entry.word, [entry]);
|
|
1910
1970
|
}
|
|
1911
1971
|
}
|
|
@@ -1920,53 +1980,17 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1920
1980
|
const wfe = Array.from(
|
|
1921
1981
|
entriesWithFormsGlobal.values()
|
|
1922
1982
|
).flat();
|
|
1923
|
-
for (const pos of
|
|
1924
|
-
"\u540D\u8A5E",
|
|
1925
|
-
"\u52D5\u8A5E",
|
|
1926
|
-
"\u6210\u53E5",
|
|
1927
|
-
"\u526F\u8A5E",
|
|
1928
|
-
"\u5F62\u5BB9\u52D5\u8A5E",
|
|
1929
|
-
"\u52A9\u8A5E",
|
|
1930
|
-
"\u611F\u52D5\u8A5E",
|
|
1931
|
-
"\u4EE3\u540D\u8A5E",
|
|
1932
|
-
"\u63A5\u5C3E\u8F9E",
|
|
1933
|
-
"\u63A5\u982D\u8A9E",
|
|
1934
|
-
"\u9020\u8A9E\u6210\u5206",
|
|
1935
|
-
"\u7565\u8A9E",
|
|
1936
|
-
"\u56FA\u6709\u540D\u8A5E",
|
|
1937
|
-
"\u4EBA\u79F0\u4EE3\u540D\u8A5E",
|
|
1938
|
-
"\u63A5\u982D\u8F9E",
|
|
1939
|
-
"\u63A5\u7D9A\u52A9\u8A5E",
|
|
1940
|
-
"\u9593\u6295\u8A5E",
|
|
1941
|
-
"\u52A9\u52D5\u8A5E",
|
|
1942
|
-
"\u5F62\u5BB9\u8A5E",
|
|
1943
|
-
"\u7E2E\u7D04\u5F62",
|
|
1944
|
-
"\u63A5\u8F9E",
|
|
1945
|
-
"\u63A5\u7D9A\u8A5E",
|
|
1946
|
-
"\u9023\u4F53\u8A5E",
|
|
1947
|
-
"\u4EBA\u540D",
|
|
1948
|
-
"\u8A18\u53F7",
|
|
1949
|
-
"\u6570\u8A5E",
|
|
1950
|
-
"\u6163\u7528\u53E5",
|
|
1951
|
-
"\u3053\u3068\u308F\u3056",
|
|
1952
|
-
"\u52A9\u6570\u8A5E",
|
|
1953
|
-
"\u82F1\u6570\u5B57\u6DF7\u5408\u8868\u8A18",
|
|
1954
|
-
"\u52D5\u8A5E\u53E5",
|
|
1955
|
-
"\u6210\u8A9E",
|
|
1956
|
-
"\u610F\u7FA9",
|
|
1957
|
-
"\u982D\u5B57\u8A9E",
|
|
1958
|
-
"\u63A5\u5C3E\u8A9E"
|
|
1959
|
-
]) {
|
|
1983
|
+
for (const pos of posList) {
|
|
1960
1984
|
posMap.set(pos, {});
|
|
1961
1985
|
for (const te of vte)
|
|
1962
1986
|
if (te.pos_title === pos || te.pos_title === "\u548C\u8A9E\u306E\u6F22\u5B57\u8868\u8A18") {
|
|
1963
1987
|
const posEntries = posMap.get(pos);
|
|
1964
1988
|
if (posEntries.title === void 0)
|
|
1965
1989
|
posEntries.title = /* @__PURE__ */ new Map();
|
|
1966
|
-
const
|
|
1990
|
+
const entryList = posEntries.title.get(
|
|
1967
1991
|
te.word
|
|
1968
1992
|
);
|
|
1969
|
-
if (
|
|
1993
|
+
if (entryList !== void 0) entryList.push(te);
|
|
1970
1994
|
else posEntries.title.set(te.word, [te]);
|
|
1971
1995
|
}
|
|
1972
1996
|
for (const ft of fge)
|
|
@@ -1974,8 +1998,8 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1974
1998
|
const posEntries = posMap.get(pos);
|
|
1975
1999
|
if (posEntries.formTitle === void 0)
|
|
1976
2000
|
posEntries.formTitle = /* @__PURE__ */ new Map();
|
|
1977
|
-
const
|
|
1978
|
-
if (
|
|
2001
|
+
const entryList = posEntries.formTitle.get(ft.word);
|
|
2002
|
+
if (entryList !== void 0) entryList.push(ft);
|
|
1979
2003
|
else posEntries.formTitle.set(ft.word, [ft]);
|
|
1980
2004
|
}
|
|
1981
2005
|
for (const wf of wfe)
|
|
@@ -1983,10 +2007,10 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1983
2007
|
const posEntries = posMap.get(pos);
|
|
1984
2008
|
if (posEntries.form === void 0)
|
|
1985
2009
|
posEntries.form = /* @__PURE__ */ new Map();
|
|
1986
|
-
const
|
|
2010
|
+
const entryList = posEntries.form.get(
|
|
1987
2011
|
wf.word
|
|
1988
2012
|
);
|
|
1989
|
-
if (
|
|
2013
|
+
if (entryList !== void 0) entryList.push(wf);
|
|
1990
2014
|
else posEntries.form.set(wf.word, [wf]);
|
|
1991
2015
|
}
|
|
1992
2016
|
}
|
|
@@ -1999,7 +2023,7 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
1999
2023
|
for (const m of word.meanings)
|
|
2000
2024
|
for (const note of m.partOfSpeech) {
|
|
2001
2025
|
const noteEntry = noteMap.get(note);
|
|
2002
|
-
if (noteEntry
|
|
2026
|
+
if ((noteEntry == null ? void 0 : noteEntry.length) === 3) {
|
|
2003
2027
|
const notePos = noteEntry[2];
|
|
2004
2028
|
if (Array.isArray(notePos))
|
|
2005
2029
|
for (const pos of notePos) {
|
|
@@ -2016,24 +2040,21 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2016
2040
|
if (poses.size > 0)
|
|
2017
2041
|
for (const pos of poses) {
|
|
2018
2042
|
const posEntries = posMap.get(pos);
|
|
2019
|
-
if (rkf.kanjiForms)
|
|
2043
|
+
if (rkf.kanjiForms !== void 0)
|
|
2020
2044
|
for (const kf of rkf.kanjiForms) {
|
|
2021
2045
|
const te = (_a = posEntries.title) == null ? void 0 : _a.get(kf);
|
|
2022
2046
|
const fe = (_b = posEntries.form) == null ? void 0 : _b.get(kf);
|
|
2023
|
-
if (te)
|
|
2047
|
+
if (te !== void 0)
|
|
2024
2048
|
entriesWithTitles.push(
|
|
2025
2049
|
...te.filter(
|
|
2026
2050
|
(ent) => validFormOfEntries.has(ent.word) || validGlossesEntries.has(ent.word) || validFormsEntries.has(ent.word)
|
|
2027
2051
|
)
|
|
2028
2052
|
);
|
|
2029
|
-
if (fe)
|
|
2053
|
+
if (fe !== void 0)
|
|
2030
2054
|
entriesWithForms.push(
|
|
2031
2055
|
...fe.filter(
|
|
2032
|
-
(ent) => ent.forms && ent.forms.some(
|
|
2033
|
-
(form) =>
|
|
2034
|
-
var _a2;
|
|
2035
|
-
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2036
|
-
}
|
|
2056
|
+
(ent) => ent.forms !== void 0 && ent.forms.some(
|
|
2057
|
+
(form) => rkf.kanjiForms !== void 0 && rkf.kanjiForms.has(form) || rkf.readings.has(form)
|
|
2037
2058
|
)
|
|
2038
2059
|
)
|
|
2039
2060
|
);
|
|
@@ -2042,50 +2063,41 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2042
2063
|
const te = (_c = posEntries.title) == null ? void 0 : _c.get(r);
|
|
2043
2064
|
const fe = (_d = posEntries.form) == null ? void 0 : _d.get(r);
|
|
2044
2065
|
const fte = (_e = posEntries.formTitle) == null ? void 0 : _e.get(r);
|
|
2045
|
-
if (te)
|
|
2066
|
+
if (te !== void 0)
|
|
2046
2067
|
entriesWithTitles.push(
|
|
2047
2068
|
...te.filter(
|
|
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
|
-
}
|
|
2069
|
+
(ent) => ent.forms !== void 0 && ent.forms.some(
|
|
2070
|
+
(form) => rkf.kanjiForms !== void 0 && rkf.kanjiForms.has(form) || rkf.readings.has(form)
|
|
2053
2071
|
)
|
|
2054
2072
|
)
|
|
2055
2073
|
);
|
|
2056
|
-
if (fe)
|
|
2074
|
+
if (fe !== void 0)
|
|
2057
2075
|
entriesWithForms.push(
|
|
2058
2076
|
...fe.filter(
|
|
2059
|
-
(ent) => ent.forms && ent.forms.some(
|
|
2060
|
-
(form) =>
|
|
2061
|
-
var _a2;
|
|
2062
|
-
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2063
|
-
}
|
|
2077
|
+
(ent) => ent.forms !== void 0 && ent.forms.some(
|
|
2078
|
+
(form) => rkf.kanjiForms !== void 0 && rkf.kanjiForms.has(form) || rkf.readings.has(form)
|
|
2064
2079
|
)
|
|
2065
2080
|
)
|
|
2066
2081
|
);
|
|
2067
|
-
if (fte) entriesWithFormTitles.push(...fte);
|
|
2082
|
+
if (fte !== void 0) entriesWithFormTitles.push(...fte);
|
|
2068
2083
|
}
|
|
2069
2084
|
}
|
|
2070
2085
|
if (entriesWithTitles.length === 0 && entriesWithFormTitles.length === 0 && entriesWithForms.length === 0) {
|
|
2071
|
-
if (rkf.kanjiForms)
|
|
2086
|
+
if (rkf.kanjiForms !== void 0)
|
|
2072
2087
|
for (const kf of rkf.kanjiForms) {
|
|
2073
2088
|
const te = validTitleEntries.get(kf);
|
|
2074
2089
|
const fe = entriesWithFormsGlobal.get(kf);
|
|
2075
|
-
if (te)
|
|
2090
|
+
if (te !== void 0)
|
|
2076
2091
|
entriesWithTitles.push(
|
|
2077
2092
|
...te.filter(
|
|
2078
2093
|
(ent) => validFormOfEntries.has(ent.word) || validGlossesEntries.has(ent.word) || validFormsEntries.has(ent.word)
|
|
2079
2094
|
)
|
|
2080
2095
|
);
|
|
2081
|
-
if (fe)
|
|
2096
|
+
if (fe !== void 0)
|
|
2082
2097
|
entriesWithForms.push(
|
|
2083
2098
|
...fe.filter(
|
|
2084
|
-
(ent) => ent.forms && ent.forms.some(
|
|
2085
|
-
(form) =>
|
|
2086
|
-
var _a2;
|
|
2087
|
-
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2088
|
-
}
|
|
2099
|
+
(ent) => ent.forms !== void 0 && ent.forms.some(
|
|
2100
|
+
(form) => rkf.kanjiForms !== void 0 && rkf.kanjiForms.has(form) || rkf.readings.has(form)
|
|
2089
2101
|
)
|
|
2090
2102
|
)
|
|
2091
2103
|
);
|
|
@@ -2094,37 +2106,31 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2094
2106
|
const te = validTitleEntries.get(r);
|
|
2095
2107
|
const fe = entriesWithFormsGlobal.get(r);
|
|
2096
2108
|
const fte = entriesWithFormTitlesGlobal.get(r);
|
|
2097
|
-
if (te)
|
|
2109
|
+
if (te !== void 0)
|
|
2098
2110
|
entriesWithTitles.push(
|
|
2099
2111
|
...te.filter(
|
|
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
|
-
}
|
|
2112
|
+
(ent) => ent.forms !== void 0 && ent.forms.some(
|
|
2113
|
+
(form) => rkf.kanjiForms !== void 0 && rkf.kanjiForms.has(form) || rkf.readings.has(form)
|
|
2105
2114
|
)
|
|
2106
2115
|
)
|
|
2107
2116
|
);
|
|
2108
|
-
if (fe)
|
|
2117
|
+
if (fe !== void 0)
|
|
2109
2118
|
entriesWithForms.push(
|
|
2110
2119
|
...fe.filter(
|
|
2111
|
-
(ent) => ent.forms && ent.forms.some(
|
|
2112
|
-
(form) =>
|
|
2113
|
-
var _a2;
|
|
2114
|
-
return ((_a2 = rkf.kanjiForms) == null ? void 0 : _a2.has(form)) || rkf.readings.has(form);
|
|
2115
|
-
}
|
|
2120
|
+
(ent) => ent.forms !== void 0 && ent.forms.some(
|
|
2121
|
+
(form) => rkf.kanjiForms !== void 0 && rkf.kanjiForms.has(form) || rkf.readings.has(form)
|
|
2116
2122
|
)
|
|
2117
2123
|
)
|
|
2118
2124
|
);
|
|
2119
|
-
if (fte) entriesWithFormTitles.push(...fte);
|
|
2125
|
+
if (fte !== void 0) entriesWithFormTitles.push(...fte);
|
|
2120
2126
|
}
|
|
2121
2127
|
}
|
|
2122
2128
|
if (entriesWithTitles.length > 0 && (entriesWithFormTitles.length > 0 || entriesWithForms.length > 0))
|
|
2123
2129
|
wordEntriesPairs.push({
|
|
2124
2130
|
word,
|
|
2125
2131
|
readings: rkf.readings,
|
|
2126
|
-
...rkf.kanjiForms ? { kanjiForms: rkf.kanjiForms } : {},
|
|
2127
|
-
forms: rkf.kanjiForms ? rkf.readings.union(rkf.kanjiForms) : rkf.readings,
|
|
2132
|
+
...rkf.kanjiForms !== void 0 ? { kanjiForms: rkf.kanjiForms } : {},
|
|
2133
|
+
forms: rkf.kanjiForms !== void 0 ? rkf.readings.union(rkf.kanjiForms) : rkf.readings,
|
|
2128
2134
|
entriesWithTitles,
|
|
2129
2135
|
entriesWithFormTitles,
|
|
2130
2136
|
entriesWithForms
|
|
@@ -2139,36 +2145,31 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2139
2145
|
const refsMap = /* @__PURE__ */ new Map();
|
|
2140
2146
|
const forms = /* @__PURE__ */ new Set();
|
|
2141
2147
|
for (const ent of pair.entriesWithTitles) {
|
|
2142
|
-
const
|
|
2143
|
-
const
|
|
2144
|
-
const validForms2 = validFormsEntries.has(ent.word);
|
|
2148
|
+
const hasValidFormOf = validFormOfEntries.has(ent.word);
|
|
2149
|
+
const hasValidForms = validFormsEntries.has(ent.word);
|
|
2145
2150
|
const hasForms = ent.forms !== void 0 && ent.forms.some((form) => pair.forms.has(form));
|
|
2146
|
-
if (pair.kanjiForms && pair.kanjiForms.has(ent.word)
|
|
2151
|
+
if (pair.kanjiForms !== void 0 && pair.kanjiForms.has(ent.word)) {
|
|
2147
2152
|
kanjiFormEntries.push(ent);
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
}
|
|
2158
|
-
}
|
|
2159
|
-
if (validGlosses) {
|
|
2160
|
-
for (const gloss of sense.glosses)
|
|
2161
|
-
if (gloss.includes("\u8868\u8A18") || gloss.includes("\u53C2\u7167")) {
|
|
2162
|
-
for (const f of pair.forms)
|
|
2163
|
-
if (gloss.includes(f)) {
|
|
2164
|
-
const elem = refsMap.get(f);
|
|
2165
|
-
if (!elem) refsMap.set(f, /* @__PURE__ */ new Set([ent.word]));
|
|
2166
|
-
else elem.add(ent.word);
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2169
|
-
}
|
|
2153
|
+
for (const sense of ent.senses) {
|
|
2154
|
+
if (hasValidFormOf && sense.form_of !== void 0) {
|
|
2155
|
+
for (const form of sense.form_of)
|
|
2156
|
+
if (pair.forms.has(form)) {
|
|
2157
|
+
const elem = titleFormMap.get(form);
|
|
2158
|
+
if (elem === void 0)
|
|
2159
|
+
titleFormMap.set(form, /* @__PURE__ */ new Set([ent.word]));
|
|
2160
|
+
else elem.add(ent.word);
|
|
2161
|
+
}
|
|
2170
2162
|
}
|
|
2171
|
-
|
|
2163
|
+
for (const gloss of sense.glosses)
|
|
2164
|
+
for (const f of pair.forms)
|
|
2165
|
+
if (gloss.includes(f)) {
|
|
2166
|
+
const elem = refsMap.get(f);
|
|
2167
|
+
if (elem === void 0)
|
|
2168
|
+
refsMap.set(f, /* @__PURE__ */ new Set([ent.word]));
|
|
2169
|
+
else elem.add(ent.word);
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
if (hasValidForms && ent.forms !== void 0) {
|
|
2172
2173
|
for (const form of ent.forms)
|
|
2173
2174
|
if (pair.forms.has(form)) forms.add(form);
|
|
2174
2175
|
}
|
|
@@ -2179,7 +2180,7 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2179
2180
|
}
|
|
2180
2181
|
for (const entry of pair.entriesWithForms) {
|
|
2181
2182
|
const elem = titleFormMap.get(entry.word);
|
|
2182
|
-
if (elem && entry.forms && entry.forms.some((form) => elem.has(form)))
|
|
2183
|
+
if (elem !== void 0 && entry.forms !== void 0 && entry.forms.some((form) => elem.has(form)))
|
|
2183
2184
|
entriesWithForms.push(entry);
|
|
2184
2185
|
}
|
|
2185
2186
|
for (const entry of pair.entriesWithFormTitles) {
|
|
@@ -2188,7 +2189,8 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2188
2189
|
continue;
|
|
2189
2190
|
}
|
|
2190
2191
|
const ft = refsMap.get(entry.word);
|
|
2191
|
-
if (ft && !ft.isDisjointFrom(pair.forms))
|
|
2192
|
+
if (ft !== void 0 && !ft.isDisjointFrom(pair.forms))
|
|
2193
|
+
entriesWithForms.push(entry);
|
|
2192
2194
|
}
|
|
2193
2195
|
if (kanjiFormEntries.length > 0) {
|
|
2194
2196
|
for (const entry of kanjiFormEntries)
|
|
@@ -2205,7 +2207,14 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2205
2207
|
japaneseDefinitions.push({
|
|
2206
2208
|
wordID: pair.word.id,
|
|
2207
2209
|
definitions,
|
|
2208
|
-
wordForms: pair.forms
|
|
2210
|
+
wordForms: pair.forms.union(
|
|
2211
|
+
new Set(
|
|
2212
|
+
pair.forms.values().toArray().flatMap((form) => [
|
|
2213
|
+
hiraganaToKatakana(form),
|
|
2214
|
+
katakanaToHiragana(form)
|
|
2215
|
+
])
|
|
2216
|
+
)
|
|
2217
|
+
)
|
|
2209
2218
|
});
|
|
2210
2219
|
}
|
|
2211
2220
|
for (let i = 0; i < japaneseDefinitions.length; i++) {
|
|
@@ -2214,14 +2223,14 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2214
2223
|
const defCount = definitionMap.get(
|
|
2215
2224
|
pair.definitions[j].definition
|
|
2216
2225
|
);
|
|
2217
|
-
if (defCount && defCount.count > 1) {
|
|
2226
|
+
if (defCount !== void 0 && defCount.count > 1) {
|
|
2218
2227
|
let mnba = true;
|
|
2219
2228
|
for (const f of pair.wordForms)
|
|
2220
2229
|
if (pair.definitions[j].definition.includes(f)) {
|
|
2221
2230
|
mnba = false;
|
|
2222
2231
|
break;
|
|
2223
2232
|
}
|
|
2224
|
-
|
|
2233
|
+
pair.definitions[j].mayNotBeAccurate = mnba ? 2 : 1;
|
|
2225
2234
|
}
|
|
2226
2235
|
}
|
|
2227
2236
|
delete pair.wordForms;
|
|
@@ -2230,33 +2239,30 @@ function getWordDefinitions(entryList, jmDict) {
|
|
|
2230
2239
|
return japaneseDefinitions;
|
|
2231
2240
|
}
|
|
2232
2241
|
async function getWordDefinitionsWithFurigana(entryList, jmDict) {
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
pair.definitions[j].
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
}
|
|
2254
|
-
resolve(japaneseDefinitions);
|
|
2255
|
-
});
|
|
2242
|
+
const japaneseDefinitions = getWordDefinitions(
|
|
2243
|
+
entryList,
|
|
2244
|
+
jmDict
|
|
2245
|
+
);
|
|
2246
|
+
const kuroshiro = new Kuroshiro.default();
|
|
2247
|
+
await kuroshiro.init(new KuromojiAnalyzer());
|
|
2248
|
+
const convert = kuroshiro.convert.bind(kuroshiro);
|
|
2249
|
+
for (let i = 0; i < japaneseDefinitions.length; i++) {
|
|
2250
|
+
const pair = japaneseDefinitions[i];
|
|
2251
|
+
for (let j = 0; j < pair.definitions.length; j++)
|
|
2252
|
+
if (!pair.definitions[j].definition.includes("\u30FB"))
|
|
2253
|
+
pair.definitions[j].furigana = String(
|
|
2254
|
+
await convert(pair.definitions[j].definition, {
|
|
2255
|
+
to: "hiragana",
|
|
2256
|
+
mode: "furigana"
|
|
2257
|
+
})
|
|
2258
|
+
);
|
|
2259
|
+
japaneseDefinitions[i] = pair;
|
|
2260
|
+
}
|
|
2261
|
+
return japaneseDefinitions;
|
|
2256
2262
|
}
|
|
2257
2263
|
function lookupWordNote(key, notes, tags) {
|
|
2258
2264
|
const info = noteMap.get(key.toLowerCase());
|
|
2259
|
-
if (
|
|
2265
|
+
if (info === void 0) {
|
|
2260
2266
|
notes.push(key);
|
|
2261
2267
|
return { note: key };
|
|
2262
2268
|
}
|
|
@@ -2266,22 +2272,172 @@ function lookupWordNote(key, notes, tags) {
|
|
|
2266
2272
|
return { note: info[1], tag };
|
|
2267
2273
|
}
|
|
2268
2274
|
var wordAddNoteArray = (arr, cb) => {
|
|
2269
|
-
if (
|
|
2275
|
+
if (arr === void 0) return;
|
|
2270
2276
|
for (const v of arr) cb(v);
|
|
2271
2277
|
};
|
|
2272
|
-
function
|
|
2278
|
+
function getKanji(searchedKanji, dict, jmDict, svgList, noteTypeName, deckPath) {
|
|
2279
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
2280
|
+
let dictKanji = void 0;
|
|
2281
|
+
if (typeof searchedKanji === "string" && dict !== void 0)
|
|
2282
|
+
dictKanji = dict instanceof Map ? dict.get(searchedKanji) : dict.find((entry) => entry.kanji === searchedKanji);
|
|
2283
|
+
else if (typeof searchedKanji === "object") dictKanji = searchedKanji;
|
|
2284
|
+
if (dictKanji !== void 0) {
|
|
2285
|
+
const kanji = {
|
|
2286
|
+
kanji: dictKanji.kanji,
|
|
2287
|
+
strokes: dictKanji.misc.strokeNumber,
|
|
2288
|
+
...((_a = dictKanji.misc) == null ? void 0 : _a.grade) !== void 0 ? { grade: dictKanji.misc.grade } : {},
|
|
2289
|
+
...((_b = dictKanji.misc) == null ? void 0 : _b.frequency) !== void 0 ? { frequency: dictKanji.misc.frequency } : {},
|
|
2290
|
+
...((_c = dictKanji.misc) == null ? void 0 : _c.jlpt) !== void 0 ? { jlpt: dictKanji.misc.jlpt } : {},
|
|
2291
|
+
noteID: `kanji_${dictKanji.kanji}`,
|
|
2292
|
+
...noteTypeName !== void 0 ? { noteTypeName } : {},
|
|
2293
|
+
...deckPath !== void 0 ? { deckPath } : {},
|
|
2294
|
+
tags: []
|
|
2295
|
+
};
|
|
2296
|
+
if (dictKanji.readingMeaning !== void 0 && dictKanji.readingMeaning.length > 0) {
|
|
2297
|
+
const meanings = [];
|
|
2298
|
+
const nanori = [];
|
|
2299
|
+
const onyomi = [];
|
|
2300
|
+
const kunyomi = [];
|
|
2301
|
+
for (const rm of dictKanji.readingMeaning) {
|
|
2302
|
+
if (rm.nanori !== void 0 && rm.nanori.length > 0)
|
|
2303
|
+
nanori.push(...rm.nanori);
|
|
2304
|
+
for (const group of rm.groups) {
|
|
2305
|
+
if (group.readings !== void 0) {
|
|
2306
|
+
onyomi.push(
|
|
2307
|
+
...group.readings.filter((reading) => reading.type === "ja_on").map((reading) => reading.reading)
|
|
2308
|
+
);
|
|
2309
|
+
kunyomi.push(
|
|
2310
|
+
...group.readings.filter(
|
|
2311
|
+
(reading) => reading.type === "ja_kun"
|
|
2312
|
+
).map((reading) => reading.reading)
|
|
2313
|
+
);
|
|
2314
|
+
}
|
|
2315
|
+
if (group.meanings !== void 0 && group.meanings.length > 0)
|
|
2316
|
+
meanings.push(...group.meanings);
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
if (meanings.length > 0) kanji.meanings = meanings;
|
|
2320
|
+
if (nanori.length > 0) kanji.nanori = nanori;
|
|
2321
|
+
if (onyomi.length > 0) kanji.onyomi = onyomi;
|
|
2322
|
+
if (kunyomi.length > 0) kanji.kunyomi = kunyomi;
|
|
2323
|
+
}
|
|
2324
|
+
if (jmDict !== void 0) {
|
|
2325
|
+
let kanjiWords = jmDict instanceof Map ? jmDict.get(kanji.kanji) : jmDict;
|
|
2326
|
+
const firstKfWords = kanjiWords == null ? void 0 : kanjiWords.filter(
|
|
2327
|
+
(word) => word.kanjiForms !== void 0 && word.kanjiForms[0].form.includes(kanji.kanji)
|
|
2328
|
+
);
|
|
2329
|
+
if (firstKfWords !== void 0 && firstKfWords.length > 0)
|
|
2330
|
+
kanjiWords = firstKfWords;
|
|
2331
|
+
if (kanjiWords !== void 0) {
|
|
2332
|
+
const validWords = [];
|
|
2333
|
+
for (const word of kanjiWords) {
|
|
2334
|
+
const kanjiForm = (_d = firstKfWords !== void 0 && firstKfWords.length > 0 ? word.kanjiForms[0] : word.kanjiForms.find(
|
|
2335
|
+
(kf) => kf.form.includes(kanji.kanji)
|
|
2336
|
+
)) == null ? void 0 : _d.form;
|
|
2337
|
+
if (kanjiForm !== void 0) {
|
|
2338
|
+
const reading = (_e = firstKfWords !== void 0 && firstKfWords.length > 0 ? word.readings[0] : word.readings.find(
|
|
2339
|
+
(r) => r.kanjiFormRestrictions !== void 0 && r.kanjiFormRestrictions.includes(kanjiForm)
|
|
2340
|
+
)) == null ? void 0 : _e.reading;
|
|
2341
|
+
if (reading === void 0) continue;
|
|
2342
|
+
const translation = (_f = firstKfWords !== void 0 && firstKfWords.length > 0 ? word.meanings[0] : word.meanings.find(
|
|
2343
|
+
(m) => m.kanjiFormRestrictions !== void 0 && m.kanjiFormRestrictions.includes(kanjiForm)
|
|
2344
|
+
)) == null ? void 0 : _f.translations.map(
|
|
2345
|
+
(t) => typeof t === "string" ? t : t.translation
|
|
2346
|
+
)[0];
|
|
2347
|
+
if (translation === void 0) continue;
|
|
2348
|
+
validWords.push({
|
|
2349
|
+
kanjiForms: [{ kanjiForm }],
|
|
2350
|
+
readings: [{ reading }],
|
|
2351
|
+
translations: [
|
|
2352
|
+
{
|
|
2353
|
+
translation
|
|
2354
|
+
}
|
|
2355
|
+
]
|
|
2356
|
+
});
|
|
2357
|
+
}
|
|
2358
|
+
if (validWords.length === 3) break;
|
|
2359
|
+
}
|
|
2360
|
+
if (validWords.length > 0) kanji.words = validWords;
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
if (svgList !== void 0) {
|
|
2364
|
+
const codePoint = kanji.kanji.codePointAt(0).toString(16).toLowerCase();
|
|
2365
|
+
const svg = svgList instanceof Map ? svgList.get(kanji.kanji) : svgList.find(
|
|
2366
|
+
(svgFile) => [`${codePoint}.svg`, `0${codePoint}.svg`].includes(
|
|
2367
|
+
svgFile.toLowerCase()
|
|
2368
|
+
)
|
|
2369
|
+
);
|
|
2370
|
+
if (svg !== void 0) kanji.svg = svg;
|
|
2371
|
+
}
|
|
2372
|
+
if (dictKanji.isKokuji === true) {
|
|
2373
|
+
kanji.kokuji = true;
|
|
2374
|
+
kanji.tags.push("kanji::kokuji");
|
|
2375
|
+
}
|
|
2376
|
+
kanji.tags.push(
|
|
2377
|
+
`kanji::strokes::${kanji.strokes}`,
|
|
2378
|
+
...kanji.frequency !== void 0 ? [`kanji::frequency::${kanji.frequency}`] : [],
|
|
2379
|
+
...kanji.grade !== void 0 ? [`kanji::grade::${kanji.grade}`] : [],
|
|
2380
|
+
...kanji.jlpt !== void 0 ? [`kanji::pre-2010_jlpt::${kanji.jlpt.toLowerCase()}`] : [],
|
|
2381
|
+
`kanji::onyomi::${(_h = (_g = kanji.onyomi) == null ? void 0 : _g.length) != null ? _h : 0}`,
|
|
2382
|
+
`kanji::kunyomi::${(_j = (_i = kanji.kunyomi) == null ? void 0 : _i.length) != null ? _j : 0}`,
|
|
2383
|
+
`kanji::nanori::${(_l = (_k = kanji.nanori) == null ? void 0 : _k.length) != null ? _l : 0}`,
|
|
2384
|
+
`kanji::words::${(_n = (_m = kanji.words) == null ? void 0 : _m.length) != null ? _n : 0}`,
|
|
2385
|
+
...kanji.svg !== void 0 ? ["kanji::has_svg"] : []
|
|
2386
|
+
);
|
|
2387
|
+
return kanji;
|
|
2388
|
+
} else return void 0;
|
|
2389
|
+
}
|
|
2390
|
+
function getKanjiExtended(info, kanji, dict, useWords, jmDict, svgList, noteTypeName, deckPath, sourceURL) {
|
|
2391
|
+
const kanjiObj = getKanji(
|
|
2392
|
+
kanji,
|
|
2393
|
+
dict,
|
|
2394
|
+
jmDict,
|
|
2395
|
+
svgList,
|
|
2396
|
+
noteTypeName,
|
|
2397
|
+
deckPath
|
|
2398
|
+
);
|
|
2399
|
+
if (kanjiObj !== void 0) {
|
|
2400
|
+
let usedInfo = false;
|
|
2401
|
+
if (info.components !== void 0) {
|
|
2402
|
+
kanjiObj.components = info.components;
|
|
2403
|
+
kanjiObj.tags.push(`kanji::components::${kanjiObj.components.length}`);
|
|
2404
|
+
usedInfo = true;
|
|
2405
|
+
}
|
|
2406
|
+
if (info.mnemonic !== void 0 && info.mnemonic.length > 0) {
|
|
2407
|
+
kanjiObj.mnemonic = info.mnemonic;
|
|
2408
|
+
kanjiObj.tags.push("kanji::has_mnemonic");
|
|
2409
|
+
usedInfo = true;
|
|
2410
|
+
}
|
|
2411
|
+
if (useWords === true && info.words !== void 0 && info.words.length > 0) {
|
|
2412
|
+
kanjiObj.words = info.words;
|
|
2413
|
+
kanjiObj.tags.forEach((tag, index) => {
|
|
2414
|
+
if (tag.startsWith("kanji::words::") && kanjiObj.words !== void 0)
|
|
2415
|
+
kanjiObj.tags.splice(
|
|
2416
|
+
index,
|
|
2417
|
+
1,
|
|
2418
|
+
`kanji::words::${kanjiObj.words.length}`
|
|
2419
|
+
);
|
|
2420
|
+
});
|
|
2421
|
+
usedInfo = true;
|
|
2422
|
+
}
|
|
2423
|
+
if (sourceURL !== void 0 && info.externalInfo === true && usedInfo)
|
|
2424
|
+
kanjiObj.source = sourceURL;
|
|
2425
|
+
return kanjiObj;
|
|
2426
|
+
} else return void 0;
|
|
2427
|
+
}
|
|
2428
|
+
function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeName, deckPath) {
|
|
2273
2429
|
var _a, _b;
|
|
2274
2430
|
let dictWord = void 0;
|
|
2275
|
-
if (typeof
|
|
2431
|
+
if (typeof searchedWord === "string" && dict !== void 0) {
|
|
2276
2432
|
if (Array.isArray(dict))
|
|
2277
2433
|
dictWord = dict.find(
|
|
2278
|
-
(entry) => entry.id ===
|
|
2434
|
+
(entry) => entry.id === searchedWord
|
|
2279
2435
|
);
|
|
2280
|
-
if (dict instanceof Map) dictWord = dict.get(
|
|
2436
|
+
if (dict instanceof Map) dictWord = dict.get(searchedWord);
|
|
2281
2437
|
}
|
|
2282
|
-
if (typeof
|
|
2283
|
-
if (dictWord) {
|
|
2284
|
-
const
|
|
2438
|
+
if (typeof searchedWord === "object") dictWord = searchedWord;
|
|
2439
|
+
if (dictWord !== void 0) {
|
|
2440
|
+
const word = {
|
|
2285
2441
|
id: dictWord.id,
|
|
2286
2442
|
readings: [],
|
|
2287
2443
|
translations: [],
|
|
@@ -2291,46 +2447,46 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2291
2447
|
tags: []
|
|
2292
2448
|
};
|
|
2293
2449
|
if (dictWord.isCommon === true) {
|
|
2294
|
-
|
|
2295
|
-
|
|
2450
|
+
word.common = true;
|
|
2451
|
+
word.tags.push("word::common");
|
|
2296
2452
|
}
|
|
2297
|
-
if (dictWord.kanjiForms)
|
|
2298
|
-
|
|
2453
|
+
if (dictWord.kanjiForms !== void 0)
|
|
2454
|
+
word.kanjiForms = dictWord.kanjiForms.map(
|
|
2299
2455
|
(dictKanjiForm) => ({
|
|
2300
2456
|
kanjiForm: dictKanjiForm.form,
|
|
2301
|
-
...dictKanjiForm.notes ? {
|
|
2457
|
+
...dictKanjiForm.notes !== void 0 ? {
|
|
2302
2458
|
notes: dictKanjiForm.notes.map((note) => {
|
|
2303
2459
|
const noteAndTag = lookupWordNote(
|
|
2304
2460
|
note,
|
|
2305
2461
|
[],
|
|
2306
|
-
|
|
2462
|
+
word.tags
|
|
2307
2463
|
);
|
|
2308
2464
|
return capitalizeString(noteAndTag.note);
|
|
2309
2465
|
})
|
|
2310
2466
|
} : {},
|
|
2311
|
-
...dictKanjiForm.commonness && dictKanjiForm.commonness.length > 0 ? { common: true } : {}
|
|
2467
|
+
...dictKanjiForm.commonness !== void 0 && dictKanjiForm.commonness.length > 0 ? { common: true } : {}
|
|
2312
2468
|
})
|
|
2313
2469
|
);
|
|
2314
|
-
|
|
2470
|
+
word.readings = dictWord.readings.map((dictReading) => ({
|
|
2315
2471
|
reading: dictReading.reading,
|
|
2316
|
-
...dictReading.kanjiFormRestrictions || dictReading.notes ? {
|
|
2472
|
+
...dictReading.kanjiFormRestrictions !== void 0 || dictReading.notes !== void 0 ? {
|
|
2317
2473
|
notes: [
|
|
2318
|
-
...dictReading.kanjiFormRestrictions ? dictReading.kanjiFormRestrictions.map(
|
|
2474
|
+
...dictReading.kanjiFormRestrictions !== void 0 ? dictReading.kanjiFormRestrictions.map(
|
|
2319
2475
|
(restriction) => `Reading restricted to ${restriction}`
|
|
2320
2476
|
) : [],
|
|
2321
|
-
...dictReading.notes ? dictReading.notes.map((note) => {
|
|
2477
|
+
...dictReading.notes !== void 0 ? dictReading.notes.map((note) => {
|
|
2322
2478
|
const noteAndTag = lookupWordNote(
|
|
2323
2479
|
note,
|
|
2324
2480
|
[],
|
|
2325
|
-
|
|
2481
|
+
word.tags
|
|
2326
2482
|
);
|
|
2327
2483
|
return capitalizeString(noteAndTag.note);
|
|
2328
2484
|
}) : []
|
|
2329
2485
|
]
|
|
2330
2486
|
} : {},
|
|
2331
|
-
...dictReading.commonness && dictReading.commonness.length > 0 ? { common: true } : {}
|
|
2487
|
+
...dictReading.commonness !== void 0 && dictReading.commonness.length > 0 ? { common: true } : {}
|
|
2332
2488
|
}));
|
|
2333
|
-
|
|
2489
|
+
word.translations = [];
|
|
2334
2490
|
for (const dictMeaning of dictWord.meanings) {
|
|
2335
2491
|
const translationTypes = [];
|
|
2336
2492
|
const translations = dictMeaning.translations.map(
|
|
@@ -2341,7 +2497,7 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2341
2497
|
translation.type
|
|
2342
2498
|
);
|
|
2343
2499
|
translationTypes.push(translationNoteAndTag[1]);
|
|
2344
|
-
|
|
2500
|
+
word.tags.push(`word::${translationNoteAndTag[0]}`);
|
|
2345
2501
|
return translation.translation;
|
|
2346
2502
|
}
|
|
2347
2503
|
}
|
|
@@ -2358,15 +2514,15 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2358
2514
|
for (const t of translationTypes) notes.push(t);
|
|
2359
2515
|
wordAddNoteArray(
|
|
2360
2516
|
dictMeaning.partOfSpeech,
|
|
2361
|
-
(pos) => lookupWordNote(pos, notes,
|
|
2517
|
+
(pos) => lookupWordNote(pos, notes, word.tags)
|
|
2362
2518
|
);
|
|
2363
2519
|
wordAddNoteArray(
|
|
2364
2520
|
dictMeaning.fields,
|
|
2365
|
-
(field) => lookupWordNote(field, notes,
|
|
2521
|
+
(field) => lookupWordNote(field, notes, word.tags)
|
|
2366
2522
|
);
|
|
2367
2523
|
wordAddNoteArray(
|
|
2368
2524
|
dictMeaning.dialects,
|
|
2369
|
-
(dialect) => lookupWordNote(dialect, notes,
|
|
2525
|
+
(dialect) => lookupWordNote(dialect, notes, word.tags)
|
|
2370
2526
|
);
|
|
2371
2527
|
wordAddNoteArray(
|
|
2372
2528
|
dictMeaning.antonyms,
|
|
@@ -2378,45 +2534,45 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2378
2534
|
);
|
|
2379
2535
|
wordAddNoteArray(
|
|
2380
2536
|
dictMeaning.info,
|
|
2381
|
-
(info) => lookupWordNote(info, notes,
|
|
2537
|
+
(info) => lookupWordNote(info, notes, word.tags)
|
|
2382
2538
|
);
|
|
2383
2539
|
wordAddNoteArray(
|
|
2384
2540
|
dictMeaning.misc,
|
|
2385
|
-
(misc) => lookupWordNote(misc, notes,
|
|
2541
|
+
(misc) => lookupWordNote(misc, notes, word.tags)
|
|
2386
2542
|
);
|
|
2387
2543
|
for (let i = 0; i < notes.length; i++)
|
|
2388
2544
|
notes[i] = capitalizeString(notes[i]);
|
|
2389
|
-
|
|
2545
|
+
word.translations.push({
|
|
2390
2546
|
translation: translations.join("; "),
|
|
2391
2547
|
notes
|
|
2392
2548
|
});
|
|
2393
2549
|
}
|
|
2394
2550
|
if (dictWord.usuallyInKana === true) {
|
|
2395
|
-
|
|
2396
|
-
|
|
2551
|
+
word.usuallyInKana = true;
|
|
2552
|
+
word.tags.push("word::usually_in_kana_for_all_senses");
|
|
2397
2553
|
}
|
|
2398
|
-
if (kanjiDic &&
|
|
2554
|
+
if (kanjiDic !== void 0 && word.kanjiForms !== void 0) {
|
|
2399
2555
|
const kanji = [];
|
|
2400
2556
|
const seenChars = /* @__PURE__ */ new Set();
|
|
2401
|
-
for (const kanjiForm of
|
|
2557
|
+
for (const kanjiForm of word.kanjiForms)
|
|
2402
2558
|
for (const char of kanjiForm.kanjiForm.split("").filter((c) => regexps.kanji.test(c))) {
|
|
2403
2559
|
if (seenChars.has(char)) continue;
|
|
2404
2560
|
seenChars.add(char);
|
|
2405
2561
|
const kanjiEntry = kanjiDic instanceof Map ? kanjiDic.get(char) : void 0;
|
|
2406
2562
|
const kanjiObj = getKanji(
|
|
2407
2563
|
kanjiEntry != null ? kanjiEntry : char,
|
|
2408
|
-
|
|
2564
|
+
!(kanjiDic instanceof Map) ? kanjiDic : void 0
|
|
2409
2565
|
);
|
|
2410
|
-
if (kanjiObj)
|
|
2566
|
+
if (kanjiObj !== void 0)
|
|
2411
2567
|
kanji.push({
|
|
2412
2568
|
kanji: kanjiObj.kanji,
|
|
2413
|
-
...kanjiObj.meanings && kanjiObj.meanings.length > 0 ? { meanings: kanjiObj.meanings } : {}
|
|
2569
|
+
...kanjiObj.meanings !== void 0 && kanjiObj.meanings.length > 0 ? { meanings: kanjiObj.meanings } : {}
|
|
2414
2570
|
});
|
|
2415
2571
|
}
|
|
2416
|
-
if (kanji.length > 0)
|
|
2572
|
+
if (kanji.length > 0) word.kanji = kanji;
|
|
2417
2573
|
}
|
|
2418
|
-
if (dictWord.hasPhrases !== void 0
|
|
2419
|
-
const exampleList =
|
|
2574
|
+
if (dictWord.hasPhrases === true && examples !== void 0) {
|
|
2575
|
+
const exampleList = examples instanceof Map ? (_a = examples.get(dictWord.id)) != null ? _a : [] : examples;
|
|
2420
2576
|
const rkf = getValidForms(
|
|
2421
2577
|
dictWord.readings,
|
|
2422
2578
|
dictWord.kanjiForms,
|
|
@@ -2425,7 +2581,7 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2425
2581
|
const readings = new Set(
|
|
2426
2582
|
rkf.readings.map((r) => r.reading)
|
|
2427
2583
|
);
|
|
2428
|
-
const kanjiForms = rkf.kanjiForms ? new Set(rkf.kanjiForms.map((kf) => kf.form)) : void 0;
|
|
2584
|
+
const kanjiForms = rkf.kanjiForms !== void 0 ? new Set(rkf.kanjiForms.map((kf) => kf.form)) : void 0;
|
|
2429
2585
|
let kanjiFormExamples = [];
|
|
2430
2586
|
const readingMatchingKanjiFormExamples = [];
|
|
2431
2587
|
const readingExamples = [];
|
|
@@ -2436,7 +2592,7 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2436
2592
|
const readingAsReadingMatch = part.reading !== void 0 && readings.has(part.reading);
|
|
2437
2593
|
const readingAsInflectedFormMatch = part.inflectedForm !== void 0 && readings.has(part.inflectedForm);
|
|
2438
2594
|
const referenceIDMatch = part.referenceID === dictWord.id;
|
|
2439
|
-
if (kanjiForms && kanjiForms.has(part.baseForm) || referenceIDMatch) {
|
|
2595
|
+
if (kanjiForms !== void 0 && kanjiForms.has(part.baseForm) || referenceIDMatch) {
|
|
2440
2596
|
if (readingAsReadingMatch || readingAsInflectedFormMatch) {
|
|
2441
2597
|
readingMatchingKanjiFormExamples.push({
|
|
2442
2598
|
ex: example,
|
|
@@ -2452,16 +2608,16 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2452
2608
|
break;
|
|
2453
2609
|
}
|
|
2454
2610
|
const readingAsBaseFormMatch = readings.has(part.baseForm);
|
|
2455
|
-
if (
|
|
2611
|
+
if (readingAsBaseFormMatch && kanjiForms === void 0) {
|
|
2456
2612
|
readingExamples.push({ ex: example, partIndex: i });
|
|
2457
2613
|
break;
|
|
2458
2614
|
}
|
|
2459
2615
|
}
|
|
2460
2616
|
if (readingMatchingKanjiForms.size > 0)
|
|
2461
2617
|
kanjiFormExamples = kanjiFormExamples.filter(
|
|
2462
|
-
(ex) => ex.form && readingMatchingKanjiForms.has(ex.form)
|
|
2618
|
+
(ex) => ex.form !== void 0 && readingMatchingKanjiForms.has(ex.form)
|
|
2463
2619
|
);
|
|
2464
|
-
const includeKanjiFormExamples =
|
|
2620
|
+
const includeKanjiFormExamples = word.kanjiForms !== void 0;
|
|
2465
2621
|
let wordExamples = [
|
|
2466
2622
|
...includeKanjiFormExamples ? [...readingMatchingKanjiFormExamples, ...kanjiFormExamples] : readingExamples
|
|
2467
2623
|
];
|
|
@@ -2471,14 +2627,14 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2471
2627
|
readingMatchingKanjiForms.clear();
|
|
2472
2628
|
const glossSpecificExamples = [];
|
|
2473
2629
|
const seenPhrases = /* @__PURE__ */ new Set();
|
|
2474
|
-
for (let i = 0; i <
|
|
2630
|
+
for (let i = 0; i < word.translations.length; i++)
|
|
2475
2631
|
outer: for (const example of wordExamples) {
|
|
2476
2632
|
if (seenPhrases.has(example.ex.phrase)) continue;
|
|
2477
2633
|
for (let j = 0; j < example.ex.parts.length; j++) {
|
|
2478
2634
|
const part = example.ex.parts[j];
|
|
2479
2635
|
if (j === example.partIndex && part.glossNumber === i + 1) {
|
|
2480
2636
|
example.ex.glossNumber = {
|
|
2481
|
-
wordId:
|
|
2637
|
+
wordId: word.id,
|
|
2482
2638
|
glossNumber: i + 1
|
|
2483
2639
|
};
|
|
2484
2640
|
glossSpecificExamples.push(example);
|
|
@@ -2487,7 +2643,6 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2487
2643
|
}
|
|
2488
2644
|
}
|
|
2489
2645
|
}
|
|
2490
|
-
}
|
|
2491
2646
|
if (glossSpecificExamples.length > 0) {
|
|
2492
2647
|
if (glossSpecificExamples.length < 5) {
|
|
2493
2648
|
wordExamples = wordExamples.filter(
|
|
@@ -2502,203 +2657,59 @@ function getWord(word, dict, kanjiDic, examples, definitions, noteTypeName, deck
|
|
|
2502
2657
|
wordExamples = glossSpecificExamples;
|
|
2503
2658
|
}
|
|
2504
2659
|
if (wordExamples.length > 0) {
|
|
2505
|
-
|
|
2660
|
+
word.phrases = (glossSpecificExamples.length === 0 ? wordExamples.slice(0, 5) : wordExamples).map((ex) => {
|
|
2506
2661
|
var _a2;
|
|
2507
2662
|
return {
|
|
2508
2663
|
phrase: (_a2 = ex.ex.furigana) != null ? _a2 : ex.ex.phrase,
|
|
2509
2664
|
translation: ex.ex.translation,
|
|
2510
2665
|
originalPhrase: ex.ex.phrase,
|
|
2511
|
-
...ex.ex.glossNumber ? { glossNumber: ex.ex.glossNumber } : {}
|
|
2666
|
+
...ex.ex.glossNumber !== void 0 ? { glossNumber: ex.ex.glossNumber } : {}
|
|
2512
2667
|
};
|
|
2513
2668
|
});
|
|
2514
|
-
|
|
2669
|
+
word.tags.push("word::has_phrases");
|
|
2515
2670
|
if (glossSpecificExamples.length > 0)
|
|
2516
|
-
|
|
2671
|
+
word.tags.push("word::has_meaning-specific_phrases");
|
|
2517
2672
|
}
|
|
2518
2673
|
}
|
|
2519
|
-
if (definitions) {
|
|
2520
|
-
const defs =
|
|
2521
|
-
|
|
2522
|
-
|
|
2674
|
+
if (definitions !== void 0) {
|
|
2675
|
+
const defs = definitions instanceof Map ? definitions.get(word.id) : (_b = definitions.find(
|
|
2676
|
+
(wdp) => wdp.wordID === word.id
|
|
2677
|
+
)) == null ? void 0 : _b.definitions;
|
|
2678
|
+
if (defs !== void 0)
|
|
2679
|
+
word.definitions = [
|
|
2523
2680
|
...defs.toSorted(
|
|
2524
|
-
(a, b) =>
|
|
2681
|
+
(a, b) => {
|
|
2682
|
+
var _a2, _b2;
|
|
2683
|
+
return ((_a2 = a.mayNotBeAccurate) != null ? _a2 : 0) - ((_b2 = b.mayNotBeAccurate) != null ? _b2 : 0);
|
|
2684
|
+
}
|
|
2525
2685
|
)
|
|
2526
2686
|
];
|
|
2527
2687
|
}
|
|
2528
|
-
return
|
|
2529
|
-
} else return void 0;
|
|
2530
|
-
}
|
|
2531
|
-
function getKanji(kanji, dict, jmDict, svgList, noteTypeName, deckPath) {
|
|
2532
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2533
|
-
let dictKanji = void 0;
|
|
2534
|
-
if (typeof kanji === "string" && dict)
|
|
2535
|
-
dictKanji = Array.isArray(dict) ? dict.find((entry) => entry.kanji === kanji) : dict.get(kanji);
|
|
2536
|
-
else if (typeof kanji === "object") dictKanji = kanji;
|
|
2537
|
-
if (dictKanji) {
|
|
2538
|
-
const kanji2 = {
|
|
2539
|
-
kanji: dictKanji.kanji,
|
|
2540
|
-
strokes: dictKanji.misc.strokeNumber,
|
|
2541
|
-
...dictKanji.misc && dictKanji.misc.grade ? { grade: dictKanji.misc.grade } : {},
|
|
2542
|
-
...dictKanji.misc && dictKanji.misc.frequency ? { frequency: dictKanji.misc.frequency } : {},
|
|
2543
|
-
...dictKanji.misc && dictKanji.misc.jlpt ? { jlpt: dictKanji.misc.jlpt } : {},
|
|
2544
|
-
noteID: `kanji_${dictKanji.kanji}`,
|
|
2545
|
-
...noteTypeName ? { noteTypeName } : {},
|
|
2546
|
-
...deckPath ? { deckPath } : {},
|
|
2547
|
-
tags: []
|
|
2548
|
-
};
|
|
2549
|
-
if (dictKanji.readingMeaning && dictKanji.readingMeaning.length > 0) {
|
|
2550
|
-
const meanings = [];
|
|
2551
|
-
const nanori = [];
|
|
2552
|
-
const onyomi = [];
|
|
2553
|
-
const kunyomi = [];
|
|
2554
|
-
for (const rm of dictKanji.readingMeaning) {
|
|
2555
|
-
if (rm.nanori && rm.nanori.length > 0) nanori.push(...rm.nanori);
|
|
2556
|
-
for (const group of rm.groups) {
|
|
2557
|
-
if (group.readings) {
|
|
2558
|
-
onyomi.push(
|
|
2559
|
-
...group.readings.filter((reading) => reading.type === "ja_on").map((reading) => reading.reading)
|
|
2560
|
-
);
|
|
2561
|
-
kunyomi.push(
|
|
2562
|
-
...group.readings.filter(
|
|
2563
|
-
(reading) => reading.type === "ja_kun"
|
|
2564
|
-
).map((reading) => reading.reading)
|
|
2565
|
-
);
|
|
2566
|
-
}
|
|
2567
|
-
if (group.meanings && group.meanings.length > 0)
|
|
2568
|
-
meanings.push(...group.meanings);
|
|
2569
|
-
}
|
|
2570
|
-
}
|
|
2571
|
-
if (meanings.length > 0) kanji2.meanings = meanings;
|
|
2572
|
-
if (nanori.length > 0) kanji2.nanori = nanori;
|
|
2573
|
-
if (onyomi.length > 0) kanji2.onyomi = onyomi;
|
|
2574
|
-
if (kunyomi.length > 0) kanji2.kunyomi = kunyomi;
|
|
2575
|
-
}
|
|
2576
|
-
if (jmDict) {
|
|
2577
|
-
let kanjiWords = Array.isArray(
|
|
2578
|
-
jmDict
|
|
2579
|
-
) ? jmDict : jmDict.get(kanji2.kanji);
|
|
2580
|
-
const firstKfWords = kanjiWords == null ? void 0 : kanjiWords.filter(
|
|
2581
|
-
(word) => word.kanjiForms && word.kanjiForms[0].form.includes(kanji2.kanji)
|
|
2582
|
-
);
|
|
2583
|
-
if (firstKfWords && firstKfWords.length > 0) kanjiWords = firstKfWords;
|
|
2584
|
-
if (kanjiWords) {
|
|
2585
|
-
const validWords = [];
|
|
2586
|
-
for (const word of kanjiWords) {
|
|
2587
|
-
const kanjiForm = (_a = firstKfWords && firstKfWords.length > 0 ? word.kanjiForms[0] : word.kanjiForms.find(
|
|
2588
|
-
(kf) => kf.form.includes(kanji2.kanji)
|
|
2589
|
-
)) == null ? void 0 : _a.form;
|
|
2590
|
-
if (kanjiForm) {
|
|
2591
|
-
const reading = (_b = firstKfWords && firstKfWords.length > 0 ? word.readings[0] : word.readings.find(
|
|
2592
|
-
(reading2) => reading2.kanjiFormRestrictions && reading2.kanjiFormRestrictions.includes(kanjiForm)
|
|
2593
|
-
)) == null ? void 0 : _b.reading;
|
|
2594
|
-
if (!reading) continue;
|
|
2595
|
-
const translation = (_c = firstKfWords && firstKfWords.length > 0 ? word.meanings[0] : word.meanings.find(
|
|
2596
|
-
(m) => m.translations && m.kanjiFormRestrictions && m.kanjiFormRestrictions.includes(kanjiForm)
|
|
2597
|
-
)) == null ? void 0 : _c.translations.map(
|
|
2598
|
-
(t) => typeof t === "string" ? t : t.translation
|
|
2599
|
-
)[0];
|
|
2600
|
-
if (!translation) continue;
|
|
2601
|
-
validWords.push({
|
|
2602
|
-
kanjiForms: [{ kanjiForm }],
|
|
2603
|
-
readings: [{ reading }],
|
|
2604
|
-
translations: [
|
|
2605
|
-
{
|
|
2606
|
-
translation
|
|
2607
|
-
}
|
|
2608
|
-
]
|
|
2609
|
-
});
|
|
2610
|
-
}
|
|
2611
|
-
if (validWords.length === 3) break;
|
|
2612
|
-
}
|
|
2613
|
-
if (validWords.length > 0) kanji2.words = validWords;
|
|
2614
|
-
}
|
|
2615
|
-
}
|
|
2616
|
-
if (svgList) {
|
|
2617
|
-
const codePoint = kanji2.kanji.codePointAt(0).toString(16).toLowerCase();
|
|
2618
|
-
const svg = Array.isArray(svgList) ? svgList.find(
|
|
2619
|
-
(svgFile) => [`${codePoint}.svg`, `0${codePoint}.svg`].includes(
|
|
2620
|
-
svgFile.toLowerCase()
|
|
2621
|
-
)
|
|
2622
|
-
) : svgList.get(kanji2.kanji);
|
|
2623
|
-
if (svg) kanji2.svg = svg;
|
|
2624
|
-
}
|
|
2625
|
-
if (kanji2.tags && dictKanji.isKokuji === true) {
|
|
2626
|
-
kanji2.kokuji = true;
|
|
2627
|
-
kanji2.tags.push("kanji::kokuji");
|
|
2628
|
-
}
|
|
2629
|
-
kanji2.tags.push(
|
|
2630
|
-
`kanji::strokes::${kanji2.strokes}`,
|
|
2631
|
-
...kanji2.frequency ? [`kanji::frequency::${kanji2.frequency}`] : [],
|
|
2632
|
-
...kanji2.grade ? [`kanji::grade::${kanji2.grade}`] : [],
|
|
2633
|
-
...kanji2.jlpt ? [`kanji::pre-2010_jlpt::${kanji2.jlpt.toLowerCase()}`] : [],
|
|
2634
|
-
`kanji::onyomi::${(_e = (_d = kanji2.onyomi) == null ? void 0 : _d.length) != null ? _e : 0}`,
|
|
2635
|
-
`kanji::kunyomi::${(_g = (_f = kanji2.kunyomi) == null ? void 0 : _f.length) != null ? _g : 0}`,
|
|
2636
|
-
`kanji::nanori::${(_i = (_h = kanji2.nanori) == null ? void 0 : _h.length) != null ? _i : 0}`,
|
|
2637
|
-
`kanji::words::${(_k = (_j = kanji2.words) == null ? void 0 : _j.length) != null ? _k : 0}`,
|
|
2638
|
-
...kanji2.svg ? ["kanji::has_svg"] : []
|
|
2639
|
-
);
|
|
2640
|
-
return kanji2;
|
|
2641
|
-
} else return void 0;
|
|
2642
|
-
}
|
|
2643
|
-
function getKanjiExtended(info, kanji, dict, useWords, jmDict, svgList, noteTypeName, deckPath, sourceURL) {
|
|
2644
|
-
const kanjiObj = getKanji(
|
|
2645
|
-
kanji,
|
|
2646
|
-
dict,
|
|
2647
|
-
jmDict,
|
|
2648
|
-
svgList,
|
|
2649
|
-
noteTypeName,
|
|
2650
|
-
deckPath
|
|
2651
|
-
);
|
|
2652
|
-
if (kanjiObj) {
|
|
2653
|
-
let usedInfo = false;
|
|
2654
|
-
if (info.components) {
|
|
2655
|
-
kanjiObj.components = info.components;
|
|
2656
|
-
usedInfo = true;
|
|
2657
|
-
}
|
|
2658
|
-
if (info.mnemonic && info.mnemonic.length > 0) {
|
|
2659
|
-
kanjiObj.mnemonic = info.mnemonic;
|
|
2660
|
-
usedInfo = true;
|
|
2661
|
-
}
|
|
2662
|
-
if (useWords === true && info.words && info.words.length > 0) {
|
|
2663
|
-
kanjiObj.words = info.words;
|
|
2664
|
-
usedInfo = true;
|
|
2665
|
-
}
|
|
2666
|
-
if (kanjiObj.components)
|
|
2667
|
-
kanjiObj.tags.push(`kanji::components::${kanjiObj.components.length}`);
|
|
2668
|
-
if (kanjiObj.mnemonic && kanjiObj.mnemonic.length > 0)
|
|
2669
|
-
kanjiObj.tags.push("kanji::has_mnemonic");
|
|
2670
|
-
if (useWords === true && kanjiObj.words && info.words)
|
|
2671
|
-
kanjiObj.tags.forEach((tag, index) => {
|
|
2672
|
-
if (tag.startsWith("kanji::words::") && kanjiObj.words) {
|
|
2673
|
-
kanjiObj.tags.splice(
|
|
2674
|
-
index,
|
|
2675
|
-
1,
|
|
2676
|
-
`kanji::words::${kanjiObj.words.length}`
|
|
2677
|
-
);
|
|
2678
|
-
}
|
|
2679
|
-
});
|
|
2680
|
-
if (sourceURL && info.externalInfo === true && usedInfo)
|
|
2681
|
-
kanjiObj.source = sourceURL;
|
|
2682
|
-
return kanjiObj;
|
|
2688
|
+
return word;
|
|
2683
2689
|
} else return void 0;
|
|
2684
2690
|
}
|
|
2685
2691
|
function isWord(entry) {
|
|
2686
|
-
|
|
2692
|
+
var _a, _b;
|
|
2693
|
+
return isObjectArray((_a = Object.getOwnPropertyDescriptor(entry, "readings")) == null ? void 0 : _a.value) && isObjectArray((_b = Object.getOwnPropertyDescriptor(entry, "translations")) == null ? void 0 : _b.value);
|
|
2687
2694
|
}
|
|
2688
2695
|
function isRadical(entry) {
|
|
2689
|
-
|
|
2696
|
+
var _a;
|
|
2697
|
+
return typeof ((_a = Object.getOwnPropertyDescriptor(entry, "radical")) == null ? void 0 : _a.value) === "string";
|
|
2690
2698
|
}
|
|
2691
2699
|
function isKanji(entry) {
|
|
2692
|
-
|
|
2700
|
+
var _a;
|
|
2701
|
+
return !Object.hasOwn(entry, "translations") && !Object.hasOwn(entry, "readings") && !Object.hasOwn(entry, "radical") && typeof ((_a = Object.getOwnPropertyDescriptor(entry, "kanji")) == null ? void 0 : _a.value) === "string";
|
|
2693
2702
|
}
|
|
2694
2703
|
function isKana(entry) {
|
|
2695
|
-
|
|
2704
|
+
var _a;
|
|
2705
|
+
return typeof ((_a = Object.getOwnPropertyDescriptor(entry, "kana")) == null ? void 0 : _a.value) === "string";
|
|
2696
2706
|
}
|
|
2697
2707
|
function isGrammar(entry) {
|
|
2698
|
-
|
|
2708
|
+
var _a;
|
|
2709
|
+
return typeof ((_a = Object.getOwnPropertyDescriptor(entry, "point")) == null ? void 0 : _a.value) === "string";
|
|
2699
2710
|
}
|
|
2700
2711
|
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>" : ""}`;
|
|
2701
|
-
var createEntry = (entry, notes, phrase, glossSpecific) => `<div class="entry${glossSpecific ? " gloss-specific" : ""}">${entry}${notes && notes.length > 0 ? createNotes(notes, phrase) : ""}</div>`;
|
|
2712
|
+
var createEntry = (entry, notes, phrase, glossSpecific) => `<div class="entry${glossSpecific === true ? " gloss-specific" : ""}">${entry}${notes !== void 0 && notes.length > 0 ? createNotes(notes, phrase) : ""}</div>`;
|
|
2702
2713
|
function generateAnkiNote(entry) {
|
|
2703
2714
|
var _a, _b;
|
|
2704
2715
|
const fields = [];
|
|
@@ -2714,42 +2725,41 @@ function generateAnkiNote(entry) {
|
|
|
2714
2725
|
)
|
|
2715
2726
|
).join("")}</details>` : "";
|
|
2716
2727
|
const readingsField = `${firstReading}${otherReadings}`;
|
|
2717
|
-
const firstKanjiForm = entry.kanjiForms ? createEntry(
|
|
2728
|
+
const firstKanjiForm = entry.kanjiForms !== void 0 ? createEntry(
|
|
2718
2729
|
`<span class="word word-kanjiform"><ruby><rb>${entry.kanjiForms[0].kanjiForm}</rb><rt>${entry.readings[0].reading}</rt></ruby></span>`,
|
|
2719
2730
|
entry.kanjiForms[0].notes
|
|
2720
2731
|
) : void 0;
|
|
2721
|
-
const otherKanjiForms = entry.kanjiForms && entry.kanjiForms.length > 1 ? `<details><summary>Show other kanji forms</summary>${entry.kanjiForms.slice(1).map((kanjiFormEntry) => {
|
|
2732
|
+
const otherKanjiForms = entry.kanjiForms !== void 0 && entry.kanjiForms.length > 1 ? `<details><summary>Show other kanji forms</summary>${entry.kanjiForms.slice(1).map((kanjiFormEntry) => {
|
|
2722
2733
|
const restrictedReading = entry.readings.find(
|
|
2723
|
-
(r) => r.notes && r.notes.includes(
|
|
2734
|
+
(r) => r.notes !== void 0 && r.notes.includes(
|
|
2724
2735
|
`Reading restricted to ${kanjiFormEntry.kanjiForm}`
|
|
2725
2736
|
)
|
|
2726
2737
|
);
|
|
2727
|
-
return
|
|
2738
|
+
return createEntry(
|
|
2739
|
+
`<span class="word word-kanjiform">${restrictedReading !== void 0 ? "<ruby><rb>" : ""}${kanjiFormEntry.kanjiForm}${restrictedReading !== void 0 ? `</rb><rt>${restrictedReading.reading}</rt></ruby>` : ""}</span>`,
|
|
2740
|
+
kanjiFormEntry.notes
|
|
2741
|
+
);
|
|
2728
2742
|
}).join("")}</details>` : "";
|
|
2729
|
-
const kanjiFormsField = firstKanjiForm ? `${firstKanjiForm}${otherKanjiForms}` : '<span class="word word-kanjiform">(no kanji forms)</span>';
|
|
2743
|
+
const kanjiFormsField = firstKanjiForm !== void 0 ? `${firstKanjiForm}${otherKanjiForms}` : '<span class="word word-kanjiform">(no kanji forms)</span>';
|
|
2730
2744
|
const firstThreeTranslations = entry.translations.slice(0, 3).map(
|
|
2731
|
-
(translationEntry, index) =>
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
void 0
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
)) ? true : void 0
|
|
2740
|
-
);
|
|
2741
|
-
}
|
|
2745
|
+
(translationEntry, index) => createEntry(
|
|
2746
|
+
`<span class="word word-translation">${translationEntry.translation}</span>`,
|
|
2747
|
+
translationEntry.notes,
|
|
2748
|
+
void 0,
|
|
2749
|
+
entry.phrases !== void 0 ? entry.phrases.some(
|
|
2750
|
+
(phrase, index2) => index === index2 && phrase.glossNumber !== void 0 && phrase.glossNumber.wordId === entry.id && phrase.glossNumber.glossNumber === index + 1
|
|
2751
|
+
) ? true : void 0 : void 0
|
|
2752
|
+
)
|
|
2742
2753
|
).join("");
|
|
2743
2754
|
const otherTranslations = entry.translations.length > 3 ? `<details><summary>Show other translations</summary>${entry.translations.map((translationEntry, index) => {
|
|
2744
|
-
var _a2;
|
|
2745
2755
|
if (index < 3) return "null";
|
|
2746
2756
|
return createEntry(
|
|
2747
2757
|
`<span class="word word-translation">${translationEntry.translation}</span>`,
|
|
2748
2758
|
translationEntry.notes,
|
|
2749
2759
|
void 0,
|
|
2750
|
-
|
|
2751
|
-
(phrase, index2) => index === index2 && phrase.glossNumber && phrase.glossNumber.wordId === entry.id && phrase.glossNumber.glossNumber === index + 1
|
|
2752
|
-
)
|
|
2760
|
+
entry.phrases !== void 0 ? entry.phrases.some(
|
|
2761
|
+
(phrase, index2) => index === index2 && phrase.glossNumber !== void 0 && phrase.glossNumber.wordId === entry.id && phrase.glossNumber.glossNumber === index + 1
|
|
2762
|
+
) ? true : void 0 : void 0
|
|
2753
2763
|
);
|
|
2754
2764
|
}).filter((translation) => translation !== "null").join("")}</details>` : "";
|
|
2755
2765
|
const translationsField = `${firstThreeTranslations}${otherTranslations}`;
|
|
@@ -2759,7 +2769,7 @@ function generateAnkiNote(entry) {
|
|
|
2759
2769
|
[phraseEntry.translation],
|
|
2760
2770
|
true,
|
|
2761
2771
|
entry.translations.some(
|
|
2762
|
-
(_translation, index2) => index === index2 && phraseEntry.glossNumber && phraseEntry.glossNumber.wordId === entry.id && phraseEntry.glossNumber.glossNumber === index2 + 1
|
|
2772
|
+
(_translation, index2) => index === index2 && phraseEntry.glossNumber !== void 0 && phraseEntry.glossNumber.wordId === entry.id && phraseEntry.glossNumber.glossNumber === index2 + 1
|
|
2763
2773
|
) ? true : void 0
|
|
2764
2774
|
)
|
|
2765
2775
|
).join("");
|
|
@@ -2770,40 +2780,40 @@ function generateAnkiNote(entry) {
|
|
|
2770
2780
|
[phraseEntry.translation],
|
|
2771
2781
|
true,
|
|
2772
2782
|
entry.translations.some(
|
|
2773
|
-
(_translation, index2) => index === index2 && phraseEntry.glossNumber && phraseEntry.glossNumber.wordId === entry.id && phraseEntry.glossNumber.glossNumber === index2 + 1
|
|
2783
|
+
(_translation, index2) => index === index2 && phraseEntry.glossNumber !== void 0 && phraseEntry.glossNumber.wordId === entry.id && phraseEntry.glossNumber.glossNumber === index2 + 1
|
|
2774
2784
|
) ? true : void 0
|
|
2775
2785
|
);
|
|
2776
2786
|
}).filter((phrase) => phrase !== "null").join("")}</details>` : "";
|
|
2777
|
-
const phrasesField = firstFivePhrases ? `${firstFivePhrases}${otherPhrases}` : '<span class="word word-phrase">(no phrases) (Search on dictionaries!)</span>';
|
|
2787
|
+
const phrasesField = firstFivePhrases !== void 0 ? `${firstFivePhrases}${otherPhrases}` : '<span class="word word-phrase">(no phrases) (Search on dictionaries!)</span>';
|
|
2778
2788
|
const firstThreeDefinitions = (_b = entry.definitions) == null ? void 0 : _b.slice(0, 3).map(
|
|
2779
2789
|
(definitionEntry) => {
|
|
2780
2790
|
var _a2;
|
|
2781
2791
|
return createEntry(
|
|
2782
|
-
`<span class="word word-definition${definitionEntry.mayNotBeAccurate ===
|
|
2792
|
+
`<span class="word word-definition${definitionEntry.mayNotBeAccurate === 2 ? " mnba2" : definitionEntry.mayNotBeAccurate === 1 ? " mnba1" : ""}"><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
2793
|
);
|
|
2784
2794
|
}
|
|
2785
2795
|
).join("");
|
|
2786
2796
|
const otherDefinitions = entry.definitions !== void 0 && entry.definitions.length > 3 ? `<details><summary>Show other definitions</summary>${entry.definitions.map(
|
|
2787
2797
|
(definitionEntry, index) => {
|
|
2788
2798
|
var _a2;
|
|
2789
|
-
return index > 2 ?
|
|
2790
|
-
`<span class="word word-definition${definitionEntry.mayNotBeAccurate ===
|
|
2791
|
-
)
|
|
2799
|
+
return index > 2 ? createEntry(
|
|
2800
|
+
`<span class="word word-definition${definitionEntry.mayNotBeAccurate === 2 ? " mnba2" : definitionEntry.mayNotBeAccurate === 1 ? " mnba1" : ""}"><span class="word word-definition-original">${definitionEntry.definition}</span><span class="word word-definition-furigana">${(_a2 = definitionEntry.furigana) != null ? _a2 : definitionEntry.definition}</span></span>`
|
|
2801
|
+
) : "null";
|
|
2792
2802
|
}
|
|
2793
2803
|
).filter((definition) => definition !== "null").join("")}</details>` : "";
|
|
2794
|
-
const definitionsField = firstThreeDefinitions ? `${firstThreeDefinitions}${otherDefinitions}` : '<span class="word word-definition">(no definitions)</span>';
|
|
2804
|
+
const definitionsField = firstThreeDefinitions !== void 0 ? `${firstThreeDefinitions}${otherDefinitions}` : '<span class="word word-definition">(no definitions)</span>';
|
|
2795
2805
|
fields.push(
|
|
2796
|
-
...entry.kanjiForms && !entry.usuallyInKana ? [kanjiFormsField, readingsField] : [readingsField, kanjiFormsField],
|
|
2806
|
+
...entry.kanjiForms !== void 0 && !entry.usuallyInKana ? [kanjiFormsField, readingsField] : [readingsField, kanjiFormsField],
|
|
2797
2807
|
translationsField,
|
|
2798
2808
|
phrasesField,
|
|
2799
2809
|
definitionsField,
|
|
2800
|
-
entry.kanji ? entry.kanji.map(
|
|
2810
|
+
entry.kanji !== void 0 ? entry.kanji.map(
|
|
2801
2811
|
(kanjiEntry) => createEntry(
|
|
2802
2812
|
`<span class="word word-kanji">${kanjiEntry.kanji}${kanjiEntry.meanings === void 0 ? " (no meanings)" : ""}</span>`,
|
|
2803
2813
|
kanjiEntry.meanings
|
|
2804
2814
|
)
|
|
2805
2815
|
).join("") : '<span class="word word-kanji">(no kanji)</span>',
|
|
2806
|
-
...entry.tags && entry.tags.length > 0 ? [
|
|
2816
|
+
...entry.tags !== void 0 && entry.tags.length > 0 ? [
|
|
2807
2817
|
entry.tags.map(
|
|
2808
2818
|
(tag) => tag.trim().toLowerCase().replaceAll(" ", "::")
|
|
2809
2819
|
).join(" ")
|
|
@@ -2823,19 +2833,19 @@ function generateAnkiNote(entry) {
|
|
|
2823
2833
|
`<span class="radical radical-meaning">${meaningEntry}</span>`
|
|
2824
2834
|
)
|
|
2825
2835
|
).join(""),
|
|
2826
|
-
entry.mnemonic ? createEntry(
|
|
2836
|
+
entry.mnemonic !== void 0 ? createEntry(
|
|
2827
2837
|
`<span class="radical radical-mnemonic">${entry.mnemonic}</span>`
|
|
2828
2838
|
) : '<span class="radical radical-mnemonic">(no mnemonic) (Come up with your own!)</span>',
|
|
2829
|
-
entry.kanji ? entry.kanji.map(
|
|
2839
|
+
entry.kanji !== void 0 ? entry.kanji.map(
|
|
2830
2840
|
(kanji) => createEntry(
|
|
2831
|
-
`<span class="radical radical-kanji">${kanji.kanji}${kanji.meanings && kanji.meanings.length
|
|
2841
|
+
`<span class="radical radical-kanji">${kanji.kanji}${kanji.meanings !== void 0 && kanji.meanings.length > 0 ? ` - ${kanji.meanings[0]}` : ""}</span>`
|
|
2832
2842
|
)
|
|
2833
2843
|
).join("") : '<span class="radical radical-kanji">(no "used-in" kanji)</span>',
|
|
2834
|
-
entry.strokes ? createEntry(
|
|
2835
|
-
`<span class="radical radical-strokes">${entry.strokes}<br>${entry.svg ? `<img class="radical radical-stroke-order" src="${entry.svg}" alt="${entry.radical} stroke order SVG">` : "(no stroke order SVG available)"}</span>`
|
|
2844
|
+
entry.strokes !== void 0 ? createEntry(
|
|
2845
|
+
`<span class="radical radical-strokes">${entry.strokes}<br>${entry.svg !== void 0 ? `<img class="radical radical-stroke-order" src="${entry.svg}" alt="${entry.radical} stroke order SVG">` : "(no stroke order SVG available)"}</span>`
|
|
2836
2846
|
) : '<span class="radical radical-strokes">(no stroke number)</span>',
|
|
2837
|
-
entry.sources ? `<span class="radical radical-source">${entry.sources.map((source, index) => `<a href="${source}" target="_blank">Source ${index + 1}</a>`).join("<br>")}</span>` : '<span class="radical radical-source">(no sources)</span>',
|
|
2838
|
-
...entry.tags && entry.tags.length > 0 ? [
|
|
2847
|
+
entry.sources !== void 0 ? `<span class="radical radical-source">${entry.sources.map((source, index) => `<a href="${source}" target="_blank">Source ${index + 1}</a>`).join("<br>")}</span>` : '<span class="radical radical-source">(no sources)</span>',
|
|
2848
|
+
...entry.tags !== void 0 && entry.tags.length > 0 ? [
|
|
2839
2849
|
entry.tags.map(
|
|
2840
2850
|
(tag) => tag.trim().toLowerCase().replaceAll(" ", "::")
|
|
2841
2851
|
).join(" ")
|
|
@@ -2844,44 +2854,44 @@ function generateAnkiNote(entry) {
|
|
|
2844
2854
|
if (isKanji(entry))
|
|
2845
2855
|
fields.push(
|
|
2846
2856
|
createEntry(`<span class="kanji kanji-character">${entry.kanji}</span>`),
|
|
2847
|
-
entry.meanings ? entry.meanings.map(
|
|
2857
|
+
entry.meanings !== void 0 ? entry.meanings.map(
|
|
2848
2858
|
(meaningEntry) => createEntry(
|
|
2849
2859
|
`<span class="kanji kanji-meaning">${meaningEntry}</span>`
|
|
2850
2860
|
)
|
|
2851
2861
|
).join("") : '<span class="kanji kanji-meaning">(no meanings)</span>',
|
|
2852
|
-
entry.onyomi ? entry.onyomi.map(
|
|
2862
|
+
entry.onyomi !== void 0 ? entry.onyomi.map(
|
|
2853
2863
|
(onyomiEntry) => createEntry(
|
|
2854
2864
|
`<span class="kanji kanji-onyomi">${onyomiEntry}</span>`
|
|
2855
2865
|
)
|
|
2856
2866
|
).join("") : `<span class="kanji kanji-onyomi">(no onyomi) ${entry.kokuji === true ? "(kokuji)" : ""}</span>`,
|
|
2857
|
-
entry.kunyomi ? entry.kunyomi.map(
|
|
2867
|
+
entry.kunyomi !== void 0 ? entry.kunyomi.map(
|
|
2858
2868
|
(kunyomiEntry) => createEntry(
|
|
2859
2869
|
`<span class="kanji kanji-kunyomi">${kunyomiEntry}</span>`
|
|
2860
2870
|
)
|
|
2861
2871
|
).join("") : `<span class="kanji kanji-kunyomi">(no kunyomi) ${entry.kokuji === true ? "(kokuji)" : ""}</span>`,
|
|
2862
|
-
entry.nanori ? entry.nanori.map(
|
|
2872
|
+
entry.nanori !== void 0 ? entry.nanori.map(
|
|
2863
2873
|
(nanoriEntry) => createEntry(
|
|
2864
2874
|
`<span class="kanji kanji-nanori">${nanoriEntry}</span>`
|
|
2865
2875
|
)
|
|
2866
2876
|
).join("") : '<span class="kanji kanji-nanori">(no nanori)</span>',
|
|
2867
|
-
entry.components ? entry.components.map(
|
|
2877
|
+
entry.components !== void 0 ? entry.components.map(
|
|
2868
2878
|
(componentEntry) => createEntry(
|
|
2869
|
-
`<span class="kanji kanji-component">${componentEntry.component}${componentEntry.meaning ? ` - ${componentEntry.meaning}` : ""}</span>`
|
|
2879
|
+
`<span class="kanji kanji-component">${componentEntry.component}${componentEntry.meaning !== void 0 ? ` - ${componentEntry.meaning}` : ""}</span>`
|
|
2870
2880
|
)
|
|
2871
2881
|
).join("") : '<span class="kanji kanji-component">(no components)</span>',
|
|
2872
|
-
entry.mnemonic ? createEntry(
|
|
2882
|
+
entry.mnemonic !== void 0 ? createEntry(
|
|
2873
2883
|
`<span class="kanji kanji-mnemonic">${entry.mnemonic}</span>`
|
|
2874
2884
|
) : '<span class="kanji kanji-mnemonic">(no mnemonic) (Come up with your own!)</span>',
|
|
2875
|
-
entry.words ? entry.words.map(
|
|
2885
|
+
entry.words !== void 0 ? entry.words.map(
|
|
2876
2886
|
(word) => createEntry(
|
|
2877
|
-
`<span class="kanji kanji-words">${word.kanjiForms
|
|
2887
|
+
`<span class="kanji kanji-words">${word.kanjiForms.find((kf) => kf.kanjiForm.includes(entry.kanji)).kanjiForm} / ${word.readings[0].reading} - ${word.translations[0].translation}</span>`
|
|
2878
2888
|
)
|
|
2879
2889
|
).join("") : '<span class="kanji kanji-words">(no words) (Search on dictionaries!)</span>',
|
|
2880
|
-
entry.strokes ? createEntry(
|
|
2881
|
-
`<span class="kanji kanji-strokes">${entry.strokes}<br>${entry.svg ? `<img class="kanji kanji-stroke-order" src="${entry.svg}" alt="${entry.kanji} stroke order SVG">` : "(no stroke order SVG available)"}</span>`
|
|
2890
|
+
entry.strokes !== void 0 ? createEntry(
|
|
2891
|
+
`<span class="kanji kanji-strokes">${entry.strokes}<br>${entry.svg !== void 0 ? `<img class="kanji kanji-stroke-order" src="${entry.svg}" alt="${entry.kanji} stroke order SVG">` : "(no stroke order SVG available)"}</span>`
|
|
2882
2892
|
) : '<span class="kanji kanji-strokes">(no stroke number)</span>',
|
|
2883
|
-
entry.source ? `<span class="kanji kanji-source"><a href="${entry.source}" target="_blank">Source</a></span>` : '<span class="kanji kanji-source">(no components/mnemonic source)</span>',
|
|
2884
|
-
...entry.tags && entry.tags.length > 0 ? [
|
|
2893
|
+
entry.source !== void 0 ? `<span class="kanji kanji-source"><a href="${entry.source}" target="_blank">Source</a></span>` : '<span class="kanji kanji-source">(no components/mnemonic source)</span>',
|
|
2894
|
+
...entry.tags !== void 0 && entry.tags.length > 0 ? [
|
|
2885
2895
|
entry.tags.map(
|
|
2886
2896
|
(tag) => tag.trim().toLowerCase().replaceAll(" ", "::")
|
|
2887
2897
|
).join(" ")
|
|
@@ -2893,10 +2903,10 @@ function generateAnkiNote(entry) {
|
|
|
2893
2903
|
createEntry(
|
|
2894
2904
|
`<span class="kana kana-reading">${entry.reading}${entry.audio !== void 0 ? `<br>[sound:${entry.audio}]` : ""}</span>`
|
|
2895
2905
|
),
|
|
2896
|
-
entry.svg ? createEntry(
|
|
2906
|
+
entry.svg !== void 0 ? createEntry(
|
|
2897
2907
|
`<img class="kana kana-stroke-order" src="${entry.svg}" alt="${entry.kana} stroke order SVG">`
|
|
2898
2908
|
) : "(no stroke order SVG available)",
|
|
2899
|
-
...entry.tags && entry.tags.length > 0 ? [
|
|
2909
|
+
...entry.tags !== void 0 && entry.tags.length > 0 ? [
|
|
2900
2910
|
entry.tags.map(
|
|
2901
2911
|
(tag) => tag.trim().toLowerCase().replaceAll(" ", "::")
|
|
2902
2912
|
).join(" ")
|
|
@@ -2905,28 +2915,28 @@ function generateAnkiNote(entry) {
|
|
|
2905
2915
|
if (isGrammar(entry))
|
|
2906
2916
|
fields.push(
|
|
2907
2917
|
createEntry(`<span class="grammar grammar-point">${entry.point}</span>`),
|
|
2908
|
-
entry.readings ? entry.readings.map(
|
|
2918
|
+
entry.readings !== void 0 ? entry.readings.map(
|
|
2909
2919
|
(readingEntry) => createEntry(
|
|
2910
2920
|
`<span class="grammar grammar-reading">${readingEntry.reading}</span>`
|
|
2911
2921
|
)
|
|
2912
2922
|
).join("") : '<span class="grammar grammar-reading">(no additional readings)</span>',
|
|
2913
2923
|
createEntry(
|
|
2914
|
-
`<span class="grammar grammar-meaning">${entry.meaning.meaning}${entry.meaning.example && entry.meaning.example.length > 0 ? `<br><span class="grammar grammar-meaning-example">${entry.meaning.example}</span>` : ""}</span>`
|
|
2924
|
+
`<span class="grammar grammar-meaning">${entry.meaning.meaning}${entry.meaning.example !== void 0 && entry.meaning.example.length > 0 ? `<br><span class="grammar grammar-meaning-example">${entry.meaning.example}</span>` : ""}</span>`
|
|
2915
2925
|
),
|
|
2916
|
-
entry.usages ? entry.usages.map(
|
|
2926
|
+
entry.usages !== void 0 ? entry.usages.map(
|
|
2917
2927
|
(usage) => createEntry(
|
|
2918
2928
|
`<span class="grammar grammar-usage">${usage}</span>`
|
|
2919
2929
|
)
|
|
2920
2930
|
).join("") : '<span class="grammar grammar-usage">(no usages)</span>',
|
|
2921
|
-
entry.phrases ? entry.phrases.map(
|
|
2931
|
+
entry.phrases !== void 0 ? entry.phrases.map(
|
|
2922
2932
|
(phraseEntry) => createEntry(
|
|
2923
2933
|
`<span class="grammar grammar-phrase"><span class="grammar grammar-phrase-original">${phraseEntry.originalPhrase}</span><span class="grammar grammar-phrase-furigana">${phraseEntry.phrase}</span></span>`,
|
|
2924
2934
|
[phraseEntry.translation],
|
|
2925
2935
|
true
|
|
2926
2936
|
)
|
|
2927
2937
|
).join("") : '<span class="grammar grammar-phrase">(no phrases) (Search on dictionaries!)</span>',
|
|
2928
|
-
entry.source ? `<span class="grammar grammar-source"><a href="${entry.source}" target="_blank">Source</a></span>` : '<span class="grammar grammar-source">(no source)</span>',
|
|
2929
|
-
...entry.tags && entry.tags.length > 0 ? [
|
|
2938
|
+
entry.source !== void 0 ? `<span class="grammar grammar-source"><a href="${entry.source}" target="_blank">Source</a></span>` : '<span class="grammar grammar-source">(no source)</span>',
|
|
2939
|
+
...entry.tags !== void 0 && entry.tags.length > 0 ? [
|
|
2930
2940
|
entry.tags.map(
|
|
2931
2941
|
(tag) => tag.trim().toLowerCase().replaceAll(" ", "::")
|
|
2932
2942
|
).join(" ")
|
|
@@ -2938,8 +2948,9 @@ function generateAnkiNotesFile(list, defaultNoteInfo) {
|
|
|
2938
2948
|
const headers = [noteHeaderKeys.separator, noteHeaderKeys.html];
|
|
2939
2949
|
let ankiNotes = "";
|
|
2940
2950
|
if (list.length > 0) {
|
|
2941
|
-
|
|
2942
|
-
|
|
2951
|
+
let noteInfo = {};
|
|
2952
|
+
if (defaultNoteInfo !== void 0) noteInfo = { ...defaultNoteInfo };
|
|
2953
|
+
const infoValues = Object.values(noteInfo);
|
|
2943
2954
|
let invalidList = false;
|
|
2944
2955
|
const firstEntry = list[0];
|
|
2945
2956
|
const firstEntryInfo = {
|
|
@@ -2949,7 +2960,7 @@ function generateAnkiNotesFile(list, defaultNoteInfo) {
|
|
|
2949
2960
|
};
|
|
2950
2961
|
if (infoValues.length === 0 || infoValues.some((value) => value === true || value === void 0)) {
|
|
2951
2962
|
for (const res of list)
|
|
2952
|
-
if (
|
|
2963
|
+
if (noteInfo.guid === true && res.noteID === void 0 || noteInfo.noteType === true && res.noteTypeName === void 0 || noteInfo.deckPath === true && res.deckPath === void 0 || noteInfo.guid === void 0 && typeof res.noteID !== firstEntryInfo.guid || noteInfo.noteType === void 0 && typeof res.noteTypeName !== firstEntryInfo.noteType || noteInfo.deckPath === void 0 && typeof res.deckPath !== firstEntryInfo.deckPath) {
|
|
2953
2964
|
invalidList = true;
|
|
2954
2965
|
break;
|
|
2955
2966
|
}
|
|
@@ -2958,26 +2969,28 @@ function generateAnkiNotesFile(list, defaultNoteInfo) {
|
|
|
2958
2969
|
const hasHeader = { guid: false, noteType: false, deckPath: false, tags: false };
|
|
2959
2970
|
let headerCount = 0;
|
|
2960
2971
|
ankiNotes = list.filter((result) => result.doNotCreateNote === void 0).map((result) => {
|
|
2961
|
-
if (typeof
|
|
2962
|
-
if (isWord(result) && result.id
|
|
2972
|
+
if (typeof noteInfo.guid === "string" && result.noteID === void 0) {
|
|
2973
|
+
if (isWord(result) && result.id !== void 0)
|
|
2974
|
+
result.noteID = result.id;
|
|
2963
2975
|
if (isKanji(result)) result.noteID = result.kanji;
|
|
2964
2976
|
if (isRadical(result)) result.noteID = result.radical;
|
|
2965
2977
|
if (isKana(result)) result.noteID = result.kana;
|
|
2966
|
-
if (isGrammar(result) && result.id
|
|
2978
|
+
if (isGrammar(result) && result.id !== void 0)
|
|
2979
|
+
result.noteID = result.id;
|
|
2967
2980
|
}
|
|
2968
|
-
if (typeof
|
|
2969
|
-
result.noteTypeName =
|
|
2970
|
-
if (typeof
|
|
2971
|
-
result.deckPath =
|
|
2972
|
-
if (!hasHeader.guid && result.noteID) {
|
|
2981
|
+
if (typeof noteInfo.noteType === "string" && result.noteTypeName === void 0)
|
|
2982
|
+
result.noteTypeName = noteInfo.noteType;
|
|
2983
|
+
if (typeof noteInfo.deckPath === "string" && result.deckPath === void 0)
|
|
2984
|
+
result.deckPath = noteInfo.deckPath;
|
|
2985
|
+
if (!hasHeader.guid && result.noteID !== void 0) {
|
|
2973
2986
|
headers.push(`${noteHeaderKeys.guid}${++headerCount}`);
|
|
2974
2987
|
hasHeader.guid = true;
|
|
2975
2988
|
}
|
|
2976
|
-
if (!hasHeader.noteType && result.noteTypeName) {
|
|
2989
|
+
if (!hasHeader.noteType && result.noteTypeName !== void 0) {
|
|
2977
2990
|
headers.push(`${noteHeaderKeys.notetype}${++headerCount}`);
|
|
2978
2991
|
hasHeader.noteType = true;
|
|
2979
2992
|
}
|
|
2980
|
-
if (!hasHeader.deckPath && result.deckPath) {
|
|
2993
|
+
if (!hasHeader.deckPath && result.deckPath !== void 0) {
|
|
2981
2994
|
headers.push(`${noteHeaderKeys.deck}${++headerCount}`);
|
|
2982
2995
|
hasHeader.deckPath = true;
|
|
2983
2996
|
}
|
|
@@ -2986,7 +2999,7 @@ function generateAnkiNotesFile(list, defaultNoteInfo) {
|
|
|
2986
2999
|
headers.push(`${noteHeaderKeys.tags}${note.length + headerCount}`);
|
|
2987
3000
|
hasHeader.tags = true;
|
|
2988
3001
|
}
|
|
2989
|
-
return `${result.noteID ? `${result.noteID} ` : ""}${result.noteTypeName ? `${result.noteTypeName} ` : ""}${result.deckPath ? `${result.deckPath} ` : ""}${note.join(" ")}`;
|
|
3002
|
+
return `${result.noteID !== void 0 ? `${result.noteID} ` : ""}${result.noteTypeName !== void 0 ? `${result.noteTypeName} ` : ""}${result.deckPath !== void 0 ? `${result.deckPath} ` : ""}${note.join(" ")}`;
|
|
2990
3003
|
}).join("\n").trim();
|
|
2991
3004
|
}
|
|
2992
3005
|
return `${headers.join("\n")}
|
|
@@ -3013,6 +3026,7 @@ ${ankiNotes}`;
|
|
|
3013
3026
|
getWord,
|
|
3014
3027
|
getWordDefinitions,
|
|
3015
3028
|
getWordDefinitionsWithFurigana,
|
|
3029
|
+
hiraganaToKatakana,
|
|
3016
3030
|
isGrammar,
|
|
3017
3031
|
isKana,
|
|
3018
3032
|
isKanji,
|
|
@@ -3021,9 +3035,11 @@ ${ankiNotes}`;
|
|
|
3021
3035
|
isStringArray,
|
|
3022
3036
|
isValidArrayWithFirstElement,
|
|
3023
3037
|
isWord,
|
|
3038
|
+
katakanaToHiragana,
|
|
3024
3039
|
notSearchedForms,
|
|
3025
3040
|
noteHeaderKeys,
|
|
3026
3041
|
noteMap,
|
|
3042
|
+
posList,
|
|
3027
3043
|
regexps,
|
|
3028
3044
|
shuffleArray
|
|
3029
3045
|
});
|