wikitongues-db 0.2.2 → 0.2.4

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.
@@ -125,6 +125,7 @@ interface ResolvedBcp47 {
125
125
  regionSubtag?: string;
126
126
  variantSubtags: string[];
127
127
  description?: string;
128
+ macrolanguage?: string;
128
129
  }
129
130
  interface ResolvedStandards {
130
131
  iso639_3: ResolvedIso639_3;
@@ -125,6 +125,7 @@ interface ResolvedBcp47 {
125
125
  regionSubtag?: string;
126
126
  variantSubtags: string[];
127
127
  description?: string;
128
+ macrolanguage?: string;
128
129
  }
129
130
  interface ResolvedStandards {
130
131
  iso639_3: ResolvedIso639_3;
@@ -1 +1 @@
1
- export { l as dataset, l as default } from './dataset-DNYcpFFZ.mjs';
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-DNYcpFFZ.js';
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-DNYcpFFZ.mjs';
2
- export { G as GlottologEntry, I as IanaLanguageEntry, i as IanaSubtagEntry, j as IanaVariantEntry, k as Iso639_3Entry, l as dataset } from './dataset-DNYcpFFZ.mjs';
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
@@ -61,6 +61,11 @@ declare class Language {
61
61
  * Wikitongues classification, Glottolog node name, ISO reference name, autonym, speaker claim.
62
62
  */
63
63
  get labels(): string[];
64
+ /**
65
+ * Check if this language matches the given code by ISO 639-3, ISO 639-1 part1,
66
+ * BCP-47 (exact or prefix), macrolanguage, or Glottocode.
67
+ */
68
+ matchesCode(code: string): boolean;
64
69
  toDict(): LanguageData;
65
70
  }
66
71
  declare class Speaker {
@@ -193,6 +198,10 @@ declare class VideoCollection implements Iterable<Video> {
193
198
  toArray(): Video[];
194
199
  slice(start?: number, end?: number): VideoCollection;
195
200
  includes(item: Video | string): boolean;
201
+ /**
202
+ * Check if any video in the collection matches the given language query.
203
+ */
204
+ hasLanguage(query: string): boolean;
196
205
  get isEmpty(): boolean;
197
206
  get ids(): string[];
198
207
  get urls(): string[];
@@ -416,6 +425,11 @@ declare class WikitonguesDB {
416
425
  * classifications, Glottolog / ISO names and speaker claims.
417
426
  */
418
427
  findByLanguage(languageQuery: string, includeAdditional?: boolean): VideoCollection;
428
+ /**
429
+ * Check if the database contains any video matching the language query
430
+ * (by ISO 639-3, ISO 639-1, BCP 47, macrolanguage, or name).
431
+ */
432
+ hasLanguage(query: string): boolean;
419
433
  /**
420
434
  * Shortcut method to filter videos by common criteria.
421
435
  */
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-DNYcpFFZ.js';
2
- export { G as GlottologEntry, I as IanaLanguageEntry, i as IanaSubtagEntry, j as IanaVariantEntry, k as Iso639_3Entry, l as dataset } from './dataset-DNYcpFFZ.js';
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
@@ -61,6 +61,11 @@ declare class Language {
61
61
  * Wikitongues classification, Glottolog node name, ISO reference name, autonym, speaker claim.
62
62
  */
63
63
  get labels(): string[];
64
+ /**
65
+ * Check if this language matches the given code by ISO 639-3, ISO 639-1 part1,
66
+ * BCP-47 (exact or prefix), macrolanguage, or Glottocode.
67
+ */
68
+ matchesCode(code: string): boolean;
64
69
  toDict(): LanguageData;
65
70
  }
66
71
  declare class Speaker {
@@ -193,6 +198,10 @@ declare class VideoCollection implements Iterable<Video> {
193
198
  toArray(): Video[];
194
199
  slice(start?: number, end?: number): VideoCollection;
195
200
  includes(item: Video | string): boolean;
201
+ /**
202
+ * Check if any video in the collection matches the given language query.
203
+ */
204
+ hasLanguage(query: string): boolean;
196
205
  get isEmpty(): boolean;
197
206
  get ids(): string[];
198
207
  get urls(): string[];
@@ -416,6 +425,11 @@ declare class WikitonguesDB {
416
425
  * classifications, Glottolog / ISO names and speaker claims.
417
426
  */
418
427
  findByLanguage(languageQuery: string, includeAdditional?: boolean): VideoCollection;
428
+ /**
429
+ * Check if the database contains any video matching the language query
430
+ * (by ISO 639-3, ISO 639-1, BCP 47, macrolanguage, or name).
431
+ */
432
+ hasLanguage(query: string): boolean;
419
433
  /**
420
434
  * Shortcut method to filter videos by common criteria.
421
435
  */
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();
@@ -9999,6 +10017,21 @@ var Language = class _Language {
9999
10017
  if (this.speakerClaim) out.push(this.speakerClaim);
10000
10018
  return out;
10001
10019
  }
10020
+ /**
10021
+ * Check if this language matches the given code by ISO 639-3, ISO 639-1 part1,
10022
+ * BCP-47 (exact or prefix), macrolanguage, or Glottocode.
10023
+ */
10024
+ matchesCode(code) {
10025
+ const c = code.trim().toLowerCase();
10026
+ if (!c) return false;
10027
+ if (this.iso639_3.toLowerCase() === c) return true;
10028
+ if (this.standards.iso639_3.part1?.toLowerCase() === c) return true;
10029
+ if (this.standards.bcp47.macrolanguage?.toLowerCase() === c) return true;
10030
+ const bcp = this.bcp47.toLowerCase();
10031
+ if (bcp === c || bcp.startsWith(`${c}-`)) return true;
10032
+ if (this.glottocode.toLowerCase() === c) return true;
10033
+ return false;
10034
+ }
10002
10035
  toDict() {
10003
10036
  return {
10004
10037
  standards: {
@@ -10183,6 +10216,8 @@ var Video = class _Video {
10183
10216
  const set = /* @__PURE__ */ new Set();
10184
10217
  for (const lang of this.allLanguages) {
10185
10218
  if (lang.iso639_3) set.add(lang.iso639_3);
10219
+ if (lang.standards.iso639_3.part1) set.add(lang.standards.iso639_3.part1);
10220
+ if (lang.standards.bcp47.macrolanguage) set.add(lang.standards.bcp47.macrolanguage);
10186
10221
  }
10187
10222
  return set;
10188
10223
  }
@@ -10193,6 +10228,9 @@ var Video = class _Video {
10193
10228
  const set = /* @__PURE__ */ new Set();
10194
10229
  for (const lang of this.allLanguages) {
10195
10230
  if (lang.bcp47) set.add(lang.bcp47);
10231
+ if (lang.iso639_3) set.add(lang.iso639_3);
10232
+ if (lang.standards.iso639_3.part1) set.add(lang.standards.iso639_3.part1);
10233
+ if (lang.standards.bcp47.macrolanguage) set.add(lang.standards.bcp47.macrolanguage);
10196
10234
  }
10197
10235
  return set;
10198
10236
  }
@@ -10230,6 +10268,8 @@ var Video = class _Video {
10230
10268
  const qNorm = normalizeText(q);
10231
10269
  for (const lang of this.allLanguages) {
10232
10270
  if (lang.iso639_3 === qLower) return true;
10271
+ if (lang.standards.iso639_3.part1?.toLowerCase() === qLower) return true;
10272
+ if (lang.standards.bcp47.macrolanguage?.toLowerCase() === qLower) return true;
10233
10273
  const bcp = lang.bcp47.toLowerCase();
10234
10274
  if (bcp === qLower || bcp.startsWith(`${qLower}-`)) return true;
10235
10275
  if (lang.glottocode === qLower) return true;
@@ -10238,7 +10278,8 @@ var Video = class _Video {
10238
10278
  const labelNorm = normalizeText(label);
10239
10279
  if (labelNorm === qNorm || ` ${labelNorm} `.includes(` ${qNorm} `)) return true;
10240
10280
  }
10241
- if (lang.autonym.toLowerCase().includes(qLower)) return true;
10281
+ const autoLower = lang.autonym.toLowerCase();
10282
+ if (autoLower === qLower || qLower.length >= 4 && autoLower.includes(qLower)) return true;
10242
10283
  }
10243
10284
  return false;
10244
10285
  }
@@ -10346,6 +10387,12 @@ var VideoCollection = class _VideoCollection {
10346
10387
  }
10347
10388
  return this._videos.some((v) => v.id === item.id);
10348
10389
  }
10390
+ /**
10391
+ * Check if any video in the collection matches the given language query.
10392
+ */
10393
+ hasLanguage(query) {
10394
+ return this._videos.some((v) => v.hasLanguage(query));
10395
+ }
10349
10396
  // -------------------------------------------------------------------------
10350
10397
  // Aggregation & Summary Properties
10351
10398
  // -------------------------------------------------------------------------
@@ -10651,7 +10698,7 @@ var DatasetIndex = class {
10651
10698
  const list = map.get(key);
10652
10699
  if (!list) {
10653
10700
  map.set(key, [video]);
10654
- } else {
10701
+ } else if (!list.some((v) => v.id === video.id)) {
10655
10702
  list.push(video);
10656
10703
  }
10657
10704
  }
@@ -10664,12 +10711,30 @@ var DatasetIndex = class {
10664
10711
  if (plIso) {
10665
10712
  this.appendToMap(this.byIsoPrimary, plIso, video);
10666
10713
  this.appendToMap(this.byIso, plIso, video);
10714
+ const part1 = video.primaryLanguage.standards.iso639_3.part1?.toLowerCase();
10715
+ if (part1 && part1 !== plIso) {
10716
+ this.appendToMap(this.byIsoPrimary, part1, video);
10717
+ this.appendToMap(this.byIso, part1, video);
10718
+ }
10719
+ const macro = video.primaryLanguage.standards.bcp47.macrolanguage?.toLowerCase();
10720
+ if (macro && macro !== plIso && macro !== part1) {
10721
+ this.appendToMap(this.byIsoPrimary, macro, video);
10722
+ this.appendToMap(this.byIso, macro, video);
10723
+ }
10667
10724
  }
10668
10725
  for (const addLang of video.additionalLanguages) {
10669
10726
  const aIso = addLang.iso639_3;
10670
- if (aIso && aIso !== plIso) {
10727
+ if (aIso) {
10671
10728
  this.appendToMap(this.byIso, aIso, video);
10672
10729
  }
10730
+ const part1 = addLang.standards.iso639_3.part1?.toLowerCase();
10731
+ if (part1 && part1 !== aIso) {
10732
+ this.appendToMap(this.byIso, part1, video);
10733
+ }
10734
+ const macro = addLang.standards.bcp47.macrolanguage?.toLowerCase();
10735
+ if (macro && macro !== aIso && macro !== part1) {
10736
+ this.appendToMap(this.byIso, macro, video);
10737
+ }
10673
10738
  }
10674
10739
  for (const lang of video.allLanguages) {
10675
10740
  const bcp = lang.bcp47.toLowerCase().trim();
@@ -10680,6 +10745,18 @@ var DatasetIndex = class {
10680
10745
  this.appendToMap(this.byBcp47, prefix, video);
10681
10746
  }
10682
10747
  }
10748
+ const iso = lang.iso639_3?.toLowerCase().trim();
10749
+ if (iso && iso !== bcp) {
10750
+ this.appendToMap(this.byBcp47, iso, video);
10751
+ }
10752
+ const part1 = lang.standards.iso639_3.part1?.toLowerCase().trim();
10753
+ if (part1 && part1 !== bcp && part1 !== iso) {
10754
+ this.appendToMap(this.byBcp47, part1, video);
10755
+ }
10756
+ const macro = lang.standards.bcp47.macrolanguage?.toLowerCase().trim();
10757
+ if (macro && macro !== bcp && macro !== iso && macro !== part1) {
10758
+ this.appendToMap(this.byBcp47, macro, video);
10759
+ }
10683
10760
  }
10684
10761
  for (const lang of video.allLanguages) {
10685
10762
  this.appendToMap(this.byGlottocode, lang.glottocode, video);
@@ -10922,6 +10999,14 @@ var QueryBuilder = class _QueryBuilder {
10922
10999
  if (matchedIsos.has(lIso) || lIso === rawLower) {
10923
11000
  return true;
10924
11001
  }
11002
+ const part1 = lang.standards.iso639_3.part1?.toLowerCase();
11003
+ if (part1 && (matchedIsos.has(part1) || part1 === rawLower)) {
11004
+ return true;
11005
+ }
11006
+ const macro = lang.standards.bcp47.macrolanguage?.toLowerCase();
11007
+ if (macro && (matchedIsos.has(macro) || macro === rawLower)) {
11008
+ return true;
11009
+ }
10925
11010
  const lBcp = lang.bcp47.toLowerCase();
10926
11011
  if (lBcp === rawLower || lBcp.startsWith(`${rawLower}-`)) {
10927
11012
  return true;
@@ -10934,7 +11019,9 @@ var QueryBuilder = class _QueryBuilder {
10934
11019
  const lNorm = normalizeText(label);
10935
11020
  if (lNorm === norm || pattern && pattern.test(lNorm)) return true;
10936
11021
  }
10937
- if (lang.autonym.toLowerCase().includes(rawLower)) return true;
11022
+ const autoLower = lang.autonym.toLowerCase();
11023
+ if (autoLower === rawLower) return true;
11024
+ if (rawLower.length >= 4 && autoLower.includes(rawLower)) return true;
10938
11025
  }
10939
11026
  return false;
10940
11027
  };
@@ -10957,13 +11044,17 @@ var QueryBuilder = class _QueryBuilder {
10957
11044
  iso(code, includeAdditional = true) {
10958
11045
  const codeClean = code.trim().toLowerCase();
10959
11046
  const predicate = (v) => {
10960
- if (v.primaryLanguage.iso639_3.toLowerCase() === codeClean) {
11047
+ const matchIso = (l) => {
11048
+ if (l.iso639_3.toLowerCase() === codeClean) return true;
11049
+ if (l.standards.iso639_3.part1?.toLowerCase() === codeClean) return true;
11050
+ if (l.standards.bcp47.macrolanguage?.toLowerCase() === codeClean) return true;
11051
+ return false;
11052
+ };
11053
+ if (matchIso(v.primaryLanguage)) {
10961
11054
  return true;
10962
11055
  }
10963
11056
  if (includeAdditional) {
10964
- return v.additionalLanguages.some(
10965
- (al) => al.iso639_3.toLowerCase() === codeClean
10966
- );
11057
+ return v.additionalLanguages.some(matchIso);
10967
11058
  }
10968
11059
  return false;
10969
11060
  };
@@ -10975,10 +11066,13 @@ var QueryBuilder = class _QueryBuilder {
10975
11066
  const predicate = (v) => {
10976
11067
  for (const lang of v.allLanguages) {
10977
11068
  const lTag = lang.bcp47.toLowerCase();
11069
+ const lIso = lang.iso639_3.toLowerCase();
11070
+ const part1 = lang.standards.iso639_3.part1?.toLowerCase();
11071
+ const macro = lang.standards.bcp47.macrolanguage?.toLowerCase();
10978
11072
  if (exact) {
10979
- if (lTag === tagClean) return true;
11073
+ if (lTag === tagClean || lIso === tagClean || part1 === tagClean || macro === tagClean) return true;
10980
11074
  } else {
10981
- if (lTag === tagClean || lTag.startsWith(`${tagClean}-`)) return true;
11075
+ if (lTag === tagClean || lTag.startsWith(`${tagClean}-`) || lIso === tagClean || part1 === tagClean || macro === tagClean) return true;
10982
11076
  }
10983
11077
  }
10984
11078
  return false;
@@ -66509,6 +66603,16 @@ var WikitonguesDB = class _WikitonguesDB {
66509
66603
  findByLanguage(languageQuery, includeAdditional = true) {
66510
66604
  return this.query().language(languageQuery, includeAdditional).all();
66511
66605
  }
66606
+ /**
66607
+ * Check if the database contains any video matching the language query
66608
+ * (by ISO 639-3, ISO 639-1, BCP 47, macrolanguage, or name).
66609
+ */
66610
+ hasLanguage(query) {
66611
+ const qClean = query.trim().toLowerCase();
66612
+ if (this.index.byIso.has(qClean)) return true;
66613
+ if (this.index.byBcp47.has(qClean)) return true;
66614
+ return this.findByLanguage(query).length > 0;
66615
+ }
66512
66616
  /**
66513
66617
  * Shortcut method to filter videos by common criteria.
66514
66618
  */