henkan 0.3.0 → 0.3.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.
Files changed (55) hide show
  1. package/dist/index.cjs.js +26 -23
  2. package/dist/index.cjs.js.map +2 -2
  3. package/dist/index.mjs +26 -23
  4. package/dist/index.mjs.map +2 -2
  5. package/dist/types/utils.d.ts.map +1 -1
  6. package/docs/api/functions/capitalizeString.md +1 -1
  7. package/docs/api/functions/convertJMdict.md +1 -1
  8. package/docs/api/functions/convertKanjiDic.md +1 -1
  9. package/docs/api/functions/convertKradFile.md +1 -1
  10. package/docs/api/functions/convertRadkFile.md +1 -1
  11. package/docs/api/functions/convertTanakaCorpus.md +1 -1
  12. package/docs/api/functions/generateAnkiNote.md +1 -1
  13. package/docs/api/functions/generateAnkiNotesFile.md +1 -1
  14. package/docs/api/functions/getKanji.md +1 -1
  15. package/docs/api/functions/getKanjiExtended.md +1 -1
  16. package/docs/api/functions/getWord.md +1 -1
  17. package/docs/api/functions/isStringArray.md +1 -1
  18. package/docs/api/functions/isValidArray.md +1 -1
  19. package/docs/api/functions/isValidArrayWithFirstElement.md +1 -1
  20. package/docs/api/functions/makeSSML.md +1 -1
  21. package/docs/api/functions/shuffleArray.md +1 -1
  22. package/docs/api/functions/synthesizeSpeech.md +1 -1
  23. package/docs/api/interfaces/DictKanji.md +5 -5
  24. package/docs/api/interfaces/DictKanjiForm.md +4 -4
  25. package/docs/api/interfaces/DictKanjiMisc.md +5 -5
  26. package/docs/api/interfaces/DictKanjiReading.md +3 -3
  27. package/docs/api/interfaces/DictKanjiReadingMeaning.md +3 -3
  28. package/docs/api/interfaces/DictKanjiReadingMeaningGroup.md +3 -3
  29. package/docs/api/interfaces/DictKanjiWithRadicals.md +3 -3
  30. package/docs/api/interfaces/DictMeaning.md +11 -11
  31. package/docs/api/interfaces/DictRadical.md +4 -4
  32. package/docs/api/interfaces/DictReading.md +5 -5
  33. package/docs/api/interfaces/DictWord.md +7 -7
  34. package/docs/api/interfaces/ExamplePart.md +7 -7
  35. package/docs/api/interfaces/Grammar.md +15 -15
  36. package/docs/api/interfaces/GrammarMeaning.md +3 -3
  37. package/docs/api/interfaces/Kana.md +11 -11
  38. package/docs/api/interfaces/Kanji.md +22 -22
  39. package/docs/api/interfaces/KanjiComponent.md +3 -3
  40. package/docs/api/interfaces/KanjiForm.md +4 -4
  41. package/docs/api/interfaces/NoteAndTag.md +3 -3
  42. package/docs/api/interfaces/Phrase.md +4 -4
  43. package/docs/api/interfaces/Radical.md +16 -16
  44. package/docs/api/interfaces/Reading.md +5 -5
  45. package/docs/api/interfaces/ResultEntry.md +7 -7
  46. package/docs/api/interfaces/TanakaExample.md +5 -5
  47. package/docs/api/interfaces/Translation.md +3 -3
  48. package/docs/api/interfaces/UsefulRegExps.md +9 -9
  49. package/docs/api/interfaces/Word.md +14 -14
  50. package/docs/api/type-aliases/Dict.md +1 -1
  51. package/docs/api/type-aliases/DictName.md +1 -1
  52. package/docs/api/type-aliases/EntryType.md +1 -1
  53. package/docs/api/type-aliases/JLPT.md +1 -1
  54. package/docs/api/type-aliases/Result.md +1 -1
  55. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1171,13 +1171,15 @@ function convertJMdict(xmlString, examples) {
1171
1171
  const dict = [];
1172
1172
  xml.parseString(dictParsed, (err, result) => {
1173
1173
  if (err) throw err;
1174
- let tanakaBaseParts = void 0;
1175
- if (examples)
1176
- tanakaBaseParts = new Set(
1177
- examples.map(
1178
- (example) => example.parts.map((part) => part.baseForm)
1179
- ).flat()
1180
- );
1174
+ const tanakaParts = examples && examples.length > 0 ? new Set(
1175
+ examples.map(
1176
+ (example) => example.parts.map((part) => [
1177
+ part.baseForm,
1178
+ ...part.reading ? [part.reading] : [],
1179
+ ...part.referenceID ? [part.referenceID] : []
1180
+ ])
1181
+ ).flat(2)
1182
+ ) : void 0;
1181
1183
  if (result.JMdict && typeof result.JMdict === "object" && isValidArray(result.JMdict.entry))
1182
1184
  for (const entry of result.JMdict.entry) {
1183
1185
  const entryObj = {
@@ -1261,36 +1263,36 @@ function convertJMdict(xmlString, examples) {
1261
1263
  if (examples) {
1262
1264
  const readings2 = new Set(
1263
1265
  entryObj.readings.filter(
1264
- (reading) => !reading.notes || !reading.notes.some(
1266
+ (reading) => (!reading.notes || !reading.notes.some(
1265
1267
  (note) => notSearchedForms.has(note)
1266
- )
1268
+ )) && (entryObj.isCommon === void 0 || reading.commonness && reading.commonness.length > 0)
1267
1269
  ).map((reading) => reading.reading)
1268
1270
  );
1269
1271
  const kanjiForms2 = entryObj.kanjiForms ? new Set(
1270
1272
  entryObj.kanjiForms.filter(
1271
- (kanjiForm) => !kanjiForm.notes || !kanjiForm.notes.some(
1273
+ (kanjiForm) => (!kanjiForm.notes || !kanjiForm.notes.some(
1272
1274
  (note) => notSearchedForms.has(note)
1273
- )
1275
+ )) && (entryObj.isCommon === void 0 || kanjiForm.commonness && kanjiForm.commonness.length > 0)
1274
1276
  ).map((kanjiForm) => kanjiForm.form)
1275
1277
  ) : void 0;
1276
- let kanjiFormExamples = false;
1277
- let readingExamples = false;
1278
- if (kanjiForms2 && kanjiForms2.size > 0 && tanakaBaseParts) {
1278
+ let existsExample = false;
1279
+ if (kanjiForms2 && kanjiForms2.size > 0 && tanakaParts) {
1279
1280
  for (const kf of kanjiForms2)
1280
- if (tanakaBaseParts.has(kf)) {
1281
- kanjiFormExamples = true;
1281
+ if (tanakaParts.has(kf)) {
1282
+ existsExample = true;
1282
1283
  break;
1283
1284
  }
1284
1285
  }
1285
- if ((!kanjiFormExamples || entryObj.isCommon === true) && readings2.size > 0 && tanakaBaseParts) {
1286
+ if (!existsExample && readings2.size > 0 && tanakaParts) {
1286
1287
  for (const r of readings2)
1287
- if (tanakaBaseParts.has(r)) {
1288
- readingExamples = true;
1288
+ if (tanakaParts.has(r)) {
1289
+ existsExample = true;
1289
1290
  break;
1290
1291
  }
1291
1292
  }
1292
- if (kanjiFormExamples || readingExamples)
1293
- entryObj.hasPhrases = true;
1293
+ if (!existsExample && tanakaParts && tanakaParts.has(entryObj.id))
1294
+ existsExample = true;
1295
+ if (existsExample) entryObj.hasPhrases = true;
1294
1296
  }
1295
1297
  if (entryObj.id.length > 0 && entryObj.readings.length > 0 && entryObj.meanings.length > 0)
1296
1298
  dict.push(entryObj);
@@ -1545,9 +1547,10 @@ function lookupWordNote(key, notes, tags, required, fallback) {
1545
1547
  if (notes) notes.push(fallback ?? key);
1546
1548
  return { note: fallback ?? key };
1547
1549
  }
1548
- if (tags) tags.push(`word::${info[0]}`);
1550
+ const tag = `word::${info[0]}`;
1551
+ if (tags && !tags.includes(tag)) tags.push(tag);
1549
1552
  if (notes) notes.push(info[1]);
1550
- return { note: info[1], tag: `word::${info[0]}` };
1553
+ return { note: info[1], tag };
1551
1554
  }
1552
1555
  var wordAddNoteArray = (arr, cb) => {
1553
1556
  if (!arr) return;