henkan 0.3.1 → 0.3.3
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.cjs.js +34 -31
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.mjs +34 -31
- package/dist/index.mjs.map +3 -3
- package/dist/types/utils.d.ts.map +1 -1
- package/docs/api/functions/capitalizeString.md +1 -1
- package/docs/api/functions/convertJMdict.md +1 -1
- package/docs/api/functions/convertKanjiDic.md +1 -1
- package/docs/api/functions/convertKradFile.md +1 -1
- package/docs/api/functions/convertRadkFile.md +1 -1
- package/docs/api/functions/convertTanakaCorpus.md +1 -1
- package/docs/api/functions/generateAnkiNote.md +1 -1
- package/docs/api/functions/generateAnkiNotesFile.md +1 -1
- package/docs/api/functions/getKanji.md +1 -1
- package/docs/api/functions/getKanjiExtended.md +1 -1
- package/docs/api/functions/getWord.md +1 -1
- package/docs/api/functions/isStringArray.md +1 -1
- package/docs/api/functions/isValidArray.md +1 -1
- package/docs/api/functions/isValidArrayWithFirstElement.md +1 -1
- package/docs/api/functions/makeSSML.md +1 -1
- package/docs/api/functions/shuffleArray.md +1 -1
- package/docs/api/functions/synthesizeSpeech.md +1 -1
- package/docs/api/interfaces/DictKanji.md +5 -5
- package/docs/api/interfaces/DictKanjiForm.md +4 -4
- package/docs/api/interfaces/DictKanjiMisc.md +5 -5
- package/docs/api/interfaces/DictKanjiReading.md +3 -3
- package/docs/api/interfaces/DictKanjiReadingMeaning.md +3 -3
- package/docs/api/interfaces/DictKanjiReadingMeaningGroup.md +3 -3
- package/docs/api/interfaces/DictKanjiWithRadicals.md +3 -3
- package/docs/api/interfaces/DictMeaning.md +11 -11
- package/docs/api/interfaces/DictRadical.md +4 -4
- package/docs/api/interfaces/DictReading.md +5 -5
- package/docs/api/interfaces/DictWord.md +7 -7
- package/docs/api/interfaces/ExamplePart.md +7 -7
- package/docs/api/interfaces/Grammar.md +15 -15
- package/docs/api/interfaces/GrammarMeaning.md +3 -3
- package/docs/api/interfaces/Kana.md +11 -11
- package/docs/api/interfaces/Kanji.md +22 -22
- package/docs/api/interfaces/KanjiComponent.md +3 -3
- package/docs/api/interfaces/KanjiForm.md +4 -4
- package/docs/api/interfaces/NoteAndTag.md +3 -3
- package/docs/api/interfaces/Phrase.md +4 -4
- package/docs/api/interfaces/Radical.md +16 -16
- package/docs/api/interfaces/Reading.md +5 -5
- package/docs/api/interfaces/ResultEntry.md +7 -7
- package/docs/api/interfaces/TanakaExample.md +5 -5
- package/docs/api/interfaces/Translation.md +3 -3
- package/docs/api/interfaces/UsefulRegExps.md +9 -9
- package/docs/api/interfaces/Word.md +14 -14
- package/docs/api/type-aliases/Dict.md +1 -1
- package/docs/api/type-aliases/DictName.md +1 -1
- package/docs/api/type-aliases/EntryType.md +1 -1
- package/docs/api/type-aliases/JLPT.md +1 -1
- package/docs/api/type-aliases/Result.md +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -70,7 +70,7 @@ var regexps = {
|
|
|
70
70
|
regExChars: /[-\/\\^$*+?.()|[\]{}]/,
|
|
71
71
|
tanakaID: /#ID=\d+_\d+$/,
|
|
72
72
|
tanakaPart: /(?<base>[^()\[\]\{\}\s]+)(?:\((?<reading>[\S]+)\))?(?:\[(?<glossnum>[\S]+)\])?(?:\{(?<inflection>[\S]+)\})?/,
|
|
73
|
-
tanakaReferenceID: /#([\d]+)/
|
|
73
|
+
tanakaReferenceID: /#(?<entryid>[\d]+)/
|
|
74
74
|
};
|
|
75
75
|
var romajiMap = {
|
|
76
76
|
A: "\u30A8\u30FC",
|
|
@@ -1462,9 +1462,9 @@ async function convertTanakaCorpus(tanakaString, generateFurigana) {
|
|
|
1462
1462
|
if (reading)
|
|
1463
1463
|
if (regexps.tanakaReferenceID.test(reading)) {
|
|
1464
1464
|
const referenceID = regexps.tanakaReferenceID.exec(reading);
|
|
1465
|
-
if (!referenceID)
|
|
1465
|
+
if (!referenceID || !referenceID.groups || !referenceID.groups["entryid"])
|
|
1466
1466
|
throw new Error(`Invalid reference ID: ${reading}`);
|
|
1467
|
-
examplePart.referenceID = referenceID[
|
|
1467
|
+
examplePart.referenceID = referenceID.groups["entryid"];
|
|
1468
1468
|
} else examplePart.reading = reading;
|
|
1469
1469
|
if (glossNumber)
|
|
1470
1470
|
examplePart.glossNumber = glossNumber.startsWith("0") ? Number.parseInt(glossNumber.substring(1)) : Number.parseInt(glossNumber);
|
|
@@ -1601,9 +1601,10 @@ function lookupWordNote(key, notes, tags, required, fallback) {
|
|
|
1601
1601
|
if (notes) notes.push(fallback != null ? fallback : key);
|
|
1602
1602
|
return { note: fallback != null ? fallback : key };
|
|
1603
1603
|
}
|
|
1604
|
-
|
|
1604
|
+
const tag = `word::${info[0]}`;
|
|
1605
|
+
if (tags && !tags.includes(tag)) tags.push(tag);
|
|
1605
1606
|
if (notes) notes.push(info[1]);
|
|
1606
|
-
return { note: info[1], tag
|
|
1607
|
+
return { note: info[1], tag };
|
|
1607
1608
|
}
|
|
1608
1609
|
var wordAddNoteArray = (arr, cb) => {
|
|
1609
1610
|
if (!arr) return;
|
|
@@ -1757,13 +1758,6 @@ function getWord(dict, id, kanjiDic, examples, dictWord, noteTypeName, deckPath)
|
|
|
1757
1758
|
if (word.kanji.length === 0) delete word.kanji;
|
|
1758
1759
|
}
|
|
1759
1760
|
if (examples && dictWord.hasPhrases === true) {
|
|
1760
|
-
let pushIfUnique2 = function(ex) {
|
|
1761
|
-
if (!seenPhrases.has(ex.phrase)) {
|
|
1762
|
-
wordExamples.push(ex);
|
|
1763
|
-
seenPhrases.add(ex.phrase);
|
|
1764
|
-
}
|
|
1765
|
-
};
|
|
1766
|
-
var pushIfUnique = pushIfUnique2;
|
|
1767
1761
|
const readings = new Set(
|
|
1768
1762
|
word.readings.filter(
|
|
1769
1763
|
(reading) => (!reading.notes || !reading.notes.some(
|
|
@@ -1781,46 +1775,55 @@ function getWord(dict, id, kanjiDic, examples, dictWord, noteTypeName, deckPath)
|
|
|
1781
1775
|
const kanjiFormExamples = [];
|
|
1782
1776
|
const readingMatchingKanjiFormExamples = [];
|
|
1783
1777
|
const readingExamples = [];
|
|
1778
|
+
const partParts = /* @__PURE__ */ new Set();
|
|
1784
1779
|
for (const example of examples)
|
|
1785
1780
|
for (const part of example.parts) {
|
|
1786
|
-
const
|
|
1781
|
+
const readingAsReadingMatch = part.reading !== void 0 && readings.has(part.reading);
|
|
1787
1782
|
if (kanjiForms && kanjiForms.size > 0 && kanjiForms.has(part.baseForm)) {
|
|
1788
|
-
if (
|
|
1789
|
-
|
|
1783
|
+
if (readingAsReadingMatch) {
|
|
1784
|
+
readingMatchingKanjiFormExamples.push(example);
|
|
1785
|
+
partParts.add(part.baseForm).add(part.reading);
|
|
1786
|
+
} else {
|
|
1787
|
+
kanjiFormExamples.push(example);
|
|
1788
|
+
partParts.add(part.baseForm);
|
|
1789
|
+
}
|
|
1790
1790
|
break;
|
|
1791
1791
|
}
|
|
1792
|
-
|
|
1792
|
+
const readingAsBaseFormMatch = readings.has(part.baseForm);
|
|
1793
|
+
const referenceIDMatch = part.referenceID !== void 0 && word.id !== void 0 && part.referenceID === word.id;
|
|
1794
|
+
if (readingAsReadingMatch || readingAsBaseFormMatch || referenceIDMatch) {
|
|
1793
1795
|
readingExamples.push(example);
|
|
1796
|
+
if (readingAsReadingMatch) partParts.add(part.reading);
|
|
1797
|
+
if (readingAsBaseFormMatch) partParts.add(part.baseForm);
|
|
1798
|
+
if (referenceIDMatch) partParts.add(part.referenceID);
|
|
1794
1799
|
break;
|
|
1795
1800
|
}
|
|
1796
1801
|
}
|
|
1797
|
-
const exampleSize =
|
|
1798
|
-
...readingMatchingKanjiFormExamples,
|
|
1799
|
-
...kanjiFormExamples,
|
|
1800
|
-
...readingExamples
|
|
1801
|
-
])).size;
|
|
1802
|
+
const exampleSize = readingMatchingKanjiFormExamples.length + kanjiFormExamples.length + readingExamples.length;
|
|
1802
1803
|
const includeKanjiFormExamples = readingMatchingKanjiFormExamples.length < Math.max(2, Math.round(exampleSize * 0.05));
|
|
1803
1804
|
const includeReadingExamples = word.usuallyInKana === void 0 && includeKanjiFormExamples && readingExamples.length >= Math.max(10, Math.round(exampleSize * 0.15)) || word.usuallyInKana === true && readingExamples.length >= Math.max(2, Math.round(exampleSize * 0.5));
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
if (includeReadingExamples)
|
|
1810
|
-
for (const ex of readingExamples) pushIfUnique2(ex);
|
|
1805
|
+
let wordExamples = [
|
|
1806
|
+
...readingMatchingKanjiFormExamples,
|
|
1807
|
+
...includeKanjiFormExamples ? kanjiFormExamples : [],
|
|
1808
|
+
...includeReadingExamples ? readingExamples : []
|
|
1809
|
+
];
|
|
1811
1810
|
if (word.translations) {
|
|
1812
1811
|
const glossSpecificExamples = [];
|
|
1812
|
+
const seenPhrases = /* @__PURE__ */ new Set();
|
|
1813
1813
|
for (let i = 0; i < word.translations.length; i++) {
|
|
1814
|
-
outer: for (const example of wordExamples)
|
|
1814
|
+
outer: for (const example of wordExamples) {
|
|
1815
|
+
if (seenPhrases.has(example.phrase)) continue;
|
|
1815
1816
|
for (const part of example.parts)
|
|
1816
|
-
if (part.glossNumber === i + 1) {
|
|
1817
|
+
if (part.glossNumber === i + 1 && (partParts.has(part.baseForm) || part.reading && partParts.has(part.reading) || part.referenceID && partParts.has(part.referenceID))) {
|
|
1817
1818
|
glossSpecificExamples.push(example);
|
|
1819
|
+
seenPhrases.add(example.phrase);
|
|
1818
1820
|
break outer;
|
|
1819
1821
|
}
|
|
1822
|
+
}
|
|
1820
1823
|
if (glossSpecificExamples.length === 5) break;
|
|
1821
1824
|
}
|
|
1822
1825
|
if (glossSpecificExamples.length === 5)
|
|
1823
|
-
wordExamples = glossSpecificExamples;
|
|
1826
|
+
wordExamples = [...glossSpecificExamples];
|
|
1824
1827
|
else if (glossSpecificExamples.length > 0) {
|
|
1825
1828
|
const seenPhrases2 = new Set(
|
|
1826
1829
|
glossSpecificExamples.map((ex) => ex.phrase)
|