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.mjs
CHANGED
|
@@ -1280,20 +1280,22 @@ function katakanaToHiragana(input) {
|
|
|
1280
1280
|
return output.join("").normalize("NFC");
|
|
1281
1281
|
}
|
|
1282
1282
|
async function generateFurigana(text, bindedFunction) {
|
|
1283
|
-
if (!text.includes("\u30FB"))
|
|
1284
|
-
|
|
1285
|
-
|
|
1283
|
+
if (!text.includes("\u30FB")) {
|
|
1284
|
+
const furigana = await bindedFunction(text, {
|
|
1285
|
+
to: "hiragana",
|
|
1286
|
+
mode: "furigana"
|
|
1287
|
+
});
|
|
1288
|
+
return furigana;
|
|
1289
|
+
}
|
|
1290
|
+
return (await Promise.all(
|
|
1291
|
+
text.split("\u30FB").map(async (part) => {
|
|
1292
|
+
const tFurigana = await bindedFunction(part, {
|
|
1286
1293
|
to: "hiragana",
|
|
1287
1294
|
mode: "furigana"
|
|
1288
|
-
})
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
text.split("\u30FB").map(async (t) => {
|
|
1293
|
-
const tFurigana = await generateFurigana(t, bindedFunction);
|
|
1294
|
-
return tFurigana;
|
|
1295
|
-
})
|
|
1296
|
-
)).join("");
|
|
1295
|
+
});
|
|
1296
|
+
return tFurigana;
|
|
1297
|
+
})
|
|
1298
|
+
)).join("\u30FB");
|
|
1297
1299
|
}
|
|
1298
1300
|
function getValidForms(readings, kanjiForms, wordIsCommon) {
|
|
1299
1301
|
const kanjiFormRestrictions = /* @__PURE__ */ new Set();
|
|
@@ -2538,8 +2540,10 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2538
2540
|
const readingMatchingKanjiFormExamples = [];
|
|
2539
2541
|
const readingExamples = [];
|
|
2540
2542
|
const readingMatchingKanjiForms = /* @__PURE__ */ new Set();
|
|
2543
|
+
const seenPhrases = /* @__PURE__ */ new Set();
|
|
2541
2544
|
for (const example of exampleList)
|
|
2542
2545
|
for (let i = 0; i < example.parts.length; i++) {
|
|
2546
|
+
if (seenPhrases.has(example.phrase)) break;
|
|
2543
2547
|
const part = example.parts[i];
|
|
2544
2548
|
const readingAsReadingMatch = part.reading !== void 0 && readings.has(part.reading);
|
|
2545
2549
|
const readingAsInflectedFormMatch = part.inflectedForm !== void 0 && readings.has(part.inflectedForm);
|
|
@@ -2557,11 +2561,13 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2557
2561
|
partIndex: i,
|
|
2558
2562
|
form: part.baseForm
|
|
2559
2563
|
});
|
|
2564
|
+
seenPhrases.add(example.phrase);
|
|
2560
2565
|
break;
|
|
2561
2566
|
}
|
|
2562
2567
|
const readingAsBaseFormMatch = readings.has(part.baseForm);
|
|
2563
2568
|
if (readingAsBaseFormMatch && kanjiForms === void 0) {
|
|
2564
2569
|
readingExamples.push({ ex: example, partIndex: i });
|
|
2570
|
+
seenPhrases.add(example.phrase);
|
|
2565
2571
|
break;
|
|
2566
2572
|
}
|
|
2567
2573
|
}
|
|
@@ -2572,13 +2578,12 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2572
2578
|
const includeKanjiFormExamples = word.kanjiForms !== void 0;
|
|
2573
2579
|
let wordExamples = [
|
|
2574
2580
|
...includeKanjiFormExamples ? [...readingMatchingKanjiFormExamples, ...kanjiFormExamples] : readingExamples
|
|
2575
|
-
]
|
|
2576
|
-
wordExamples.sort(
|
|
2581
|
+
].toSorted(
|
|
2577
2582
|
(a, b) => a.ex.phrase.length - b.ex.phrase.length
|
|
2578
2583
|
);
|
|
2579
2584
|
readingMatchingKanjiForms.clear();
|
|
2585
|
+
seenPhrases.clear();
|
|
2580
2586
|
const glossSpecificExamples = [];
|
|
2581
|
-
const seenPhrases = /* @__PURE__ */ new Set();
|
|
2582
2587
|
for (let i = 0; i < word.translations.length; i++)
|
|
2583
2588
|
outer: for (const example of wordExamples) {
|
|
2584
2589
|
if (seenPhrases.has(example.ex.phrase)) continue;
|