henkan 2.4.7 → 2.4.8
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 +31 -8
- package/dist/index.cjs.js.map +2 -2
- package/dist/index.mjs +31 -8
- package/dist/index.mjs.map +2 -2
- package/dist/types/utils.d.ts.map +1 -1
- package/docs/api/functions/generateAnkiNote.md +1 -1
- package/docs/api/functions/generateAnkiNotesFile.md +1 -1
- package/package.json +4 -4
- package/src/utils.ts +63 -7
package/dist/index.cjs.js
CHANGED
|
@@ -2607,9 +2607,19 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2607
2607
|
rkf.readings.map((r) => r.reading)
|
|
2608
2608
|
);
|
|
2609
2609
|
const kanjiForms = rkf.kanjiForms !== void 0 ? new Set(rkf.kanjiForms.map((kf) => kf.form)) : void 0;
|
|
2610
|
+
const meanings = new Set(
|
|
2611
|
+
dictWord.meanings.flatMap(
|
|
2612
|
+
(m) => m.translations.map((t) => {
|
|
2613
|
+
if (typeof t === "string")
|
|
2614
|
+
return t.replaceAll(/\([^)]*\)|\[[^\]]*\]|\{[^}]*\}/g, "").trim();
|
|
2615
|
+
else
|
|
2616
|
+
return t.translation.replaceAll(/\([^)]*\)|\[[^\]]*\]|\{[^}]*\}/g, "").trim();
|
|
2617
|
+
})
|
|
2618
|
+
)
|
|
2619
|
+
).values().toArray();
|
|
2610
2620
|
let kanjiFormExamples = [];
|
|
2611
2621
|
const readingMatchingKanjiFormExamples = [];
|
|
2612
|
-
|
|
2622
|
+
let readingExamples = [];
|
|
2613
2623
|
const readingMatchingKanjiForms = /* @__PURE__ */ new Set();
|
|
2614
2624
|
const seenPhrases = /* @__PURE__ */ new Set();
|
|
2615
2625
|
for (const example of exampleList)
|
|
@@ -2630,29 +2640,42 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2630
2640
|
kanjiFormExamples.push({
|
|
2631
2641
|
ex: example,
|
|
2632
2642
|
partIndex: i,
|
|
2633
|
-
form: part.baseForm
|
|
2643
|
+
form: part.baseForm,
|
|
2644
|
+
...meanings.some(
|
|
2645
|
+
(m) => example.translation.includes(m)
|
|
2646
|
+
) ? { includesTranslation: true } : {}
|
|
2634
2647
|
});
|
|
2635
2648
|
seenPhrases.add(example.phrase);
|
|
2636
2649
|
break;
|
|
2637
2650
|
}
|
|
2638
2651
|
const readingAsBaseFormMatch = readings.has(part.baseForm);
|
|
2639
2652
|
if ((readingAsBaseFormMatch || referenceIDMatch) && kanjiForms === void 0) {
|
|
2640
|
-
readingExamples.push({
|
|
2653
|
+
readingExamples.push({
|
|
2654
|
+
ex: example,
|
|
2655
|
+
partIndex: i,
|
|
2656
|
+
...referenceIDMatch ? { referenceIDMatch: true } : {},
|
|
2657
|
+
...!referenceIDMatch && meanings.some((m) => example.translation.includes(m)) ? { includesTranslation: true } : {}
|
|
2658
|
+
});
|
|
2641
2659
|
seenPhrases.add(example.phrase);
|
|
2642
2660
|
break;
|
|
2643
2661
|
}
|
|
2644
2662
|
}
|
|
2645
|
-
if (readingMatchingKanjiForms.size > 0)
|
|
2663
|
+
if (kanjiFormExamples.length > 0 && readingMatchingKanjiForms.size > 0)
|
|
2646
2664
|
kanjiFormExamples = kanjiFormExamples.filter(
|
|
2647
|
-
(ex) => ex.form !== void 0 && readingMatchingKanjiForms.has(ex.form)
|
|
2665
|
+
(ex) => ex.includesTranslation === true && ex.form !== void 0 && readingMatchingKanjiForms.has(ex.form)
|
|
2666
|
+
);
|
|
2667
|
+
else kanjiFormExamples.length = 0;
|
|
2668
|
+
if (readingExamples.length > 0 && readingExamples.some(
|
|
2669
|
+
(ex) => ex.includesTranslation === true || ex.referenceIDMatch === true
|
|
2670
|
+
))
|
|
2671
|
+
readingExamples = readingExamples.filter(
|
|
2672
|
+
(ex) => ex.includesTranslation === true || ex.referenceIDMatch === true
|
|
2648
2673
|
);
|
|
2649
|
-
const includeKanjiFormExamples = word.kanjiForms !== void 0;
|
|
2650
2674
|
let wordExamples = [
|
|
2651
|
-
...
|
|
2675
|
+
...word.kanjiForms !== void 0 ? [...readingMatchingKanjiFormExamples, ...kanjiFormExamples] : readingExamples
|
|
2652
2676
|
].toSorted(
|
|
2653
2677
|
(a, b) => a.ex.phrase.length - b.ex.phrase.length
|
|
2654
2678
|
);
|
|
2655
|
-
readingMatchingKanjiForms.clear();
|
|
2656
2679
|
seenPhrases.clear();
|
|
2657
2680
|
const glossSpecificExamples = [];
|
|
2658
2681
|
for (let i = 0; i < word.translations.length; i++)
|