henkan 2.4.0 → 2.4.2
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 +20 -15
- package/dist/index.cjs.js.map +2 -2
- package/dist/index.mjs +20 -15
- package/dist/index.mjs.map +2 -2
- package/dist/types/utils.d.ts +4 -2
- package/dist/types/utils.d.ts.map +1 -1
- package/docs/api/functions/convertJMdict.md +1 -1
- package/docs/api/functions/convertJawiktionaryAsync.md +1 -1
- package/docs/api/functions/convertJawiktionarySync.md +1 -1
- package/docs/api/functions/convertKanjiDic.md +1 -1
- package/docs/api/functions/convertKradFile.md +1 -1
- package/docs/api/functions/convertRadkFile.md +1 -1
- package/docs/api/functions/convertTanakaCorpus.md +1 -1
- package/docs/api/functions/convertTanakaCorpusWithFurigana.md +1 -1
- package/docs/api/functions/createEntryMaps.md +1 -1
- package/docs/api/functions/generateAnkiNote.md +1 -1
- package/docs/api/functions/generateAnkiNotesFile.md +1 -1
- package/docs/api/functions/generateFurigana.md +5 -3
- package/docs/api/functions/getKanji.md +1 -1
- package/docs/api/functions/getKanjiExtended.md +1 -1
- package/docs/api/functions/getValidForms.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 +1 -1
- package/src/utils.ts +33 -22
package/dist/index.cjs.js
CHANGED
|
@@ -1343,20 +1343,22 @@ function katakanaToHiragana(input) {
|
|
|
1343
1343
|
return output.join("").normalize("NFC");
|
|
1344
1344
|
}
|
|
1345
1345
|
async function generateFurigana(text, bindedFunction) {
|
|
1346
|
-
if (!text.includes("\u30FB"))
|
|
1347
|
-
|
|
1348
|
-
|
|
1346
|
+
if (!text.includes("\u30FB")) {
|
|
1347
|
+
const furigana = await bindedFunction(text, {
|
|
1348
|
+
to: "hiragana",
|
|
1349
|
+
mode: "furigana"
|
|
1350
|
+
});
|
|
1351
|
+
return furigana;
|
|
1352
|
+
}
|
|
1353
|
+
return (await Promise.all(
|
|
1354
|
+
text.split("\u30FB").map(async (part) => {
|
|
1355
|
+
const tFurigana = await bindedFunction(part, {
|
|
1349
1356
|
to: "hiragana",
|
|
1350
1357
|
mode: "furigana"
|
|
1351
|
-
})
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
text.split("\u30FB").map(async (t) => {
|
|
1356
|
-
const tFurigana = await generateFurigana(t, bindedFunction);
|
|
1357
|
-
return tFurigana;
|
|
1358
|
-
})
|
|
1359
|
-
)).join("");
|
|
1358
|
+
});
|
|
1359
|
+
return tFurigana;
|
|
1360
|
+
})
|
|
1361
|
+
)).join("\u30FB");
|
|
1360
1362
|
}
|
|
1361
1363
|
function getValidForms(readings, kanjiForms, wordIsCommon) {
|
|
1362
1364
|
const kanjiFormRestrictions = /* @__PURE__ */ new Set();
|
|
@@ -2601,8 +2603,10 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2601
2603
|
const readingMatchingKanjiFormExamples = [];
|
|
2602
2604
|
const readingExamples = [];
|
|
2603
2605
|
const readingMatchingKanjiForms = /* @__PURE__ */ new Set();
|
|
2606
|
+
const seenPhrases = /* @__PURE__ */ new Set();
|
|
2604
2607
|
for (const example of exampleList)
|
|
2605
2608
|
for (let i = 0; i < example.parts.length; i++) {
|
|
2609
|
+
if (seenPhrases.has(example.phrase)) break;
|
|
2606
2610
|
const part = example.parts[i];
|
|
2607
2611
|
const readingAsReadingMatch = part.reading !== void 0 && readings.has(part.reading);
|
|
2608
2612
|
const readingAsInflectedFormMatch = part.inflectedForm !== void 0 && readings.has(part.inflectedForm);
|
|
@@ -2620,11 +2624,13 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2620
2624
|
partIndex: i,
|
|
2621
2625
|
form: part.baseForm
|
|
2622
2626
|
});
|
|
2627
|
+
seenPhrases.add(example.phrase);
|
|
2623
2628
|
break;
|
|
2624
2629
|
}
|
|
2625
2630
|
const readingAsBaseFormMatch = readings.has(part.baseForm);
|
|
2626
2631
|
if (readingAsBaseFormMatch && kanjiForms === void 0) {
|
|
2627
2632
|
readingExamples.push({ ex: example, partIndex: i });
|
|
2633
|
+
seenPhrases.add(example.phrase);
|
|
2628
2634
|
break;
|
|
2629
2635
|
}
|
|
2630
2636
|
}
|
|
@@ -2635,13 +2641,12 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2635
2641
|
const includeKanjiFormExamples = word.kanjiForms !== void 0;
|
|
2636
2642
|
let wordExamples = [
|
|
2637
2643
|
...includeKanjiFormExamples ? [...readingMatchingKanjiFormExamples, ...kanjiFormExamples] : readingExamples
|
|
2638
|
-
]
|
|
2639
|
-
wordExamples.sort(
|
|
2644
|
+
].toSorted(
|
|
2640
2645
|
(a, b) => a.ex.phrase.length - b.ex.phrase.length
|
|
2641
2646
|
);
|
|
2642
2647
|
readingMatchingKanjiForms.clear();
|
|
2648
|
+
seenPhrases.clear();
|
|
2643
2649
|
const glossSpecificExamples = [];
|
|
2644
|
-
const seenPhrases = /* @__PURE__ */ new Set();
|
|
2645
2650
|
for (let i = 0; i < word.translations.length; i++)
|
|
2646
2651
|
outer: for (const example of wordExamples) {
|
|
2647
2652
|
if (seenPhrases.has(example.ex.phrase)) continue;
|