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/dataset.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { l as dataset, l as default } from './dataset-
|
|
1
|
+
export { l as dataset, l as default } from './dataset-Bh9bZBtJ.mjs';
|
package/dist/dataset.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { l as dataset, l as default } from './dataset-
|
|
1
|
+
export { l as dataset, l as default } from './dataset-Bh9bZBtJ.js';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ReferenceTables, a as ResolvedIso639_3, b as ResolvedGlottolog, c as ResolvedBcp47, S as StandardsData, d as ResolvedStandards, L as LanguageData, e as SpeakerData, P as ProvenanceData, T as TranscriptionData, f as RawMetadataData, V as VideoData, F as FilterOptions, g as LanguageSummary, C as CountrySummary, h as SpeakerSummary, D as DatasetStats } from './dataset-
|
|
2
|
-
export { G as GlottologEntry, I as IanaLanguageEntry, i as IanaSubtagEntry, j as IanaVariantEntry, k as Iso639_3Entry, l as dataset } from './dataset-
|
|
1
|
+
import { R as ReferenceTables, a as ResolvedIso639_3, b as ResolvedGlottolog, c as ResolvedBcp47, S as StandardsData, d as ResolvedStandards, L as LanguageData, e as SpeakerData, P as ProvenanceData, T as TranscriptionData, f as RawMetadataData, V as VideoData, F as FilterOptions, g as LanguageSummary, C as CountrySummary, h as SpeakerSummary, D as DatasetStats } from './dataset-Bh9bZBtJ.mjs';
|
|
2
|
+
export { G as GlottologEntry, I as IanaLanguageEntry, i as IanaSubtagEntry, j as IanaVariantEntry, k as Iso639_3Entry, l as dataset } from './dataset-Bh9bZBtJ.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Deterministic hydration of the persisted ontological anchor keys
|
|
@@ -193,6 +193,10 @@ declare class VideoCollection implements Iterable<Video> {
|
|
|
193
193
|
toArray(): Video[];
|
|
194
194
|
slice(start?: number, end?: number): VideoCollection;
|
|
195
195
|
includes(item: Video | string): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Check if any video in the collection matches the given language query.
|
|
198
|
+
*/
|
|
199
|
+
hasLanguage(query: string): boolean;
|
|
196
200
|
get isEmpty(): boolean;
|
|
197
201
|
get ids(): string[];
|
|
198
202
|
get urls(): string[];
|
|
@@ -416,6 +420,11 @@ declare class WikitonguesDB {
|
|
|
416
420
|
* classifications, Glottolog / ISO names and speaker claims.
|
|
417
421
|
*/
|
|
418
422
|
findByLanguage(languageQuery: string, includeAdditional?: boolean): VideoCollection;
|
|
423
|
+
/**
|
|
424
|
+
* Check if the database contains any video matching the language query
|
|
425
|
+
* (by ISO 639-3, ISO 639-1, BCP 47, macrolanguage, or name).
|
|
426
|
+
*/
|
|
427
|
+
hasLanguage(query: string): boolean;
|
|
419
428
|
/**
|
|
420
429
|
* Shortcut method to filter videos by common criteria.
|
|
421
430
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ReferenceTables, a as ResolvedIso639_3, b as ResolvedGlottolog, c as ResolvedBcp47, S as StandardsData, d as ResolvedStandards, L as LanguageData, e as SpeakerData, P as ProvenanceData, T as TranscriptionData, f as RawMetadataData, V as VideoData, F as FilterOptions, g as LanguageSummary, C as CountrySummary, h as SpeakerSummary, D as DatasetStats } from './dataset-
|
|
2
|
-
export { G as GlottologEntry, I as IanaLanguageEntry, i as IanaSubtagEntry, j as IanaVariantEntry, k as Iso639_3Entry, l as dataset } from './dataset-
|
|
1
|
+
import { R as ReferenceTables, a as ResolvedIso639_3, b as ResolvedGlottolog, c as ResolvedBcp47, S as StandardsData, d as ResolvedStandards, L as LanguageData, e as SpeakerData, P as ProvenanceData, T as TranscriptionData, f as RawMetadataData, V as VideoData, F as FilterOptions, g as LanguageSummary, C as CountrySummary, h as SpeakerSummary, D as DatasetStats } from './dataset-Bh9bZBtJ.js';
|
|
2
|
+
export { G as GlottologEntry, I as IanaLanguageEntry, i as IanaSubtagEntry, j as IanaVariantEntry, k as Iso639_3Entry, l as dataset } from './dataset-Bh9bZBtJ.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Deterministic hydration of the persisted ontological anchor keys
|
|
@@ -193,6 +193,10 @@ declare class VideoCollection implements Iterable<Video> {
|
|
|
193
193
|
toArray(): Video[];
|
|
194
194
|
slice(start?: number, end?: number): VideoCollection;
|
|
195
195
|
includes(item: Video | string): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Check if any video in the collection matches the given language query.
|
|
198
|
+
*/
|
|
199
|
+
hasLanguage(query: string): boolean;
|
|
196
200
|
get isEmpty(): boolean;
|
|
197
201
|
get ids(): string[];
|
|
198
202
|
get urls(): string[];
|
|
@@ -416,6 +420,11 @@ declare class WikitonguesDB {
|
|
|
416
420
|
* classifications, Glottolog / ISO names and speaker claims.
|
|
417
421
|
*/
|
|
418
422
|
findByLanguage(languageQuery: string, includeAdditional?: boolean): VideoCollection;
|
|
423
|
+
/**
|
|
424
|
+
* Check if the database contains any video matching the language query
|
|
425
|
+
* (by ISO 639-3, ISO 639-1, BCP 47, macrolanguage, or name).
|
|
426
|
+
*/
|
|
427
|
+
hasLanguage(query: string): boolean;
|
|
419
428
|
/**
|
|
420
429
|
* Shortcut method to filter videos by common criteria.
|
|
421
430
|
*/
|
package/dist/index.js
CHANGED
|
@@ -219,7 +219,13 @@ var MULTILINGUAL_ALIASES = {
|
|
|
219
219
|
sw: "swh",
|
|
220
220
|
so: "som",
|
|
221
221
|
zu: "zul",
|
|
222
|
-
xh: "xho"
|
|
222
|
+
xh: "xho",
|
|
223
|
+
et: "est",
|
|
224
|
+
az: "aze",
|
|
225
|
+
lv: "lav",
|
|
226
|
+
ne: "nep",
|
|
227
|
+
ff: "ful",
|
|
228
|
+
mg: "mlg"
|
|
223
229
|
};
|
|
224
230
|
var MACROLANGUAGE_EXPANSIONS = {
|
|
225
231
|
fas: ["fas", "pes", "prs"],
|
|
@@ -268,7 +274,10 @@ var MACROLANGUAGE_EXPANSIONS = {
|
|
|
268
274
|
est: ["est", "ekk", "vro"],
|
|
269
275
|
aka: ["aka", "twi", "fat"],
|
|
270
276
|
nep: ["nep", "npi"],
|
|
271
|
-
ful: ["ful", "fuf", "fuh", "fub", "fuq"]
|
|
277
|
+
ful: ["ful", "fuf", "fuh", "fub", "fuq"],
|
|
278
|
+
lav: ["lav", "lvs", "ltg"],
|
|
279
|
+
mon: ["mon", "khk", "mvf"],
|
|
280
|
+
mlg: ["mlg", "plt", "skg", "tkg"]
|
|
272
281
|
};
|
|
273
282
|
var LanguageResolver = class {
|
|
274
283
|
isoToName = /* @__PURE__ */ new Map();
|
|
@@ -310,6 +319,14 @@ var LanguageResolver = class {
|
|
|
310
319
|
this.aliases.set(prefix, iso);
|
|
311
320
|
}
|
|
312
321
|
}
|
|
322
|
+
const part1 = lang.standards.iso639_3.part1?.toLowerCase();
|
|
323
|
+
if (part1 && !this.aliases.has(part1)) {
|
|
324
|
+
this.aliases.set(part1, iso);
|
|
325
|
+
}
|
|
326
|
+
const macro = lang.standards.bcp47.macrolanguage?.toLowerCase();
|
|
327
|
+
if (macro && !this.aliases.has(macro)) {
|
|
328
|
+
this.aliases.set(macro, iso);
|
|
329
|
+
}
|
|
313
330
|
const gc = lang.glottocode;
|
|
314
331
|
this.glottoToIso.set(gc, iso);
|
|
315
332
|
this.isoToGlotto.set(iso, gc);
|
|
@@ -375,7 +392,7 @@ var LanguageResolver = class {
|
|
|
375
392
|
}
|
|
376
393
|
}
|
|
377
394
|
}
|
|
378
|
-
if (matchedIsos.size === 0) {
|
|
395
|
+
if (matchedIsos.size === 0 && norm.length >= 4) {
|
|
379
396
|
for (const [autoKey, isoSet] of this.autonymToIso.entries()) {
|
|
380
397
|
if (autoKey.includes(norm)) {
|
|
381
398
|
for (const iso of isoSet) {
|
|
@@ -9902,6 +9919,7 @@ var ReferenceHydrator = class {
|
|
|
9902
9919
|
}
|
|
9903
9920
|
const resolved = { tag: raw, primarySubtag: primary, variantSubtags: [] };
|
|
9904
9921
|
if (lang.description) resolved.description = lang.description;
|
|
9922
|
+
if (lang.macrolanguage) resolved.macrolanguage = lang.macrolanguage;
|
|
9905
9923
|
let state = 0;
|
|
9906
9924
|
for (const sub of parts.slice(1)) {
|
|
9907
9925
|
const lower = sub.toLowerCase();
|
|
@@ -10183,6 +10201,8 @@ var Video = class _Video {
|
|
|
10183
10201
|
const set = /* @__PURE__ */ new Set();
|
|
10184
10202
|
for (const lang of this.allLanguages) {
|
|
10185
10203
|
if (lang.iso639_3) set.add(lang.iso639_3);
|
|
10204
|
+
if (lang.standards.iso639_3.part1) set.add(lang.standards.iso639_3.part1);
|
|
10205
|
+
if (lang.standards.bcp47.macrolanguage) set.add(lang.standards.bcp47.macrolanguage);
|
|
10186
10206
|
}
|
|
10187
10207
|
return set;
|
|
10188
10208
|
}
|
|
@@ -10193,6 +10213,9 @@ var Video = class _Video {
|
|
|
10193
10213
|
const set = /* @__PURE__ */ new Set();
|
|
10194
10214
|
for (const lang of this.allLanguages) {
|
|
10195
10215
|
if (lang.bcp47) set.add(lang.bcp47);
|
|
10216
|
+
if (lang.iso639_3) set.add(lang.iso639_3);
|
|
10217
|
+
if (lang.standards.iso639_3.part1) set.add(lang.standards.iso639_3.part1);
|
|
10218
|
+
if (lang.standards.bcp47.macrolanguage) set.add(lang.standards.bcp47.macrolanguage);
|
|
10196
10219
|
}
|
|
10197
10220
|
return set;
|
|
10198
10221
|
}
|
|
@@ -10230,6 +10253,8 @@ var Video = class _Video {
|
|
|
10230
10253
|
const qNorm = normalizeText(q);
|
|
10231
10254
|
for (const lang of this.allLanguages) {
|
|
10232
10255
|
if (lang.iso639_3 === qLower) return true;
|
|
10256
|
+
if (lang.standards.iso639_3.part1?.toLowerCase() === qLower) return true;
|
|
10257
|
+
if (lang.standards.bcp47.macrolanguage?.toLowerCase() === qLower) return true;
|
|
10233
10258
|
const bcp = lang.bcp47.toLowerCase();
|
|
10234
10259
|
if (bcp === qLower || bcp.startsWith(`${qLower}-`)) return true;
|
|
10235
10260
|
if (lang.glottocode === qLower) return true;
|
|
@@ -10238,7 +10263,8 @@ var Video = class _Video {
|
|
|
10238
10263
|
const labelNorm = normalizeText(label);
|
|
10239
10264
|
if (labelNorm === qNorm || ` ${labelNorm} `.includes(` ${qNorm} `)) return true;
|
|
10240
10265
|
}
|
|
10241
|
-
|
|
10266
|
+
const autoLower = lang.autonym.toLowerCase();
|
|
10267
|
+
if (autoLower === qLower || qLower.length >= 4 && autoLower.includes(qLower)) return true;
|
|
10242
10268
|
}
|
|
10243
10269
|
return false;
|
|
10244
10270
|
}
|
|
@@ -10346,6 +10372,12 @@ var VideoCollection = class _VideoCollection {
|
|
|
10346
10372
|
}
|
|
10347
10373
|
return this._videos.some((v) => v.id === item.id);
|
|
10348
10374
|
}
|
|
10375
|
+
/**
|
|
10376
|
+
* Check if any video in the collection matches the given language query.
|
|
10377
|
+
*/
|
|
10378
|
+
hasLanguage(query) {
|
|
10379
|
+
return this._videos.some((v) => v.hasLanguage(query));
|
|
10380
|
+
}
|
|
10349
10381
|
// -------------------------------------------------------------------------
|
|
10350
10382
|
// Aggregation & Summary Properties
|
|
10351
10383
|
// -------------------------------------------------------------------------
|
|
@@ -10651,7 +10683,7 @@ var DatasetIndex = class {
|
|
|
10651
10683
|
const list = map.get(key);
|
|
10652
10684
|
if (!list) {
|
|
10653
10685
|
map.set(key, [video]);
|
|
10654
|
-
} else {
|
|
10686
|
+
} else if (!list.some((v) => v.id === video.id)) {
|
|
10655
10687
|
list.push(video);
|
|
10656
10688
|
}
|
|
10657
10689
|
}
|
|
@@ -10664,12 +10696,30 @@ var DatasetIndex = class {
|
|
|
10664
10696
|
if (plIso) {
|
|
10665
10697
|
this.appendToMap(this.byIsoPrimary, plIso, video);
|
|
10666
10698
|
this.appendToMap(this.byIso, plIso, video);
|
|
10699
|
+
const part1 = video.primaryLanguage.standards.iso639_3.part1?.toLowerCase();
|
|
10700
|
+
if (part1 && part1 !== plIso) {
|
|
10701
|
+
this.appendToMap(this.byIsoPrimary, part1, video);
|
|
10702
|
+
this.appendToMap(this.byIso, part1, video);
|
|
10703
|
+
}
|
|
10704
|
+
const macro = video.primaryLanguage.standards.bcp47.macrolanguage?.toLowerCase();
|
|
10705
|
+
if (macro && macro !== plIso && macro !== part1) {
|
|
10706
|
+
this.appendToMap(this.byIsoPrimary, macro, video);
|
|
10707
|
+
this.appendToMap(this.byIso, macro, video);
|
|
10708
|
+
}
|
|
10667
10709
|
}
|
|
10668
10710
|
for (const addLang of video.additionalLanguages) {
|
|
10669
10711
|
const aIso = addLang.iso639_3;
|
|
10670
|
-
if (aIso
|
|
10712
|
+
if (aIso) {
|
|
10671
10713
|
this.appendToMap(this.byIso, aIso, video);
|
|
10672
10714
|
}
|
|
10715
|
+
const part1 = addLang.standards.iso639_3.part1?.toLowerCase();
|
|
10716
|
+
if (part1 && part1 !== aIso) {
|
|
10717
|
+
this.appendToMap(this.byIso, part1, video);
|
|
10718
|
+
}
|
|
10719
|
+
const macro = addLang.standards.bcp47.macrolanguage?.toLowerCase();
|
|
10720
|
+
if (macro && macro !== aIso && macro !== part1) {
|
|
10721
|
+
this.appendToMap(this.byIso, macro, video);
|
|
10722
|
+
}
|
|
10673
10723
|
}
|
|
10674
10724
|
for (const lang of video.allLanguages) {
|
|
10675
10725
|
const bcp = lang.bcp47.toLowerCase().trim();
|
|
@@ -10680,6 +10730,18 @@ var DatasetIndex = class {
|
|
|
10680
10730
|
this.appendToMap(this.byBcp47, prefix, video);
|
|
10681
10731
|
}
|
|
10682
10732
|
}
|
|
10733
|
+
const iso = lang.iso639_3?.toLowerCase().trim();
|
|
10734
|
+
if (iso && iso !== bcp) {
|
|
10735
|
+
this.appendToMap(this.byBcp47, iso, video);
|
|
10736
|
+
}
|
|
10737
|
+
const part1 = lang.standards.iso639_3.part1?.toLowerCase().trim();
|
|
10738
|
+
if (part1 && part1 !== bcp && part1 !== iso) {
|
|
10739
|
+
this.appendToMap(this.byBcp47, part1, video);
|
|
10740
|
+
}
|
|
10741
|
+
const macro = lang.standards.bcp47.macrolanguage?.toLowerCase().trim();
|
|
10742
|
+
if (macro && macro !== bcp && macro !== iso && macro !== part1) {
|
|
10743
|
+
this.appendToMap(this.byBcp47, macro, video);
|
|
10744
|
+
}
|
|
10683
10745
|
}
|
|
10684
10746
|
for (const lang of video.allLanguages) {
|
|
10685
10747
|
this.appendToMap(this.byGlottocode, lang.glottocode, video);
|
|
@@ -10922,6 +10984,14 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
10922
10984
|
if (matchedIsos.has(lIso) || lIso === rawLower) {
|
|
10923
10985
|
return true;
|
|
10924
10986
|
}
|
|
10987
|
+
const part1 = lang.standards.iso639_3.part1?.toLowerCase();
|
|
10988
|
+
if (part1 && (matchedIsos.has(part1) || part1 === rawLower)) {
|
|
10989
|
+
return true;
|
|
10990
|
+
}
|
|
10991
|
+
const macro = lang.standards.bcp47.macrolanguage?.toLowerCase();
|
|
10992
|
+
if (macro && (matchedIsos.has(macro) || macro === rawLower)) {
|
|
10993
|
+
return true;
|
|
10994
|
+
}
|
|
10925
10995
|
const lBcp = lang.bcp47.toLowerCase();
|
|
10926
10996
|
if (lBcp === rawLower || lBcp.startsWith(`${rawLower}-`)) {
|
|
10927
10997
|
return true;
|
|
@@ -10934,7 +11004,9 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
10934
11004
|
const lNorm = normalizeText(label);
|
|
10935
11005
|
if (lNorm === norm || pattern && pattern.test(lNorm)) return true;
|
|
10936
11006
|
}
|
|
10937
|
-
|
|
11007
|
+
const autoLower = lang.autonym.toLowerCase();
|
|
11008
|
+
if (autoLower === rawLower) return true;
|
|
11009
|
+
if (rawLower.length >= 4 && autoLower.includes(rawLower)) return true;
|
|
10938
11010
|
}
|
|
10939
11011
|
return false;
|
|
10940
11012
|
};
|
|
@@ -10957,13 +11029,17 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
10957
11029
|
iso(code, includeAdditional = true) {
|
|
10958
11030
|
const codeClean = code.trim().toLowerCase();
|
|
10959
11031
|
const predicate = (v) => {
|
|
10960
|
-
|
|
11032
|
+
const matchIso = (l) => {
|
|
11033
|
+
if (l.iso639_3.toLowerCase() === codeClean) return true;
|
|
11034
|
+
if (l.standards.iso639_3.part1?.toLowerCase() === codeClean) return true;
|
|
11035
|
+
if (l.standards.bcp47.macrolanguage?.toLowerCase() === codeClean) return true;
|
|
11036
|
+
return false;
|
|
11037
|
+
};
|
|
11038
|
+
if (matchIso(v.primaryLanguage)) {
|
|
10961
11039
|
return true;
|
|
10962
11040
|
}
|
|
10963
11041
|
if (includeAdditional) {
|
|
10964
|
-
return v.additionalLanguages.some(
|
|
10965
|
-
(al) => al.iso639_3.toLowerCase() === codeClean
|
|
10966
|
-
);
|
|
11042
|
+
return v.additionalLanguages.some(matchIso);
|
|
10967
11043
|
}
|
|
10968
11044
|
return false;
|
|
10969
11045
|
};
|
|
@@ -10975,10 +11051,13 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
10975
11051
|
const predicate = (v) => {
|
|
10976
11052
|
for (const lang of v.allLanguages) {
|
|
10977
11053
|
const lTag = lang.bcp47.toLowerCase();
|
|
11054
|
+
const lIso = lang.iso639_3.toLowerCase();
|
|
11055
|
+
const part1 = lang.standards.iso639_3.part1?.toLowerCase();
|
|
11056
|
+
const macro = lang.standards.bcp47.macrolanguage?.toLowerCase();
|
|
10978
11057
|
if (exact) {
|
|
10979
|
-
if (lTag === tagClean) return true;
|
|
11058
|
+
if (lTag === tagClean || lIso === tagClean || part1 === tagClean || macro === tagClean) return true;
|
|
10980
11059
|
} else {
|
|
10981
|
-
if (lTag === tagClean || lTag.startsWith(`${tagClean}-`)) return true;
|
|
11060
|
+
if (lTag === tagClean || lTag.startsWith(`${tagClean}-`) || lIso === tagClean || part1 === tagClean || macro === tagClean) return true;
|
|
10982
11061
|
}
|
|
10983
11062
|
}
|
|
10984
11063
|
return false;
|
|
@@ -66509,6 +66588,16 @@ var WikitonguesDB = class _WikitonguesDB {
|
|
|
66509
66588
|
findByLanguage(languageQuery, includeAdditional = true) {
|
|
66510
66589
|
return this.query().language(languageQuery, includeAdditional).all();
|
|
66511
66590
|
}
|
|
66591
|
+
/**
|
|
66592
|
+
* Check if the database contains any video matching the language query
|
|
66593
|
+
* (by ISO 639-3, ISO 639-1, BCP 47, macrolanguage, or name).
|
|
66594
|
+
*/
|
|
66595
|
+
hasLanguage(query) {
|
|
66596
|
+
const qClean = query.trim().toLowerCase();
|
|
66597
|
+
if (this.index.byIso.has(qClean)) return true;
|
|
66598
|
+
if (this.index.byBcp47.has(qClean)) return true;
|
|
66599
|
+
return this.findByLanguage(query).length > 0;
|
|
66600
|
+
}
|
|
66512
66601
|
/**
|
|
66513
66602
|
* Shortcut method to filter videos by common criteria.
|
|
66514
66603
|
*/
|