henkan 3.0.1 → 3.0.3
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 +66 -53
- package/dist/index.cjs.js.map +2 -2
- package/dist/index.mjs +66 -53
- package/dist/index.mjs.map +2 -2
- package/dist/types/utils.d.ts.map +1 -1
- package/docs/api/functions/convertJMdict.md +1 -1
- package/docs/api/functions/convertJMnedict.md +1 -1
- package/docs/api/functions/convertJawiktionaryAsync.md +1 -1
- package/docs/api/functions/convertJawiktionarySync.md +1 -1
- package/docs/api/functions/convertKanjiDic.md +1 -1
- package/docs/api/functions/convertKradFile.md +1 -1
- package/docs/api/functions/convertRadkFile.md +1 -1
- package/docs/api/functions/convertTanakaCorpus.md +1 -1
- package/docs/api/functions/convertTanakaCorpusWithFurigana.md +1 -1
- package/docs/api/functions/createEntryMaps.md +1 -1
- package/docs/api/functions/generateAnkiNote.md +1 -1
- package/docs/api/functions/generateAnkiNotesFile.md +1 -1
- package/docs/api/functions/getKanji.md +1 -1
- package/docs/api/functions/getKanjiExtended.md +1 -1
- package/docs/api/functions/getName.md +1 -1
- package/docs/api/functions/getWord.md +1 -1
- package/docs/api/functions/getWordDefinitions.md +1 -1
- package/docs/api/functions/getWordDefinitionsWithFurigana.md +1 -1
- package/package.json +4 -4
- package/src/utils.ts +113 -73
package/dist/index.mjs
CHANGED
|
@@ -1317,33 +1317,27 @@ async function generateFurigana(text, bindedFunction) {
|
|
|
1317
1317
|
}
|
|
1318
1318
|
function getValidForms(readings, kanjiForms, wordIsCommon) {
|
|
1319
1319
|
const kanjiFormRestrictions = /* @__PURE__ */ new Set();
|
|
1320
|
-
const
|
|
1321
|
-
(
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
if (wordIsCommon === void 0 || reading.commonness !== void 0)
|
|
1320
|
+
const existValidReadings = readings.some(
|
|
1321
|
+
(r) => r.commonness !== void 0 || (r.notes === void 0 || !r.notes.some((note) => notSearchedForms.has(note))) && (r.kanjiFormRestrictions !== void 0 || wordIsCommon === void 0)
|
|
1322
|
+
);
|
|
1323
|
+
const validReadings = readings.filter((r) => {
|
|
1324
|
+
if (!existValidReadings || r.commonness !== void 0 || r.notes === void 0 || !r.notes.some((note) => notSearchedForms.has(note))) {
|
|
1325
|
+
if (r.kanjiFormRestrictions !== void 0) {
|
|
1326
|
+
for (const kfr of r.kanjiFormRestrictions)
|
|
1327
|
+
kanjiFormRestrictions.add(kfr);
|
|
1328
|
+
if (r.notes === void 0 || !r.notes.some((note) => notSearchedForms.has(note)))
|
|
1330
1329
|
return true;
|
|
1331
1330
|
}
|
|
1332
|
-
|
|
1331
|
+
if (!existValidReadings || wordIsCommon === void 0 || r.commonness !== void 0)
|
|
1332
|
+
return true;
|
|
1333
1333
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1334
|
+
return false;
|
|
1335
|
+
});
|
|
1336
|
+
const existValidKanjiForms = kanjiForms?.some(
|
|
1337
|
+
(kf) => kanjiFormRestrictions.has(kf.form) || kf.commonness !== void 0 || (kf.notes === void 0 || !kf.notes.some((note) => notSearchedForms.has(note))) && wordIsCommon === void 0
|
|
1337
1338
|
);
|
|
1338
1339
|
const validKanjiForms = kanjiForms?.filter(
|
|
1339
|
-
(
|
|
1340
|
-
if (index === 0) return true;
|
|
1341
|
-
if (existValidKf === true)
|
|
1342
|
-
return kanjiForm.notes === void 0 || !kanjiForm.notes.some(
|
|
1343
|
-
(note) => notSearchedForms.has(note)
|
|
1344
|
-
) && (wordIsCommon === void 0 || kanjiForm.commonness !== void 0) || kanjiFormRestrictions.has(kanjiForm.form);
|
|
1345
|
-
else return true;
|
|
1346
|
-
}
|
|
1340
|
+
(kf) => existValidKanjiForms === false || kanjiFormRestrictions.has(kf.form) || kf.commonness !== void 0 || (kf.notes === void 0 || !kf.notes.some((note) => notSearchedForms.has(note))) && wordIsCommon === void 0
|
|
1347
1341
|
);
|
|
1348
1342
|
return {
|
|
1349
1343
|
readings: validReadings,
|
|
@@ -2547,42 +2541,57 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2547
2541
|
deckPath,
|
|
2548
2542
|
tags: []
|
|
2549
2543
|
};
|
|
2550
|
-
if (dictWord.isCommon === true)
|
|
2551
|
-
|
|
2552
|
-
word.tags.push("word::common");
|
|
2553
|
-
}
|
|
2544
|
+
if (dictWord.isCommon === true) word.common = true;
|
|
2545
|
+
const priorities = /* @__PURE__ */ new Set();
|
|
2554
2546
|
if (dictWord.kanjiForms !== void 0)
|
|
2555
2547
|
word.kanjiForms = dictWord.kanjiForms.map(
|
|
2556
2548
|
(dictKanjiForm) => ({
|
|
2557
2549
|
kanjiForm: dictKanjiForm.form,
|
|
2558
|
-
...dictKanjiForm.notes !== void 0 ? {
|
|
2559
|
-
notes:
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2550
|
+
...dictKanjiForm.notes !== void 0 || dictKanjiForm.commonness !== void 0 ? {
|
|
2551
|
+
notes: [
|
|
2552
|
+
...dictKanjiForm.commonness !== void 0 ? ["Common kanji form"].map((commonKf) => {
|
|
2553
|
+
for (const priority of dictKanjiForm.commonness) {
|
|
2554
|
+
word.tags.push(`word::common::${priority}`);
|
|
2555
|
+
priorities.add(priority);
|
|
2556
|
+
}
|
|
2557
|
+
return commonKf;
|
|
2558
|
+
}) : [],
|
|
2559
|
+
...dictKanjiForm.notes?.map((note) => {
|
|
2560
|
+
const noteAndTag = lookupWordNote(
|
|
2561
|
+
note,
|
|
2562
|
+
[],
|
|
2563
|
+
word.tags
|
|
2564
|
+
);
|
|
2565
|
+
return capitalizeString(noteAndTag.note);
|
|
2566
|
+
}) ?? []
|
|
2567
|
+
]
|
|
2567
2568
|
} : {},
|
|
2568
2569
|
...dictKanjiForm.commonness !== void 0 && dictKanjiForm.commonness.length > 0 ? { common: true } : {}
|
|
2569
2570
|
})
|
|
2570
2571
|
);
|
|
2571
2572
|
word.readings = dictWord.readings.map((dictReading) => ({
|
|
2572
2573
|
reading: dictReading.reading,
|
|
2573
|
-
...dictReading.kanjiFormRestrictions !== void 0 || dictReading.notes !== void 0 ? {
|
|
2574
|
+
...dictReading.kanjiFormRestrictions !== void 0 || dictReading.notes !== void 0 || dictReading.commonness !== void 0 ? {
|
|
2574
2575
|
notes: [
|
|
2576
|
+
...dictReading.notes !== void 0 || dictReading.commonness !== void 0 ? [
|
|
2577
|
+
...dictReading.commonness !== void 0 ? ["Common reading"].map((commonR) => {
|
|
2578
|
+
for (const priority of dictReading.commonness)
|
|
2579
|
+
if (!priorities.has(priority))
|
|
2580
|
+
word.tags.push(`word::common::${priority}`);
|
|
2581
|
+
return commonR;
|
|
2582
|
+
}) : [],
|
|
2583
|
+
...dictReading.notes?.map((note) => {
|
|
2584
|
+
const noteAndTag = lookupWordNote(
|
|
2585
|
+
note,
|
|
2586
|
+
[],
|
|
2587
|
+
word.tags
|
|
2588
|
+
);
|
|
2589
|
+
return capitalizeString(noteAndTag.note);
|
|
2590
|
+
}) ?? []
|
|
2591
|
+
] : [],
|
|
2575
2592
|
...dictReading.kanjiFormRestrictions !== void 0 ? dictReading.kanjiFormRestrictions.map(
|
|
2576
2593
|
(restriction) => `Reading restricted to ${restriction}`
|
|
2577
|
-
) : []
|
|
2578
|
-
...dictReading.notes !== void 0 ? dictReading.notes.map((note) => {
|
|
2579
|
-
const noteAndTag = lookupWordNote(
|
|
2580
|
-
note,
|
|
2581
|
-
[],
|
|
2582
|
-
word.tags
|
|
2583
|
-
);
|
|
2584
|
-
return capitalizeString(noteAndTag.note);
|
|
2585
|
-
}) : []
|
|
2594
|
+
) : []
|
|
2586
2595
|
]
|
|
2587
2596
|
} : {},
|
|
2588
2597
|
...dictReading.commonness !== void 0 && dictReading.commonness.length > 0 ? { common: true } : {}
|
|
@@ -2842,10 +2851,7 @@ function getName(searchedName, dict, kanjiDic, examples, noteTypeName, deckPath)
|
|
|
2842
2851
|
deckPath,
|
|
2843
2852
|
tags: []
|
|
2844
2853
|
};
|
|
2845
|
-
if (dictName.isCommon === true)
|
|
2846
|
-
name.common = true;
|
|
2847
|
-
name.tags.push("name::common");
|
|
2848
|
-
}
|
|
2854
|
+
if (dictName.isCommon === true) name.common = true;
|
|
2849
2855
|
if (dictName.kanjiForms !== void 0)
|
|
2850
2856
|
name.kanjiForms = dictName.kanjiForms.map(
|
|
2851
2857
|
(dictKanjiForm) => ({
|
|
@@ -2855,10 +2861,17 @@ function getName(searchedName, dict, kanjiDic, examples, noteTypeName, deckPath)
|
|
|
2855
2861
|
name.nameReadings = dictName.nameReadings.map(
|
|
2856
2862
|
(dictReading) => ({
|
|
2857
2863
|
reading: dictReading.reading,
|
|
2858
|
-
...dictReading.kanjiFormRestrictions !== void 0 ? {
|
|
2859
|
-
notes:
|
|
2860
|
-
(
|
|
2861
|
-
|
|
2864
|
+
...dictReading.kanjiFormRestrictions !== void 0 || dictReading.commonness !== void 0 ? {
|
|
2865
|
+
notes: [
|
|
2866
|
+
...dictReading.commonness !== void 0 ? ["Common reading"].map((commonR) => {
|
|
2867
|
+
for (const priority of dictReading.commonness)
|
|
2868
|
+
name.tags.push(`name::common::${priority}`);
|
|
2869
|
+
return commonR;
|
|
2870
|
+
}) : [],
|
|
2871
|
+
...dictReading.kanjiFormRestrictions?.map(
|
|
2872
|
+
(restriction) => `Reading restricted to ${restriction}`
|
|
2873
|
+
) ?? []
|
|
2874
|
+
]
|
|
2862
2875
|
} : {},
|
|
2863
2876
|
...dictReading.commonness !== void 0 && dictReading.commonness.length > 0 ? { common: true } : {}
|
|
2864
2877
|
})
|