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.cjs.js
CHANGED
|
@@ -1383,33 +1383,27 @@ async function generateFurigana(text, bindedFunction) {
|
|
|
1383
1383
|
}
|
|
1384
1384
|
function getValidForms(readings, kanjiForms, wordIsCommon) {
|
|
1385
1385
|
const kanjiFormRestrictions = /* @__PURE__ */ new Set();
|
|
1386
|
-
const
|
|
1387
|
-
(
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
if (wordIsCommon === void 0 || reading.commonness !== void 0)
|
|
1386
|
+
const existValidReadings = readings.some(
|
|
1387
|
+
(r) => r.commonness !== void 0 || (r.notes === void 0 || !r.notes.some((note) => notSearchedForms.has(note))) && (r.kanjiFormRestrictions !== void 0 || wordIsCommon === void 0)
|
|
1388
|
+
);
|
|
1389
|
+
const validReadings = readings.filter((r) => {
|
|
1390
|
+
if (!existValidReadings || r.commonness !== void 0 || r.notes === void 0 || !r.notes.some((note) => notSearchedForms.has(note))) {
|
|
1391
|
+
if (r.kanjiFormRestrictions !== void 0) {
|
|
1392
|
+
for (const kfr of r.kanjiFormRestrictions)
|
|
1393
|
+
kanjiFormRestrictions.add(kfr);
|
|
1394
|
+
if (r.notes === void 0 || !r.notes.some((note) => notSearchedForms.has(note)))
|
|
1396
1395
|
return true;
|
|
1397
1396
|
}
|
|
1398
|
-
|
|
1397
|
+
if (!existValidReadings || wordIsCommon === void 0 || r.commonness !== void 0)
|
|
1398
|
+
return true;
|
|
1399
1399
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1400
|
+
return false;
|
|
1401
|
+
});
|
|
1402
|
+
const existValidKanjiForms = kanjiForms?.some(
|
|
1403
|
+
(kf) => kanjiFormRestrictions.has(kf.form) || kf.commonness !== void 0 || (kf.notes === void 0 || !kf.notes.some((note) => notSearchedForms.has(note))) && wordIsCommon === void 0
|
|
1403
1404
|
);
|
|
1404
1405
|
const validKanjiForms = kanjiForms?.filter(
|
|
1405
|
-
(
|
|
1406
|
-
if (index === 0) return true;
|
|
1407
|
-
if (existValidKf === true)
|
|
1408
|
-
return kanjiForm.notes === void 0 || !kanjiForm.notes.some(
|
|
1409
|
-
(note) => notSearchedForms.has(note)
|
|
1410
|
-
) && (wordIsCommon === void 0 || kanjiForm.commonness !== void 0) || kanjiFormRestrictions.has(kanjiForm.form);
|
|
1411
|
-
else return true;
|
|
1412
|
-
}
|
|
1406
|
+
(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
|
|
1413
1407
|
);
|
|
1414
1408
|
return {
|
|
1415
1409
|
readings: validReadings,
|
|
@@ -2613,42 +2607,57 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2613
2607
|
deckPath,
|
|
2614
2608
|
tags: []
|
|
2615
2609
|
};
|
|
2616
|
-
if (dictWord.isCommon === true)
|
|
2617
|
-
|
|
2618
|
-
word.tags.push("word::common");
|
|
2619
|
-
}
|
|
2610
|
+
if (dictWord.isCommon === true) word.common = true;
|
|
2611
|
+
const priorities = /* @__PURE__ */ new Set();
|
|
2620
2612
|
if (dictWord.kanjiForms !== void 0)
|
|
2621
2613
|
word.kanjiForms = dictWord.kanjiForms.map(
|
|
2622
2614
|
(dictKanjiForm) => ({
|
|
2623
2615
|
kanjiForm: dictKanjiForm.form,
|
|
2624
|
-
...dictKanjiForm.notes !== void 0 ? {
|
|
2625
|
-
notes:
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2616
|
+
...dictKanjiForm.notes !== void 0 || dictKanjiForm.commonness !== void 0 ? {
|
|
2617
|
+
notes: [
|
|
2618
|
+
...dictKanjiForm.commonness !== void 0 ? ["Common kanji form"].map((commonKf) => {
|
|
2619
|
+
for (const priority of dictKanjiForm.commonness) {
|
|
2620
|
+
word.tags.push(`word::common::${priority}`);
|
|
2621
|
+
priorities.add(priority);
|
|
2622
|
+
}
|
|
2623
|
+
return commonKf;
|
|
2624
|
+
}) : [],
|
|
2625
|
+
...dictKanjiForm.notes?.map((note) => {
|
|
2626
|
+
const noteAndTag = lookupWordNote(
|
|
2627
|
+
note,
|
|
2628
|
+
[],
|
|
2629
|
+
word.tags
|
|
2630
|
+
);
|
|
2631
|
+
return capitalizeString(noteAndTag.note);
|
|
2632
|
+
}) ?? []
|
|
2633
|
+
]
|
|
2633
2634
|
} : {},
|
|
2634
2635
|
...dictKanjiForm.commonness !== void 0 && dictKanjiForm.commonness.length > 0 ? { common: true } : {}
|
|
2635
2636
|
})
|
|
2636
2637
|
);
|
|
2637
2638
|
word.readings = dictWord.readings.map((dictReading) => ({
|
|
2638
2639
|
reading: dictReading.reading,
|
|
2639
|
-
...dictReading.kanjiFormRestrictions !== void 0 || dictReading.notes !== void 0 ? {
|
|
2640
|
+
...dictReading.kanjiFormRestrictions !== void 0 || dictReading.notes !== void 0 || dictReading.commonness !== void 0 ? {
|
|
2640
2641
|
notes: [
|
|
2642
|
+
...dictReading.notes !== void 0 || dictReading.commonness !== void 0 ? [
|
|
2643
|
+
...dictReading.commonness !== void 0 ? ["Common reading"].map((commonR) => {
|
|
2644
|
+
for (const priority of dictReading.commonness)
|
|
2645
|
+
if (!priorities.has(priority))
|
|
2646
|
+
word.tags.push(`word::common::${priority}`);
|
|
2647
|
+
return commonR;
|
|
2648
|
+
}) : [],
|
|
2649
|
+
...dictReading.notes?.map((note) => {
|
|
2650
|
+
const noteAndTag = lookupWordNote(
|
|
2651
|
+
note,
|
|
2652
|
+
[],
|
|
2653
|
+
word.tags
|
|
2654
|
+
);
|
|
2655
|
+
return capitalizeString(noteAndTag.note);
|
|
2656
|
+
}) ?? []
|
|
2657
|
+
] : [],
|
|
2641
2658
|
...dictReading.kanjiFormRestrictions !== void 0 ? dictReading.kanjiFormRestrictions.map(
|
|
2642
2659
|
(restriction) => `Reading restricted to ${restriction}`
|
|
2643
|
-
) : []
|
|
2644
|
-
...dictReading.notes !== void 0 ? dictReading.notes.map((note) => {
|
|
2645
|
-
const noteAndTag = lookupWordNote(
|
|
2646
|
-
note,
|
|
2647
|
-
[],
|
|
2648
|
-
word.tags
|
|
2649
|
-
);
|
|
2650
|
-
return capitalizeString(noteAndTag.note);
|
|
2651
|
-
}) : []
|
|
2660
|
+
) : []
|
|
2652
2661
|
]
|
|
2653
2662
|
} : {},
|
|
2654
2663
|
...dictReading.commonness !== void 0 && dictReading.commonness.length > 0 ? { common: true } : {}
|
|
@@ -2908,10 +2917,7 @@ function getName(searchedName, dict, kanjiDic, examples, noteTypeName, deckPath)
|
|
|
2908
2917
|
deckPath,
|
|
2909
2918
|
tags: []
|
|
2910
2919
|
};
|
|
2911
|
-
if (dictName.isCommon === true)
|
|
2912
|
-
name.common = true;
|
|
2913
|
-
name.tags.push("name::common");
|
|
2914
|
-
}
|
|
2920
|
+
if (dictName.isCommon === true) name.common = true;
|
|
2915
2921
|
if (dictName.kanjiForms !== void 0)
|
|
2916
2922
|
name.kanjiForms = dictName.kanjiForms.map(
|
|
2917
2923
|
(dictKanjiForm) => ({
|
|
@@ -2921,10 +2927,17 @@ function getName(searchedName, dict, kanjiDic, examples, noteTypeName, deckPath)
|
|
|
2921
2927
|
name.nameReadings = dictName.nameReadings.map(
|
|
2922
2928
|
(dictReading) => ({
|
|
2923
2929
|
reading: dictReading.reading,
|
|
2924
|
-
...dictReading.kanjiFormRestrictions !== void 0 ? {
|
|
2925
|
-
notes:
|
|
2926
|
-
(
|
|
2927
|
-
|
|
2930
|
+
...dictReading.kanjiFormRestrictions !== void 0 || dictReading.commonness !== void 0 ? {
|
|
2931
|
+
notes: [
|
|
2932
|
+
...dictReading.commonness !== void 0 ? ["Common reading"].map((commonR) => {
|
|
2933
|
+
for (const priority of dictReading.commonness)
|
|
2934
|
+
name.tags.push(`name::common::${priority}`);
|
|
2935
|
+
return commonR;
|
|
2936
|
+
}) : [],
|
|
2937
|
+
...dictReading.kanjiFormRestrictions?.map(
|
|
2938
|
+
(restriction) => `Reading restricted to ${restriction}`
|
|
2939
|
+
) ?? []
|
|
2940
|
+
]
|
|
2928
2941
|
} : {},
|
|
2929
2942
|
...dictReading.commonness !== void 0 && dictReading.commonness.length > 0 ? { common: true } : {}
|
|
2930
2943
|
})
|