wikitongues-db 0.2.2 → 0.2.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/{dataset-DNYcpFFZ.d.mts → dataset-Bh9bZBtJ.d.mts} +1 -0
- package/dist/{dataset-DNYcpFFZ.d.ts → dataset-Bh9bZBtJ.d.ts} +1 -0
- package/dist/dataset.d.mts +1 -1
- package/dist/dataset.d.ts +1 -1
- package/dist/index.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +102 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -217,7 +217,13 @@ var MULTILINGUAL_ALIASES = {
|
|
|
217
217
|
sw: "swh",
|
|
218
218
|
so: "som",
|
|
219
219
|
zu: "zul",
|
|
220
|
-
xh: "xho"
|
|
220
|
+
xh: "xho",
|
|
221
|
+
et: "est",
|
|
222
|
+
az: "aze",
|
|
223
|
+
lv: "lav",
|
|
224
|
+
ne: "nep",
|
|
225
|
+
ff: "ful",
|
|
226
|
+
mg: "mlg"
|
|
221
227
|
};
|
|
222
228
|
var MACROLANGUAGE_EXPANSIONS = {
|
|
223
229
|
fas: ["fas", "pes", "prs"],
|
|
@@ -266,7 +272,10 @@ var MACROLANGUAGE_EXPANSIONS = {
|
|
|
266
272
|
est: ["est", "ekk", "vro"],
|
|
267
273
|
aka: ["aka", "twi", "fat"],
|
|
268
274
|
nep: ["nep", "npi"],
|
|
269
|
-
ful: ["ful", "fuf", "fuh", "fub", "fuq"]
|
|
275
|
+
ful: ["ful", "fuf", "fuh", "fub", "fuq"],
|
|
276
|
+
lav: ["lav", "lvs", "ltg"],
|
|
277
|
+
mon: ["mon", "khk", "mvf"],
|
|
278
|
+
mlg: ["mlg", "plt", "skg", "tkg"]
|
|
270
279
|
};
|
|
271
280
|
var LanguageResolver = class {
|
|
272
281
|
isoToName = /* @__PURE__ */ new Map();
|
|
@@ -308,6 +317,14 @@ var LanguageResolver = class {
|
|
|
308
317
|
this.aliases.set(prefix, iso);
|
|
309
318
|
}
|
|
310
319
|
}
|
|
320
|
+
const part1 = lang.standards.iso639_3.part1?.toLowerCase();
|
|
321
|
+
if (part1 && !this.aliases.has(part1)) {
|
|
322
|
+
this.aliases.set(part1, iso);
|
|
323
|
+
}
|
|
324
|
+
const macro = lang.standards.bcp47.macrolanguage?.toLowerCase();
|
|
325
|
+
if (macro && !this.aliases.has(macro)) {
|
|
326
|
+
this.aliases.set(macro, iso);
|
|
327
|
+
}
|
|
311
328
|
const gc = lang.glottocode;
|
|
312
329
|
this.glottoToIso.set(gc, iso);
|
|
313
330
|
this.isoToGlotto.set(iso, gc);
|
|
@@ -373,7 +390,7 @@ var LanguageResolver = class {
|
|
|
373
390
|
}
|
|
374
391
|
}
|
|
375
392
|
}
|
|
376
|
-
if (matchedIsos.size === 0) {
|
|
393
|
+
if (matchedIsos.size === 0 && norm.length >= 4) {
|
|
377
394
|
for (const [autoKey, isoSet] of this.autonymToIso.entries()) {
|
|
378
395
|
if (autoKey.includes(norm)) {
|
|
379
396
|
for (const iso of isoSet) {
|
|
@@ -9900,6 +9917,7 @@ var ReferenceHydrator = class {
|
|
|
9900
9917
|
}
|
|
9901
9918
|
const resolved = { tag: raw, primarySubtag: primary, variantSubtags: [] };
|
|
9902
9919
|
if (lang.description) resolved.description = lang.description;
|
|
9920
|
+
if (lang.macrolanguage) resolved.macrolanguage = lang.macrolanguage;
|
|
9903
9921
|
let state = 0;
|
|
9904
9922
|
for (const sub of parts.slice(1)) {
|
|
9905
9923
|
const lower = sub.toLowerCase();
|
|
@@ -10181,6 +10199,8 @@ var Video = class _Video {
|
|
|
10181
10199
|
const set = /* @__PURE__ */ new Set();
|
|
10182
10200
|
for (const lang of this.allLanguages) {
|
|
10183
10201
|
if (lang.iso639_3) set.add(lang.iso639_3);
|
|
10202
|
+
if (lang.standards.iso639_3.part1) set.add(lang.standards.iso639_3.part1);
|
|
10203
|
+
if (lang.standards.bcp47.macrolanguage) set.add(lang.standards.bcp47.macrolanguage);
|
|
10184
10204
|
}
|
|
10185
10205
|
return set;
|
|
10186
10206
|
}
|
|
@@ -10191,6 +10211,9 @@ var Video = class _Video {
|
|
|
10191
10211
|
const set = /* @__PURE__ */ new Set();
|
|
10192
10212
|
for (const lang of this.allLanguages) {
|
|
10193
10213
|
if (lang.bcp47) set.add(lang.bcp47);
|
|
10214
|
+
if (lang.iso639_3) set.add(lang.iso639_3);
|
|
10215
|
+
if (lang.standards.iso639_3.part1) set.add(lang.standards.iso639_3.part1);
|
|
10216
|
+
if (lang.standards.bcp47.macrolanguage) set.add(lang.standards.bcp47.macrolanguage);
|
|
10194
10217
|
}
|
|
10195
10218
|
return set;
|
|
10196
10219
|
}
|
|
@@ -10228,6 +10251,8 @@ var Video = class _Video {
|
|
|
10228
10251
|
const qNorm = normalizeText(q);
|
|
10229
10252
|
for (const lang of this.allLanguages) {
|
|
10230
10253
|
if (lang.iso639_3 === qLower) return true;
|
|
10254
|
+
if (lang.standards.iso639_3.part1?.toLowerCase() === qLower) return true;
|
|
10255
|
+
if (lang.standards.bcp47.macrolanguage?.toLowerCase() === qLower) return true;
|
|
10231
10256
|
const bcp = lang.bcp47.toLowerCase();
|
|
10232
10257
|
if (bcp === qLower || bcp.startsWith(`${qLower}-`)) return true;
|
|
10233
10258
|
if (lang.glottocode === qLower) return true;
|
|
@@ -10236,7 +10261,8 @@ var Video = class _Video {
|
|
|
10236
10261
|
const labelNorm = normalizeText(label);
|
|
10237
10262
|
if (labelNorm === qNorm || ` ${labelNorm} `.includes(` ${qNorm} `)) return true;
|
|
10238
10263
|
}
|
|
10239
|
-
|
|
10264
|
+
const autoLower = lang.autonym.toLowerCase();
|
|
10265
|
+
if (autoLower === qLower || qLower.length >= 4 && autoLower.includes(qLower)) return true;
|
|
10240
10266
|
}
|
|
10241
10267
|
return false;
|
|
10242
10268
|
}
|
|
@@ -10344,6 +10370,12 @@ var VideoCollection = class _VideoCollection {
|
|
|
10344
10370
|
}
|
|
10345
10371
|
return this._videos.some((v) => v.id === item.id);
|
|
10346
10372
|
}
|
|
10373
|
+
/**
|
|
10374
|
+
* Check if any video in the collection matches the given language query.
|
|
10375
|
+
*/
|
|
10376
|
+
hasLanguage(query) {
|
|
10377
|
+
return this._videos.some((v) => v.hasLanguage(query));
|
|
10378
|
+
}
|
|
10347
10379
|
// -------------------------------------------------------------------------
|
|
10348
10380
|
// Aggregation & Summary Properties
|
|
10349
10381
|
// -------------------------------------------------------------------------
|
|
@@ -10649,7 +10681,7 @@ var DatasetIndex = class {
|
|
|
10649
10681
|
const list = map.get(key);
|
|
10650
10682
|
if (!list) {
|
|
10651
10683
|
map.set(key, [video]);
|
|
10652
|
-
} else {
|
|
10684
|
+
} else if (!list.some((v) => v.id === video.id)) {
|
|
10653
10685
|
list.push(video);
|
|
10654
10686
|
}
|
|
10655
10687
|
}
|
|
@@ -10662,12 +10694,30 @@ var DatasetIndex = class {
|
|
|
10662
10694
|
if (plIso) {
|
|
10663
10695
|
this.appendToMap(this.byIsoPrimary, plIso, video);
|
|
10664
10696
|
this.appendToMap(this.byIso, plIso, video);
|
|
10697
|
+
const part1 = video.primaryLanguage.standards.iso639_3.part1?.toLowerCase();
|
|
10698
|
+
if (part1 && part1 !== plIso) {
|
|
10699
|
+
this.appendToMap(this.byIsoPrimary, part1, video);
|
|
10700
|
+
this.appendToMap(this.byIso, part1, video);
|
|
10701
|
+
}
|
|
10702
|
+
const macro = video.primaryLanguage.standards.bcp47.macrolanguage?.toLowerCase();
|
|
10703
|
+
if (macro && macro !== plIso && macro !== part1) {
|
|
10704
|
+
this.appendToMap(this.byIsoPrimary, macro, video);
|
|
10705
|
+
this.appendToMap(this.byIso, macro, video);
|
|
10706
|
+
}
|
|
10665
10707
|
}
|
|
10666
10708
|
for (const addLang of video.additionalLanguages) {
|
|
10667
10709
|
const aIso = addLang.iso639_3;
|
|
10668
|
-
if (aIso
|
|
10710
|
+
if (aIso) {
|
|
10669
10711
|
this.appendToMap(this.byIso, aIso, video);
|
|
10670
10712
|
}
|
|
10713
|
+
const part1 = addLang.standards.iso639_3.part1?.toLowerCase();
|
|
10714
|
+
if (part1 && part1 !== aIso) {
|
|
10715
|
+
this.appendToMap(this.byIso, part1, video);
|
|
10716
|
+
}
|
|
10717
|
+
const macro = addLang.standards.bcp47.macrolanguage?.toLowerCase();
|
|
10718
|
+
if (macro && macro !== aIso && macro !== part1) {
|
|
10719
|
+
this.appendToMap(this.byIso, macro, video);
|
|
10720
|
+
}
|
|
10671
10721
|
}
|
|
10672
10722
|
for (const lang of video.allLanguages) {
|
|
10673
10723
|
const bcp = lang.bcp47.toLowerCase().trim();
|
|
@@ -10678,6 +10728,18 @@ var DatasetIndex = class {
|
|
|
10678
10728
|
this.appendToMap(this.byBcp47, prefix, video);
|
|
10679
10729
|
}
|
|
10680
10730
|
}
|
|
10731
|
+
const iso = lang.iso639_3?.toLowerCase().trim();
|
|
10732
|
+
if (iso && iso !== bcp) {
|
|
10733
|
+
this.appendToMap(this.byBcp47, iso, video);
|
|
10734
|
+
}
|
|
10735
|
+
const part1 = lang.standards.iso639_3.part1?.toLowerCase().trim();
|
|
10736
|
+
if (part1 && part1 !== bcp && part1 !== iso) {
|
|
10737
|
+
this.appendToMap(this.byBcp47, part1, video);
|
|
10738
|
+
}
|
|
10739
|
+
const macro = lang.standards.bcp47.macrolanguage?.toLowerCase().trim();
|
|
10740
|
+
if (macro && macro !== bcp && macro !== iso && macro !== part1) {
|
|
10741
|
+
this.appendToMap(this.byBcp47, macro, video);
|
|
10742
|
+
}
|
|
10681
10743
|
}
|
|
10682
10744
|
for (const lang of video.allLanguages) {
|
|
10683
10745
|
this.appendToMap(this.byGlottocode, lang.glottocode, video);
|
|
@@ -10920,6 +10982,14 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
10920
10982
|
if (matchedIsos.has(lIso) || lIso === rawLower) {
|
|
10921
10983
|
return true;
|
|
10922
10984
|
}
|
|
10985
|
+
const part1 = lang.standards.iso639_3.part1?.toLowerCase();
|
|
10986
|
+
if (part1 && (matchedIsos.has(part1) || part1 === rawLower)) {
|
|
10987
|
+
return true;
|
|
10988
|
+
}
|
|
10989
|
+
const macro = lang.standards.bcp47.macrolanguage?.toLowerCase();
|
|
10990
|
+
if (macro && (matchedIsos.has(macro) || macro === rawLower)) {
|
|
10991
|
+
return true;
|
|
10992
|
+
}
|
|
10923
10993
|
const lBcp = lang.bcp47.toLowerCase();
|
|
10924
10994
|
if (lBcp === rawLower || lBcp.startsWith(`${rawLower}-`)) {
|
|
10925
10995
|
return true;
|
|
@@ -10932,7 +11002,9 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
10932
11002
|
const lNorm = normalizeText(label);
|
|
10933
11003
|
if (lNorm === norm || pattern && pattern.test(lNorm)) return true;
|
|
10934
11004
|
}
|
|
10935
|
-
|
|
11005
|
+
const autoLower = lang.autonym.toLowerCase();
|
|
11006
|
+
if (autoLower === rawLower) return true;
|
|
11007
|
+
if (rawLower.length >= 4 && autoLower.includes(rawLower)) return true;
|
|
10936
11008
|
}
|
|
10937
11009
|
return false;
|
|
10938
11010
|
};
|
|
@@ -10955,13 +11027,17 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
10955
11027
|
iso(code, includeAdditional = true) {
|
|
10956
11028
|
const codeClean = code.trim().toLowerCase();
|
|
10957
11029
|
const predicate = (v) => {
|
|
10958
|
-
|
|
11030
|
+
const matchIso = (l) => {
|
|
11031
|
+
if (l.iso639_3.toLowerCase() === codeClean) return true;
|
|
11032
|
+
if (l.standards.iso639_3.part1?.toLowerCase() === codeClean) return true;
|
|
11033
|
+
if (l.standards.bcp47.macrolanguage?.toLowerCase() === codeClean) return true;
|
|
11034
|
+
return false;
|
|
11035
|
+
};
|
|
11036
|
+
if (matchIso(v.primaryLanguage)) {
|
|
10959
11037
|
return true;
|
|
10960
11038
|
}
|
|
10961
11039
|
if (includeAdditional) {
|
|
10962
|
-
return v.additionalLanguages.some(
|
|
10963
|
-
(al) => al.iso639_3.toLowerCase() === codeClean
|
|
10964
|
-
);
|
|
11040
|
+
return v.additionalLanguages.some(matchIso);
|
|
10965
11041
|
}
|
|
10966
11042
|
return false;
|
|
10967
11043
|
};
|
|
@@ -10973,10 +11049,13 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
10973
11049
|
const predicate = (v) => {
|
|
10974
11050
|
for (const lang of v.allLanguages) {
|
|
10975
11051
|
const lTag = lang.bcp47.toLowerCase();
|
|
11052
|
+
const lIso = lang.iso639_3.toLowerCase();
|
|
11053
|
+
const part1 = lang.standards.iso639_3.part1?.toLowerCase();
|
|
11054
|
+
const macro = lang.standards.bcp47.macrolanguage?.toLowerCase();
|
|
10976
11055
|
if (exact) {
|
|
10977
|
-
if (lTag === tagClean) return true;
|
|
11056
|
+
if (lTag === tagClean || lIso === tagClean || part1 === tagClean || macro === tagClean) return true;
|
|
10978
11057
|
} else {
|
|
10979
|
-
if (lTag === tagClean || lTag.startsWith(`${tagClean}-`)) return true;
|
|
11058
|
+
if (lTag === tagClean || lTag.startsWith(`${tagClean}-`) || lIso === tagClean || part1 === tagClean || macro === tagClean) return true;
|
|
10980
11059
|
}
|
|
10981
11060
|
}
|
|
10982
11061
|
return false;
|
|
@@ -66507,6 +66586,16 @@ var WikitonguesDB = class _WikitonguesDB {
|
|
|
66507
66586
|
findByLanguage(languageQuery, includeAdditional = true) {
|
|
66508
66587
|
return this.query().language(languageQuery, includeAdditional).all();
|
|
66509
66588
|
}
|
|
66589
|
+
/**
|
|
66590
|
+
* Check if the database contains any video matching the language query
|
|
66591
|
+
* (by ISO 639-3, ISO 639-1, BCP 47, macrolanguage, or name).
|
|
66592
|
+
*/
|
|
66593
|
+
hasLanguage(query) {
|
|
66594
|
+
const qClean = query.trim().toLowerCase();
|
|
66595
|
+
if (this.index.byIso.has(qClean)) return true;
|
|
66596
|
+
if (this.index.byBcp47.has(qClean)) return true;
|
|
66597
|
+
return this.findByLanguage(query).length > 0;
|
|
66598
|
+
}
|
|
66510
66599
|
/**
|
|
66511
66600
|
* Shortcut method to filter videos by common criteria.
|
|
66512
66601
|
*/
|