henkan 3.0.0 → 3.0.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.
package/dist/index.mjs CHANGED
@@ -1364,7 +1364,6 @@ function convertJMdict(xmlString, examples) {
1364
1364
  (example) => example.parts.flatMap((part) => [
1365
1365
  part.baseForm,
1366
1366
  ...part.reading !== void 0 ? [part.reading] : [],
1367
- ...part.inflectedForm !== void 0 ? [part.inflectedForm] : [],
1368
1367
  ...part.referenceID !== void 0 ? [part.referenceID] : []
1369
1368
  ])
1370
1369
  )
@@ -1490,7 +1489,6 @@ function convertJMnedict(xmlString, examples) {
1490
1489
  (example) => example.parts.flatMap((part) => [
1491
1490
  part.baseForm,
1492
1491
  ...part.reading !== void 0 ? [part.reading] : [],
1493
- ...part.inflectedForm !== void 0 ? [part.inflectedForm] : [],
1494
1492
  ...part.referenceID !== void 0 ? [part.referenceID] : []
1495
1493
  ])
1496
1494
  )
@@ -1834,14 +1832,6 @@ function createEntryMaps(jmDict, jmNedict, kanjiDic, tanakaExamples, wordDefinit
1834
1832
  if (exList === void 0) partExamplesMap.set(part.reading, [ex]);
1835
1833
  else exList.push(ex);
1836
1834
  }
1837
- if (part.inflectedForm !== void 0 && entryParts.has(part.inflectedForm)) {
1838
- const exList = partExamplesMap.get(
1839
- part.inflectedForm
1840
- );
1841
- if (exList === void 0)
1842
- partExamplesMap.set(part.inflectedForm, [ex]);
1843
- else exList.push(ex);
1844
- }
1845
1835
  if (part.referenceID !== void 0 && entryParts.has(part.referenceID)) {
1846
1836
  const exList = partExamplesMap.get(
1847
1837
  part.referenceID
@@ -1911,14 +1901,6 @@ function createEntryMaps(jmDict, jmNedict, kanjiDic, tanakaExamples, wordDefinit
1911
1901
  if (exList === void 0) partExamplesMap.set(part.reading, [ex]);
1912
1902
  else exList.push(ex);
1913
1903
  }
1914
- if (part.inflectedForm !== void 0 && entryParts.has(part.inflectedForm)) {
1915
- const exList = partExamplesMap.get(
1916
- part.inflectedForm
1917
- );
1918
- if (exList === void 0)
1919
- partExamplesMap.set(part.inflectedForm, [ex]);
1920
- else exList.push(ex);
1921
- }
1922
1904
  }
1923
1905
  for (const name of jmNedict) {
1924
1906
  const seenEx = /* @__PURE__ */ new Set();
@@ -2722,37 +2704,42 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
2722
2704
  const readingMatchingKanjiFormExamples = [];
2723
2705
  let kanjiFormExamples = [];
2724
2706
  let readingExamples = [];
2707
+ let hasKanjiFormExamplesWithTranslation = false;
2708
+ let hasReadingExamplesWithTranslation = false;
2725
2709
  for (const example of exampleList)
2726
2710
  for (let i = 0; i < example.parts.length; i++) {
2727
2711
  if (seenPhrases.has(example.phrase)) break;
2728
- const includesTranslation = meanings.some(
2729
- (m) => example.translation.includes(m)
2730
- );
2731
2712
  const part = example.parts[i];
2732
2713
  const readingAsReadingMatch = part.reading !== void 0 && readings.has(part.reading);
2733
- const readingAsInflectedFormMatch = part.inflectedForm !== void 0 && readings.has(part.inflectedForm);
2734
2714
  const referenceIDMatch = part.referenceID === dictWord.id;
2735
2715
  if (kanjiForms !== void 0 && kanjiForms.has(part.baseForm)) {
2736
- if (readingAsReadingMatch || readingAsInflectedFormMatch || referenceIDMatch)
2716
+ if (readingAsReadingMatch || referenceIDMatch)
2737
2717
  readingMatchingKanjiFormExamples.push({
2738
2718
  ex: example,
2739
- partIndex: i,
2740
- form: part.baseForm,
2741
- ...referenceIDMatch ? { referenceIDMatch: true } : {},
2742
- ...includesTranslation ? { includesTranslation: true } : {}
2719
+ partIndex: i
2743
2720
  });
2744
- else
2721
+ else {
2722
+ const includesTranslation = meanings.some(
2723
+ (m) => example.translation.includes(m)
2724
+ );
2725
+ if (!hasKanjiFormExamplesWithTranslation && includesTranslation)
2726
+ hasKanjiFormExamplesWithTranslation = true;
2745
2727
  kanjiFormExamples.push({
2746
2728
  ex: example,
2747
2729
  partIndex: i,
2748
- form: part.baseForm,
2749
2730
  ...includesTranslation ? { includesTranslation: true } : {}
2750
2731
  });
2732
+ }
2751
2733
  seenPhrases.add(example.phrase);
2752
2734
  break;
2753
2735
  }
2754
2736
  const readingAsBaseFormMatch = readings.has(part.baseForm);
2755
2737
  if ((readingAsBaseFormMatch || referenceIDMatch) && kanjiForms === void 0) {
2738
+ const includesTranslation = meanings.some(
2739
+ (m) => example.translation.includes(m)
2740
+ );
2741
+ if (!hasReadingExamplesWithTranslation && includesTranslation)
2742
+ hasReadingExamplesWithTranslation = true;
2756
2743
  readingExamples.push({
2757
2744
  ex: example,
2758
2745
  partIndex: i,
@@ -2763,21 +2750,13 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
2763
2750
  break;
2764
2751
  }
2765
2752
  }
2766
- if (kanjiFormExamples.length > 0 && kanjiFormExamples.some(
2767
- (ex) => ex.includesTranslation === true || ex.ex.parts.some(
2768
- (part) => ex.form === part.baseForm && part.glossNumber !== void 0
2769
- )
2770
- ))
2753
+ if (kanjiFormExamples.length > 0 && hasKanjiFormExamplesWithTranslation)
2771
2754
  kanjiFormExamples = kanjiFormExamples.filter(
2772
- (ex) => ex.includesTranslation === true || ex.ex.parts.some(
2773
- (part) => ex.form === part.baseForm && part.glossNumber !== void 0
2774
- )
2755
+ (ex) => ex.includesTranslation === true
2775
2756
  );
2776
2757
  else if (kanjiFormExamples.length > 0 && readingMatchingKanjiFormExamples.length > 0)
2777
2758
  kanjiFormExamples.length = 0;
2778
- if (readingExamples.length > 0 && readingExamples.some(
2779
- (ex) => ex.includesTranslation === true || ex.referenceIDMatch === true
2780
- ))
2759
+ if (readingExamples.length > 0 && hasReadingExamplesWithTranslation)
2781
2760
  readingExamples = readingExamples.filter(
2782
2761
  (ex) => ex.includesTranslation === true || ex.referenceIDMatch === true
2783
2762
  );
@@ -2954,29 +2933,32 @@ function getName(searchedName, dict, kanjiDic, examples, noteTypeName, deckPath)
2954
2933
  for (const example of exampleList)
2955
2934
  for (let i = 0; i < example.parts.length; i++) {
2956
2935
  if (seenPhrases.has(example.phrase)) break;
2957
- const includesTranslation = meanings.some(
2958
- (m) => example.translation.includes(m)
2959
- );
2960
2936
  const part = example.parts[i];
2961
2937
  const readingAsReadingMatch = part.reading !== void 0 && readings.has(part.reading);
2962
2938
  if (kanjiForms !== void 0 && kanjiForms.has(part.baseForm) && readingAsReadingMatch) {
2939
+ const includesTranslation = meanings.some(
2940
+ (m) => example.translation.includes(m)
2941
+ );
2942
+ if (!hasReadingMatchingKanjiFormWithTranslation && includesTranslation)
2943
+ hasReadingMatchingKanjiFormWithTranslation = true;
2963
2944
  readingMatchingKanjiFormExamples.push({
2964
2945
  ex: example,
2965
2946
  ...includesTranslation ? { includesTranslation: true } : {}
2966
2947
  });
2967
- if (!hasReadingMatchingKanjiFormWithTranslation && includesTranslation)
2968
- hasReadingMatchingKanjiFormWithTranslation = true;
2969
2948
  seenPhrases.add(example.phrase);
2970
2949
  break;
2971
2950
  }
2972
2951
  const readingAsBaseFormMatch = readings.has(part.baseForm);
2973
2952
  if (readingAsBaseFormMatch && kanjiForms === void 0) {
2953
+ const includesTranslation = meanings.some(
2954
+ (m) => example.translation.includes(m)
2955
+ );
2956
+ if (!hasReadingWithTranslation && includesTranslation)
2957
+ hasReadingWithTranslation = true;
2974
2958
  readingExamples.push({
2975
2959
  ex: example,
2976
2960
  ...includesTranslation ? { includesTranslation: true } : {}
2977
2961
  });
2978
- if (!hasReadingWithTranslation && includesTranslation)
2979
- hasReadingWithTranslation = true;
2980
2962
  seenPhrases.add(example.phrase);
2981
2963
  break;
2982
2964
  }