henkan 0.3.0 → 0.3.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.cjs.js +23 -21
- package/dist/index.cjs.js.map +2 -2
- package/dist/index.mjs +23 -21
- package/dist/index.mjs.map +2 -2
- 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 +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1171,13 +1171,15 @@ function convertJMdict(xmlString, examples) {
|
|
|
1171
1171
|
const dict = [];
|
|
1172
1172
|
xml.parseString(dictParsed, (err, result) => {
|
|
1173
1173
|
if (err) throw err;
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1174
|
+
const tanakaParts = examples && examples.length > 0 ? new Set(
|
|
1175
|
+
examples.map(
|
|
1176
|
+
(example) => example.parts.map((part) => [
|
|
1177
|
+
part.baseForm,
|
|
1178
|
+
...part.reading ? [part.reading] : [],
|
|
1179
|
+
...part.referenceID ? [part.referenceID] : []
|
|
1180
|
+
])
|
|
1181
|
+
).flat(2)
|
|
1182
|
+
) : void 0;
|
|
1181
1183
|
if (result.JMdict && typeof result.JMdict === "object" && isValidArray(result.JMdict.entry))
|
|
1182
1184
|
for (const entry of result.JMdict.entry) {
|
|
1183
1185
|
const entryObj = {
|
|
@@ -1261,36 +1263,36 @@ function convertJMdict(xmlString, examples) {
|
|
|
1261
1263
|
if (examples) {
|
|
1262
1264
|
const readings2 = new Set(
|
|
1263
1265
|
entryObj.readings.filter(
|
|
1264
|
-
(reading) => !reading.notes || !reading.notes.some(
|
|
1266
|
+
(reading) => (!reading.notes || !reading.notes.some(
|
|
1265
1267
|
(note) => notSearchedForms.has(note)
|
|
1266
|
-
)
|
|
1268
|
+
)) && (entryObj.isCommon === void 0 || reading.commonness && reading.commonness.length > 0)
|
|
1267
1269
|
).map((reading) => reading.reading)
|
|
1268
1270
|
);
|
|
1269
1271
|
const kanjiForms2 = entryObj.kanjiForms ? new Set(
|
|
1270
1272
|
entryObj.kanjiForms.filter(
|
|
1271
|
-
(kanjiForm) => !kanjiForm.notes || !kanjiForm.notes.some(
|
|
1273
|
+
(kanjiForm) => (!kanjiForm.notes || !kanjiForm.notes.some(
|
|
1272
1274
|
(note) => notSearchedForms.has(note)
|
|
1273
|
-
)
|
|
1275
|
+
)) && (entryObj.isCommon === void 0 || kanjiForm.commonness && kanjiForm.commonness.length > 0)
|
|
1274
1276
|
).map((kanjiForm) => kanjiForm.form)
|
|
1275
1277
|
) : void 0;
|
|
1276
|
-
let
|
|
1277
|
-
|
|
1278
|
-
if (kanjiForms2 && kanjiForms2.size > 0 && tanakaBaseParts) {
|
|
1278
|
+
let existsExample = false;
|
|
1279
|
+
if (kanjiForms2 && kanjiForms2.size > 0 && tanakaParts) {
|
|
1279
1280
|
for (const kf of kanjiForms2)
|
|
1280
|
-
if (
|
|
1281
|
-
|
|
1281
|
+
if (tanakaParts.has(kf)) {
|
|
1282
|
+
existsExample = true;
|
|
1282
1283
|
break;
|
|
1283
1284
|
}
|
|
1284
1285
|
}
|
|
1285
|
-
if (
|
|
1286
|
+
if (!existsExample && readings2.size > 0 && tanakaParts) {
|
|
1286
1287
|
for (const r of readings2)
|
|
1287
|
-
if (
|
|
1288
|
-
|
|
1288
|
+
if (tanakaParts.has(r)) {
|
|
1289
|
+
existsExample = true;
|
|
1289
1290
|
break;
|
|
1290
1291
|
}
|
|
1291
1292
|
}
|
|
1292
|
-
if (
|
|
1293
|
-
|
|
1293
|
+
if (!existsExample && tanakaParts && tanakaParts.has(entryObj.id))
|
|
1294
|
+
existsExample = true;
|
|
1295
|
+
if (existsExample) entryObj.hasPhrases = true;
|
|
1294
1296
|
}
|
|
1295
1297
|
if (entryObj.id.length > 0 && entryObj.readings.length > 0 && entryObj.meanings.length > 0)
|
|
1296
1298
|
dict.push(entryObj);
|