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.
- package/dist/index.cjs.js +42 -4
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.mjs +42 -4
- package/dist/index.mjs.map +3 -3
- package/dist/types/types.d.ts +10 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +2 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/docs/api/functions/capitalizeString.md +1 -1
- package/docs/api/functions/convertJMdict.md +8 -2
- 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 +4 -4
- 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 +27 -5
- 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 +21 -21
- package/docs/api/interfaces/KanjiComponent.md +3 -3
- package/docs/api/interfaces/KanjiForm.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 +4 -4
- 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 +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1149,7 +1149,7 @@ function shuffleArray(arr) {
|
|
|
1149
1149
|
}
|
|
1150
1150
|
return a;
|
|
1151
1151
|
}
|
|
1152
|
-
function convertJMdict(xmlString) {
|
|
1152
|
+
function convertJMdict(xmlString, examples) {
|
|
1153
1153
|
try {
|
|
1154
1154
|
const dictParsed = libxml.parseXml(xmlString, {
|
|
1155
1155
|
dtdvalid: true,
|
|
@@ -1183,8 +1183,10 @@ function convertJMdict(xmlString) {
|
|
|
1183
1183
|
);
|
|
1184
1184
|
if (isStringArray(kanjiForm.ke_inf))
|
|
1185
1185
|
form.notes = kanjiForm.ke_inf;
|
|
1186
|
-
if (isStringArray(kanjiForm.ke_pri))
|
|
1186
|
+
if (isStringArray(kanjiForm.ke_pri)) {
|
|
1187
1187
|
form.commonness = kanjiForm.ke_pri;
|
|
1188
|
+
if (entryObj.isCommon === void 0) entryObj.isCommon = true;
|
|
1189
|
+
}
|
|
1188
1190
|
if (form.form.length > 0) entryObj.kanjiForms.push(form);
|
|
1189
1191
|
}
|
|
1190
1192
|
}
|
|
@@ -1197,10 +1199,12 @@ function convertJMdict(xmlString) {
|
|
|
1197
1199
|
throw new Error(`Invalid JMdict entry reading: ${entryObj.id}`);
|
|
1198
1200
|
if (isStringArray(reading.re_inf))
|
|
1199
1201
|
readingObj.notes = reading.re_inf;
|
|
1200
|
-
if (isStringArray(reading.re_pri))
|
|
1201
|
-
readingObj.commonness = reading.re_pri;
|
|
1202
1202
|
if (isStringArray(reading.re_restr))
|
|
1203
1203
|
readingObj.kanjiFormRestrictions = reading.re_restr;
|
|
1204
|
+
if (isStringArray(reading.re_pri)) {
|
|
1205
|
+
readingObj.commonness = reading.re_pri;
|
|
1206
|
+
if (entryObj.isCommon === void 0) entryObj.isCommon = true;
|
|
1207
|
+
}
|
|
1204
1208
|
if (readingObj.reading.length > 0)
|
|
1205
1209
|
entryObj.readings.push(readingObj);
|
|
1206
1210
|
}
|
|
@@ -1236,6 +1240,40 @@ function convertJMdict(xmlString) {
|
|
|
1236
1240
|
if (meaningObj.partOfSpeech && meaningObj.partOfSpeech.length > 0 || meaningObj.translations && meaningObj.translations.length > 0)
|
|
1237
1241
|
entryObj.meanings.push(meaningObj);
|
|
1238
1242
|
}
|
|
1243
|
+
if (examples) {
|
|
1244
|
+
const readings2 = new Set(
|
|
1245
|
+
entryObj.readings.filter(
|
|
1246
|
+
(reading) => !reading.notes || reading.notes && !reading.notes.some(
|
|
1247
|
+
(note) => notSearchedForms.has(note)
|
|
1248
|
+
)
|
|
1249
|
+
).map((reading) => reading.reading)
|
|
1250
|
+
);
|
|
1251
|
+
const kanjiForms2 = entryObj.kanjiForms ? new Set(
|
|
1252
|
+
entryObj.kanjiForms.map(
|
|
1253
|
+
(kanjiForm) => kanjiForm.form
|
|
1254
|
+
)
|
|
1255
|
+
) : void 0;
|
|
1256
|
+
let kanjiFormExamples = false;
|
|
1257
|
+
let readingExamples = false;
|
|
1258
|
+
if (kanjiForms2) {
|
|
1259
|
+
outer: for (const example of examples)
|
|
1260
|
+
for (const part of example.parts)
|
|
1261
|
+
if (kanjiForms2.has(part.baseForm)) {
|
|
1262
|
+
kanjiFormExamples = true;
|
|
1263
|
+
break outer;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
if (!kanjiFormExamples) {
|
|
1267
|
+
outer: for (const example of examples)
|
|
1268
|
+
for (const part of example.parts)
|
|
1269
|
+
if (readings2.has(part.baseForm)) {
|
|
1270
|
+
readingExamples = true;
|
|
1271
|
+
break outer;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
if (kanjiFormExamples || readingExamples)
|
|
1275
|
+
entryObj.hasPhrases = true;
|
|
1276
|
+
}
|
|
1239
1277
|
if (entryObj.id.length > 0 && entryObj.readings.length > 0 && entryObj.meanings.length > 0)
|
|
1240
1278
|
dict.push(entryObj);
|
|
1241
1279
|
}
|