henkan 0.1.1 → 0.1.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 (57) hide show
  1. package/dist/index.cjs.js +42 -4
  2. package/dist/index.cjs.js.map +3 -3
  3. package/dist/index.mjs +42 -4
  4. package/dist/index.mjs.map +3 -3
  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 +2 -1
  8. package/dist/types/utils.d.ts.map +1 -1
  9. package/docs/api/functions/capitalizeString.md +1 -1
  10. package/docs/api/functions/convertJMdict.md +8 -2
  11. package/docs/api/functions/convertKanjiDic.md +1 -1
  12. package/docs/api/functions/convertKradFile.md +1 -1
  13. package/docs/api/functions/convertRadkFile.md +1 -1
  14. package/docs/api/functions/convertTanakaCorpus.md +1 -1
  15. package/docs/api/functions/generateAnkiNote.md +1 -1
  16. package/docs/api/functions/generateAnkiNotesFile.md +1 -1
  17. package/docs/api/functions/getKanji.md +1 -1
  18. package/docs/api/functions/getKanjiExtended.md +1 -1
  19. package/docs/api/functions/getWord.md +1 -1
  20. package/docs/api/functions/isStringArray.md +1 -1
  21. package/docs/api/functions/isValidArray.md +1 -1
  22. package/docs/api/functions/isValidArrayWithFirstElement.md +1 -1
  23. package/docs/api/functions/makeSSML.md +1 -1
  24. package/docs/api/functions/shuffleArray.md +1 -1
  25. package/docs/api/functions/synthesizeSpeech.md +1 -1
  26. package/docs/api/interfaces/DictKanji.md +4 -4
  27. package/docs/api/interfaces/DictKanjiForm.md +4 -4
  28. package/docs/api/interfaces/DictKanjiMisc.md +5 -5
  29. package/docs/api/interfaces/DictKanjiReading.md +3 -3
  30. package/docs/api/interfaces/DictKanjiReadingMeaning.md +3 -3
  31. package/docs/api/interfaces/DictKanjiReadingMeaningGroup.md +3 -3
  32. package/docs/api/interfaces/DictKanjiWithRadicals.md +3 -3
  33. package/docs/api/interfaces/DictMeaning.md +11 -11
  34. package/docs/api/interfaces/DictRadical.md +4 -4
  35. package/docs/api/interfaces/DictReading.md +5 -5
  36. package/docs/api/interfaces/DictWord.md +27 -5
  37. package/docs/api/interfaces/ExamplePart.md +7 -7
  38. package/docs/api/interfaces/Grammar.md +15 -15
  39. package/docs/api/interfaces/GrammarMeaning.md +3 -3
  40. package/docs/api/interfaces/Kana.md +11 -11
  41. package/docs/api/interfaces/Kanji.md +21 -21
  42. package/docs/api/interfaces/KanjiComponent.md +3 -3
  43. package/docs/api/interfaces/KanjiForm.md +3 -3
  44. package/docs/api/interfaces/Phrase.md +4 -4
  45. package/docs/api/interfaces/Radical.md +16 -16
  46. package/docs/api/interfaces/Reading.md +4 -4
  47. package/docs/api/interfaces/ResultEntry.md +7 -7
  48. package/docs/api/interfaces/TanakaExample.md +5 -5
  49. package/docs/api/interfaces/Translation.md +3 -3
  50. package/docs/api/interfaces/UsefulRegExps.md +9 -9
  51. package/docs/api/interfaces/Word.md +14 -14
  52. package/docs/api/type-aliases/Dict.md +1 -1
  53. package/docs/api/type-aliases/DictName.md +1 -1
  54. package/docs/api/type-aliases/EntryType.md +1 -1
  55. package/docs/api/type-aliases/JLPT.md +1 -1
  56. package/docs/api/type-aliases/Result.md +1 -1
  57. package/package.json +1 -1
package/dist/index.cjs.js CHANGED
@@ -1203,7 +1203,7 @@ function shuffleArray(arr) {
1203
1203
  }
1204
1204
  return a;
1205
1205
  }
1206
- function convertJMdict(xmlString) {
1206
+ function convertJMdict(xmlString, examples) {
1207
1207
  try {
1208
1208
  const dictParsed = import_libxmljs2.default.parseXml(xmlString, {
1209
1209
  dtdvalid: true,
@@ -1237,8 +1237,10 @@ function convertJMdict(xmlString) {
1237
1237
  );
1238
1238
  if (isStringArray(kanjiForm.ke_inf))
1239
1239
  form.notes = kanjiForm.ke_inf;
1240
- if (isStringArray(kanjiForm.ke_pri))
1240
+ if (isStringArray(kanjiForm.ke_pri)) {
1241
1241
  form.commonness = kanjiForm.ke_pri;
1242
+ if (entryObj.isCommon === void 0) entryObj.isCommon = true;
1243
+ }
1242
1244
  if (form.form.length > 0) entryObj.kanjiForms.push(form);
1243
1245
  }
1244
1246
  }
@@ -1251,10 +1253,12 @@ function convertJMdict(xmlString) {
1251
1253
  throw new Error(`Invalid JMdict entry reading: ${entryObj.id}`);
1252
1254
  if (isStringArray(reading.re_inf))
1253
1255
  readingObj.notes = reading.re_inf;
1254
- if (isStringArray(reading.re_pri))
1255
- readingObj.commonness = reading.re_pri;
1256
1256
  if (isStringArray(reading.re_restr))
1257
1257
  readingObj.kanjiFormRestrictions = reading.re_restr;
1258
+ if (isStringArray(reading.re_pri)) {
1259
+ readingObj.commonness = reading.re_pri;
1260
+ if (entryObj.isCommon === void 0) entryObj.isCommon = true;
1261
+ }
1258
1262
  if (readingObj.reading.length > 0)
1259
1263
  entryObj.readings.push(readingObj);
1260
1264
  }
@@ -1290,6 +1294,40 @@ function convertJMdict(xmlString) {
1290
1294
  if (meaningObj.partOfSpeech && meaningObj.partOfSpeech.length > 0 || meaningObj.translations && meaningObj.translations.length > 0)
1291
1295
  entryObj.meanings.push(meaningObj);
1292
1296
  }
1297
+ if (examples) {
1298
+ const readings2 = new Set(
1299
+ entryObj.readings.filter(
1300
+ (reading) => !reading.notes || reading.notes && !reading.notes.some(
1301
+ (note) => notSearchedForms.has(note)
1302
+ )
1303
+ ).map((reading) => reading.reading)
1304
+ );
1305
+ const kanjiForms2 = entryObj.kanjiForms ? new Set(
1306
+ entryObj.kanjiForms.map(
1307
+ (kanjiForm) => kanjiForm.form
1308
+ )
1309
+ ) : void 0;
1310
+ let kanjiFormExamples = false;
1311
+ let readingExamples = false;
1312
+ if (kanjiForms2) {
1313
+ outer: for (const example of examples)
1314
+ for (const part of example.parts)
1315
+ if (kanjiForms2.has(part.baseForm)) {
1316
+ kanjiFormExamples = true;
1317
+ break outer;
1318
+ }
1319
+ }
1320
+ if (!kanjiFormExamples) {
1321
+ outer: for (const example of examples)
1322
+ for (const part of example.parts)
1323
+ if (readings2.has(part.baseForm)) {
1324
+ readingExamples = true;
1325
+ break outer;
1326
+ }
1327
+ }
1328
+ if (kanjiFormExamples || readingExamples)
1329
+ entryObj.hasPhrases = true;
1330
+ }
1293
1331
  if (entryObj.id.length > 0 && entryObj.readings.length > 0 && entryObj.meanings.length > 0)
1294
1332
  dict.push(entryObj);
1295
1333
  }