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.cjs.js CHANGED
@@ -1225,13 +1225,15 @@ function convertJMdict(xmlString, examples) {
1225
1225
  const dict = [];
1226
1226
  import_xml2js.default.parseString(dictParsed, (err, result) => {
1227
1227
  if (err) throw err;
1228
- let tanakaBaseParts = void 0;
1229
- if (examples)
1230
- tanakaBaseParts = new Set(
1231
- examples.map(
1232
- (example) => example.parts.map((part) => part.baseForm)
1233
- ).flat()
1234
- );
1228
+ const tanakaParts = examples && examples.length > 0 ? new Set(
1229
+ examples.map(
1230
+ (example) => example.parts.map((part) => [
1231
+ part.baseForm,
1232
+ ...part.reading ? [part.reading] : [],
1233
+ ...part.referenceID ? [part.referenceID] : []
1234
+ ])
1235
+ ).flat(2)
1236
+ ) : void 0;
1235
1237
  if (result.JMdict && typeof result.JMdict === "object" && isValidArray(result.JMdict.entry))
1236
1238
  for (const entry of result.JMdict.entry) {
1237
1239
  const entryObj = {
@@ -1315,36 +1317,36 @@ function convertJMdict(xmlString, examples) {
1315
1317
  if (examples) {
1316
1318
  const readings2 = new Set(
1317
1319
  entryObj.readings.filter(
1318
- (reading) => !reading.notes || !reading.notes.some(
1320
+ (reading) => (!reading.notes || !reading.notes.some(
1319
1321
  (note) => notSearchedForms.has(note)
1320
- )
1322
+ )) && (entryObj.isCommon === void 0 || reading.commonness && reading.commonness.length > 0)
1321
1323
  ).map((reading) => reading.reading)
1322
1324
  );
1323
1325
  const kanjiForms2 = entryObj.kanjiForms ? new Set(
1324
1326
  entryObj.kanjiForms.filter(
1325
- (kanjiForm) => !kanjiForm.notes || !kanjiForm.notes.some(
1327
+ (kanjiForm) => (!kanjiForm.notes || !kanjiForm.notes.some(
1326
1328
  (note) => notSearchedForms.has(note)
1327
- )
1329
+ )) && (entryObj.isCommon === void 0 || kanjiForm.commonness && kanjiForm.commonness.length > 0)
1328
1330
  ).map((kanjiForm) => kanjiForm.form)
1329
1331
  ) : void 0;
1330
- let kanjiFormExamples = false;
1331
- let readingExamples = false;
1332
- if (kanjiForms2 && kanjiForms2.size > 0 && tanakaBaseParts) {
1332
+ let existsExample = false;
1333
+ if (kanjiForms2 && kanjiForms2.size > 0 && tanakaParts) {
1333
1334
  for (const kf of kanjiForms2)
1334
- if (tanakaBaseParts.has(kf)) {
1335
- kanjiFormExamples = true;
1335
+ if (tanakaParts.has(kf)) {
1336
+ existsExample = true;
1336
1337
  break;
1337
1338
  }
1338
1339
  }
1339
- if ((!kanjiFormExamples || entryObj.isCommon === true) && readings2.size > 0 && tanakaBaseParts) {
1340
+ if (!existsExample && readings2.size > 0 && tanakaParts) {
1340
1341
  for (const r of readings2)
1341
- if (tanakaBaseParts.has(r)) {
1342
- readingExamples = true;
1342
+ if (tanakaParts.has(r)) {
1343
+ existsExample = true;
1343
1344
  break;
1344
1345
  }
1345
1346
  }
1346
- if (kanjiFormExamples || readingExamples)
1347
- entryObj.hasPhrases = true;
1347
+ if (!existsExample && tanakaParts && tanakaParts.has(entryObj.id))
1348
+ existsExample = true;
1349
+ if (existsExample) entryObj.hasPhrases = true;
1348
1350
  }
1349
1351
  if (entryObj.id.length > 0 && entryObj.readings.length > 0 && entryObj.meanings.length > 0)
1350
1352
  dict.push(entryObj);
@@ -1599,9 +1601,10 @@ function lookupWordNote(key, notes, tags, required, fallback) {
1599
1601
  if (notes) notes.push(fallback != null ? fallback : key);
1600
1602
  return { note: fallback != null ? fallback : key };
1601
1603
  }
1602
- if (tags) tags.push(`word::${info[0]}`);
1604
+ const tag = `word::${info[0]}`;
1605
+ if (tags && !tags.includes(tag)) tags.push(tag);
1603
1606
  if (notes) notes.push(info[1]);
1604
- return { note: info[1], tag: `word::${info[0]}` };
1607
+ return { note: info[1], tag };
1605
1608
  }
1606
1609
  var wordAddNoteArray = (arr, cb) => {
1607
1610
  if (!arr) return;