henkan 0.0.3 → 0.1.1

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.
Files changed (56) hide show
  1. package/dist/index.cjs.js +24 -17
  2. package/dist/index.cjs.js.map +2 -2
  3. package/dist/index.mjs +21 -14
  4. package/dist/index.mjs.map +2 -2
  5. package/dist/types/types.d.ts +10 -0
  6. package/dist/types/types.d.ts.map +1 -1
  7. package/dist/types/utils.d.ts.map +1 -1
  8. package/docs/api/functions/capitalizeString.md +1 -1
  9. package/docs/api/functions/convertJMdict.md +1 -1
  10. package/docs/api/functions/convertKanjiDic.md +1 -1
  11. package/docs/api/functions/convertKradFile.md +1 -1
  12. package/docs/api/functions/convertRadkFile.md +1 -1
  13. package/docs/api/functions/convertTanakaCorpus.md +1 -1
  14. package/docs/api/functions/generateAnkiNote.md +1 -1
  15. package/docs/api/functions/generateAnkiNotesFile.md +3 -3
  16. package/docs/api/functions/getKanji.md +1 -1
  17. package/docs/api/functions/getKanjiExtended.md +1 -1
  18. package/docs/api/functions/getWord.md +1 -1
  19. package/docs/api/functions/isStringArray.md +1 -1
  20. package/docs/api/functions/isValidArray.md +1 -1
  21. package/docs/api/functions/isValidArrayWithFirstElement.md +1 -1
  22. package/docs/api/functions/makeSSML.md +1 -1
  23. package/docs/api/functions/shuffleArray.md +1 -1
  24. package/docs/api/functions/synthesizeSpeech.md +3 -3
  25. package/docs/api/interfaces/DictKanji.md +4 -4
  26. package/docs/api/interfaces/DictKanjiForm.md +4 -4
  27. package/docs/api/interfaces/DictKanjiMisc.md +5 -5
  28. package/docs/api/interfaces/DictKanjiReading.md +3 -3
  29. package/docs/api/interfaces/DictKanjiReadingMeaning.md +3 -3
  30. package/docs/api/interfaces/DictKanjiReadingMeaningGroup.md +3 -3
  31. package/docs/api/interfaces/DictKanjiWithRadicals.md +3 -3
  32. package/docs/api/interfaces/DictMeaning.md +11 -11
  33. package/docs/api/interfaces/DictRadical.md +4 -4
  34. package/docs/api/interfaces/DictReading.md +5 -5
  35. package/docs/api/interfaces/DictWord.md +5 -5
  36. package/docs/api/interfaces/ExamplePart.md +7 -7
  37. package/docs/api/interfaces/Grammar.md +28 -14
  38. package/docs/api/interfaces/GrammarMeaning.md +3 -3
  39. package/docs/api/interfaces/Kana.md +24 -10
  40. package/docs/api/interfaces/Kanji.md +34 -20
  41. package/docs/api/interfaces/KanjiComponent.md +3 -3
  42. package/docs/api/interfaces/KanjiForm.md +3 -3
  43. package/docs/api/interfaces/Phrase.md +4 -4
  44. package/docs/api/interfaces/Radical.md +29 -15
  45. package/docs/api/interfaces/Reading.md +4 -4
  46. package/docs/api/interfaces/ResultEntry.md +16 -6
  47. package/docs/api/interfaces/TanakaExample.md +5 -5
  48. package/docs/api/interfaces/Translation.md +3 -3
  49. package/docs/api/interfaces/UsefulRegExps.md +9 -9
  50. package/docs/api/interfaces/Word.md +38 -12
  51. package/docs/api/type-aliases/Dict.md +1 -1
  52. package/docs/api/type-aliases/DictName.md +1 -1
  53. package/docs/api/type-aliases/EntryType.md +1 -1
  54. package/docs/api/type-aliases/JLPT.md +1 -1
  55. package/docs/api/type-aliases/Result.md +1 -1
  56. package/package.json +10 -10
package/dist/index.cjs.js CHANGED
@@ -1592,6 +1592,7 @@ function getWord(dict, id, kanjiDic, examples, dictWord, noteTypeName, deckPath)
1592
1592
  } : {}
1593
1593
  };
1594
1594
  });
1595
+ let usuallyInKanaMeanings = 0;
1595
1596
  word.translations = dictWord.meanings.map((dictMeaning) => {
1596
1597
  if (!dictMeaning.translations)
1597
1598
  throw new Error(`No translations for ${dictWord.id}`);
@@ -1645,10 +1646,11 @@ function getWord(dict, id, kanjiDic, examples, dictWord, noteTypeName, deckPath)
1645
1646
  dictMeaning.info,
1646
1647
  (info) => lookupWordNote(info, notes, word.tags, false, info)
1647
1648
  );
1648
- wordAddNoteArray(
1649
- dictMeaning.misc,
1650
- (misc) => lookupWordNote(misc, notes, word.tags, false, misc)
1651
- );
1649
+ wordAddNoteArray(dictMeaning.misc, (misc) => {
1650
+ lookupWordNote(misc, notes, word.tags, false, misc);
1651
+ if (misc.toLowerCase() === "word usually written using kana alone")
1652
+ usuallyInKanaMeanings++;
1653
+ });
1652
1654
  for (let i = 0; i < notes.length; i++)
1653
1655
  notes[i] = capitalizeString(notes[i]);
1654
1656
  return {
@@ -1656,6 +1658,8 @@ function getWord(dict, id, kanjiDic, examples, dictWord, noteTypeName, deckPath)
1656
1658
  notes
1657
1659
  };
1658
1660
  });
1661
+ if (word.translations && word.translations.length === usuallyInKanaMeanings)
1662
+ word.usuallyInKana = true;
1659
1663
  if (kanjiDic && word.kanjiForms) {
1660
1664
  word.kanji = [];
1661
1665
  for (const kanjiForm of word.kanjiForms)
@@ -1729,14 +1733,20 @@ function getWord(dict, id, kanjiDic, examples, dictWord, noteTypeName, deckPath)
1729
1733
  ];
1730
1734
  }
1731
1735
  }
1732
- word.phrases = (examples.length > 5 ? examples.slice(0, 5) : examples).map((ex) => {
1733
- var _a;
1734
- return {
1735
- phrase: (_a = ex.furigana) != null ? _a : ex.phrase,
1736
- translation: ex.translation,
1737
- originalPhrase: ex.phrase
1738
- };
1739
- });
1736
+ examples = examples.filter(
1737
+ (example, index, arr) => arr.findIndex(
1738
+ (ex) => ex.phrase === example.phrase
1739
+ ) === index
1740
+ );
1741
+ if (examples.length > 0)
1742
+ word.phrases = (examples.length > 5 ? examples.slice(0, 5) : examples).map((ex) => {
1743
+ var _a;
1744
+ return {
1745
+ phrase: (_a = ex.furigana) != null ? _a : ex.phrase,
1746
+ translation: ex.translation,
1747
+ originalPhrase: ex.phrase
1748
+ };
1749
+ });
1740
1750
  }
1741
1751
  return word;
1742
1752
  } else throw new Error(`Word${id ? ` ${id}` : ""} not found`);
@@ -2030,11 +2040,8 @@ function generateAnkiNote(entry) {
2030
2040
  const fields = [];
2031
2041
  if (isWord(entry)) {
2032
2042
  if (!entry.translations) throw new Error(`Invalid word: ${entry.noteID}`);
2033
- const usuallyInKana = entry.translations.every(
2034
- (translation) => translation.notes && translation.notes.includes("Word usually written using kana alone")
2035
- );
2036
2043
  fields.push(
2037
- ...entry.kanjiForms && !usuallyInKana ? [
2044
+ ...entry.kanjiForms && !entry.usuallyInKana ? [
2038
2045
  entry.kanjiForms.map(
2039
2046
  (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>" : ""}`
2040
2047
  ).join(""),
@@ -2209,7 +2216,7 @@ function generateAnkiNotesFile(list) {
2209
2216
  "#notetype column:2",
2210
2217
  "#deck column:3"
2211
2218
  ];
2212
- const ankiNotes = list.map((result) => {
2219
+ const ankiNotes = list.filter((result) => result.doNotCreateNote === void 0).map((result) => {
2213
2220
  if (!result.noteID || !result.noteTypeName || !result.deckPath)
2214
2221
  throw new Error("Invalid result");
2215
2222
  const note = generateAnkiNote(result);