henkan 0.0.3 → 0.1.0
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 +23 -16
- package/dist/index.cjs.js.map +2 -2
- package/dist/index.mjs +20 -13
- package/dist/index.mjs.map +2 -2
- package/dist/types/types.d.ts +6 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/docs/api/functions/capitalizeString.md +1 -1
- package/docs/api/functions/convertJMdict.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/generateAnkiNote.md +1 -1
- package/docs/api/functions/generateAnkiNotesFile.md +3 -3
- package/docs/api/functions/getKanji.md +1 -1
- package/docs/api/functions/getKanjiExtended.md +1 -1
- package/docs/api/functions/getWord.md +1 -1
- package/docs/api/functions/isStringArray.md +1 -1
- package/docs/api/functions/isValidArray.md +1 -1
- package/docs/api/functions/isValidArrayWithFirstElement.md +1 -1
- package/docs/api/functions/makeSSML.md +1 -1
- package/docs/api/functions/shuffleArray.md +1 -1
- package/docs/api/functions/synthesizeSpeech.md +3 -3
- package/docs/api/interfaces/DictKanji.md +4 -4
- package/docs/api/interfaces/DictKanjiForm.md +4 -4
- package/docs/api/interfaces/DictKanjiMisc.md +5 -5
- package/docs/api/interfaces/DictKanjiReading.md +3 -3
- package/docs/api/interfaces/DictKanjiReadingMeaning.md +3 -3
- package/docs/api/interfaces/DictKanjiReadingMeaningGroup.md +3 -3
- package/docs/api/interfaces/DictKanjiWithRadicals.md +3 -3
- package/docs/api/interfaces/DictMeaning.md +11 -11
- package/docs/api/interfaces/DictRadical.md +4 -4
- package/docs/api/interfaces/DictReading.md +5 -5
- package/docs/api/interfaces/DictWord.md +5 -5
- package/docs/api/interfaces/ExamplePart.md +7 -7
- package/docs/api/interfaces/Grammar.md +14 -14
- package/docs/api/interfaces/GrammarMeaning.md +3 -3
- package/docs/api/interfaces/Kana.md +10 -10
- package/docs/api/interfaces/Kanji.md +20 -20
- package/docs/api/interfaces/KanjiComponent.md +3 -3
- package/docs/api/interfaces/KanjiForm.md +3 -3
- package/docs/api/interfaces/Phrase.md +4 -4
- package/docs/api/interfaces/Radical.md +15 -15
- package/docs/api/interfaces/Reading.md +4 -4
- package/docs/api/interfaces/ResultEntry.md +6 -6
- package/docs/api/interfaces/TanakaExample.md +5 -5
- package/docs/api/interfaces/Translation.md +3 -3
- package/docs/api/interfaces/UsefulRegExps.md +9 -9
- package/docs/api/interfaces/Word.md +24 -12
- package/docs/api/type-aliases/Dict.md +1 -1
- package/docs/api/type-aliases/DictName.md +1 -1
- package/docs/api/type-aliases/EntryType.md +1 -1
- package/docs/api/type-aliases/JLPT.md +1 -1
- package/docs/api/type-aliases/Result.md +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -1538,6 +1538,7 @@ function getWord(dict, id, kanjiDic, examples, dictWord, noteTypeName, deckPath)
|
|
|
1538
1538
|
} : {}
|
|
1539
1539
|
};
|
|
1540
1540
|
});
|
|
1541
|
+
let usuallyInKanaMeanings = 0;
|
|
1541
1542
|
word.translations = dictWord.meanings.map((dictMeaning) => {
|
|
1542
1543
|
if (!dictMeaning.translations)
|
|
1543
1544
|
throw new Error(`No translations for ${dictWord.id}`);
|
|
@@ -1591,10 +1592,11 @@ function getWord(dict, id, kanjiDic, examples, dictWord, noteTypeName, deckPath)
|
|
|
1591
1592
|
dictMeaning.info,
|
|
1592
1593
|
(info) => lookupWordNote(info, notes, word.tags, false, info)
|
|
1593
1594
|
);
|
|
1594
|
-
wordAddNoteArray(
|
|
1595
|
-
|
|
1596
|
-
(misc)
|
|
1597
|
-
|
|
1595
|
+
wordAddNoteArray(dictMeaning.misc, (misc) => {
|
|
1596
|
+
lookupWordNote(misc, notes, word.tags, false, misc);
|
|
1597
|
+
if (misc.toLowerCase() === "word usually written using kana alone")
|
|
1598
|
+
usuallyInKanaMeanings++;
|
|
1599
|
+
});
|
|
1598
1600
|
for (let i = 0; i < notes.length; i++)
|
|
1599
1601
|
notes[i] = capitalizeString(notes[i]);
|
|
1600
1602
|
return {
|
|
@@ -1602,6 +1604,8 @@ function getWord(dict, id, kanjiDic, examples, dictWord, noteTypeName, deckPath)
|
|
|
1602
1604
|
notes
|
|
1603
1605
|
};
|
|
1604
1606
|
});
|
|
1607
|
+
if (word.translations && word.translations.length === usuallyInKanaMeanings)
|
|
1608
|
+
word.usuallyInKana = true;
|
|
1605
1609
|
if (kanjiDic && word.kanjiForms) {
|
|
1606
1610
|
word.kanji = [];
|
|
1607
1611
|
for (const kanjiForm of word.kanjiForms)
|
|
@@ -1675,11 +1679,17 @@ function getWord(dict, id, kanjiDic, examples, dictWord, noteTypeName, deckPath)
|
|
|
1675
1679
|
];
|
|
1676
1680
|
}
|
|
1677
1681
|
}
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1682
|
+
examples = examples.filter(
|
|
1683
|
+
(example, index, arr) => arr.findIndex(
|
|
1684
|
+
(ex) => ex.phrase === example.phrase
|
|
1685
|
+
) === index
|
|
1686
|
+
);
|
|
1687
|
+
if (examples.length > 0)
|
|
1688
|
+
word.phrases = (examples.length > 5 ? examples.slice(0, 5) : examples).map((ex) => ({
|
|
1689
|
+
phrase: ex.furigana ?? ex.phrase,
|
|
1690
|
+
translation: ex.translation,
|
|
1691
|
+
originalPhrase: ex.phrase
|
|
1692
|
+
}));
|
|
1683
1693
|
}
|
|
1684
1694
|
return word;
|
|
1685
1695
|
} else throw new Error(`Word${id ? ` ${id}` : ""} not found`);
|
|
@@ -1973,11 +1983,8 @@ function generateAnkiNote(entry) {
|
|
|
1973
1983
|
const fields = [];
|
|
1974
1984
|
if (isWord(entry)) {
|
|
1975
1985
|
if (!entry.translations) throw new Error(`Invalid word: ${entry.noteID}`);
|
|
1976
|
-
const usuallyInKana = entry.translations.every(
|
|
1977
|
-
(translation) => translation.notes && translation.notes.includes("Word usually written using kana alone")
|
|
1978
|
-
);
|
|
1979
1986
|
fields.push(
|
|
1980
|
-
...entry.kanjiForms && !usuallyInKana ? [
|
|
1987
|
+
...entry.kanjiForms && !entry.usuallyInKana ? [
|
|
1981
1988
|
entry.kanjiForms.map(
|
|
1982
1989
|
(kanjiFormEntry, index) => `${index > 0 ? "<details><summary>Show kanji form</summary>" : ""}${createEntry(`<span class="word word-kanjiform">${index === 0 ? "<ruby><rb>" : ""}${kanjiFormEntry.kanjiForm}${index === 0 ? `</rb><rt>${entry.readings[0].reading}</rt></ruby>` : ""}</span>`, kanjiFormEntry.notes)}${index > 0 ? "</details>" : ""}`
|
|
1983
1990
|
).join(""),
|