wikitongues-db 0.1.0
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/LICENSE +21 -0
- package/README.md +172 -0
- package/data/processed/wikitongues_normalized.json +49337 -0
- package/data/processed/wikitongues_normalized.jsonl +863 -0
- package/dist/dataset-jRTVzgZX.d.mts +104 -0
- package/dist/dataset-jRTVzgZX.d.ts +104 -0
- package/dist/dataset.d.mts +1 -0
- package/dist/dataset.d.ts +1 -0
- package/dist/dataset.js +49351 -0
- package/dist/dataset.js.map +1 -0
- package/dist/dataset.mjs +49346 -0
- package/dist/dataset.mjs.map +1 -0
- package/dist/index.d.mts +394 -0
- package/dist/index.d.ts +394 -0
- package/dist/index.js +51242 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +51226 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +57 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { L as LanguageData, S as SpeakerData, P as ProvenanceData, T as TranscriptionData, R as RawMetadataData, V as VideoData, F as FilterOptions, a as LanguageSummary, C as CountrySummary, b as SpeakerSummary, D as DatasetStats } from './dataset-jRTVzgZX.js';
|
|
2
|
+
export { d as dataset } from './dataset-jRTVzgZX.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Domain models for the high-level Wikitongues Database API.
|
|
6
|
+
* Provides typed, immutable-friendly classes with rich helper methods.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
declare class Language {
|
|
10
|
+
readonly iso639_3: string;
|
|
11
|
+
readonly bcp47: string;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly glottocode: string | null;
|
|
14
|
+
readonly autonym: string | null;
|
|
15
|
+
readonly dialect: string | null;
|
|
16
|
+
constructor(data: Partial<LanguageData>);
|
|
17
|
+
static fromDict(data: Partial<LanguageData>): Language;
|
|
18
|
+
toDict(): LanguageData;
|
|
19
|
+
}
|
|
20
|
+
declare class Speaker {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly role: string;
|
|
23
|
+
readonly origin: string | null;
|
|
24
|
+
constructor(data: Partial<SpeakerData>);
|
|
25
|
+
static fromDict(data: Partial<SpeakerData>): Speaker;
|
|
26
|
+
toDict(): SpeakerData;
|
|
27
|
+
}
|
|
28
|
+
declare class Provenance {
|
|
29
|
+
readonly countryCode: string | null;
|
|
30
|
+
readonly countryName: string | null;
|
|
31
|
+
readonly region: string | null;
|
|
32
|
+
readonly city: string | null;
|
|
33
|
+
readonly recordedBy: string | null;
|
|
34
|
+
readonly recordingDate: string | null;
|
|
35
|
+
constructor(data?: Partial<ProvenanceData> | null);
|
|
36
|
+
static fromDict(data?: Partial<ProvenanceData> | null): Provenance;
|
|
37
|
+
toDict(): ProvenanceData;
|
|
38
|
+
}
|
|
39
|
+
declare class Transcription {
|
|
40
|
+
readonly hasSubtitles: boolean;
|
|
41
|
+
readonly availableSubtitles: string[];
|
|
42
|
+
readonly nativeText: string | null;
|
|
43
|
+
readonly englishTranslation: string | null;
|
|
44
|
+
constructor(data?: Partial<TranscriptionData> | null);
|
|
45
|
+
static fromDict(data?: Partial<TranscriptionData> | null): Transcription;
|
|
46
|
+
toDict(): TranscriptionData;
|
|
47
|
+
}
|
|
48
|
+
declare class RawMetadata {
|
|
49
|
+
readonly title: string;
|
|
50
|
+
readonly tags: string[];
|
|
51
|
+
constructor(data?: Partial<RawMetadataData> | null);
|
|
52
|
+
static fromDict(data?: Partial<RawMetadataData> | null): RawMetadata;
|
|
53
|
+
toDict(): RawMetadataData;
|
|
54
|
+
}
|
|
55
|
+
declare class Video {
|
|
56
|
+
readonly id: string;
|
|
57
|
+
readonly url: string;
|
|
58
|
+
readonly durationSeconds: number;
|
|
59
|
+
readonly uploadDate: string;
|
|
60
|
+
readonly license: string;
|
|
61
|
+
readonly contentType: string;
|
|
62
|
+
readonly primaryLanguage: Language;
|
|
63
|
+
readonly additionalLanguages: Language[];
|
|
64
|
+
readonly speakers: Speaker[];
|
|
65
|
+
readonly provenance: Provenance;
|
|
66
|
+
readonly transcription: Transcription;
|
|
67
|
+
readonly rawMetadata: RawMetadata;
|
|
68
|
+
constructor(data: Partial<VideoData>);
|
|
69
|
+
/**
|
|
70
|
+
* Returns the YouTube embed URL for iframe players.
|
|
71
|
+
*/
|
|
72
|
+
get embedUrl(): string;
|
|
73
|
+
/**
|
|
74
|
+
* Returns video title.
|
|
75
|
+
*/
|
|
76
|
+
get title(): string;
|
|
77
|
+
/**
|
|
78
|
+
* Returns raw metadata tags.
|
|
79
|
+
*/
|
|
80
|
+
get tags(): string[];
|
|
81
|
+
/**
|
|
82
|
+
* Returns human-readable duration formatted as 'MM:SS' or 'HH:MM:SS'.
|
|
83
|
+
*/
|
|
84
|
+
get durationFormatted(): string;
|
|
85
|
+
/**
|
|
86
|
+
* True if the video is licensed under any Creative Commons or Public Domain license.
|
|
87
|
+
*/
|
|
88
|
+
get isCreativeCommons(): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Returns all languages (primary + additional).
|
|
91
|
+
*/
|
|
92
|
+
get allLanguages(): Language[];
|
|
93
|
+
/**
|
|
94
|
+
* Returns all ISO 639-3 codes for this video.
|
|
95
|
+
*/
|
|
96
|
+
get allIsoCodes(): Set<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Returns all BCP 47 codes for this video.
|
|
99
|
+
*/
|
|
100
|
+
get allBcp47Codes(): Set<string>;
|
|
101
|
+
/**
|
|
102
|
+
* Returns all Glottolog codes for this video.
|
|
103
|
+
*/
|
|
104
|
+
get allGlottocodes(): Set<string>;
|
|
105
|
+
/**
|
|
106
|
+
* Returns list of speaker names (excluding 'unknown').
|
|
107
|
+
*/
|
|
108
|
+
get speakerNames(): string[];
|
|
109
|
+
get countryCode(): string | null;
|
|
110
|
+
get countryName(): string | null;
|
|
111
|
+
/**
|
|
112
|
+
* Check if video contains a language matching query (by ISO, BCP-47, Glottocode, Name, Autonym, or Dialect).
|
|
113
|
+
* Case-insensitive.
|
|
114
|
+
*/
|
|
115
|
+
hasLanguage(query: string): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Check if any speaker matches the name or role (case-insensitive substring match).
|
|
118
|
+
*/
|
|
119
|
+
hasSpeaker(nameOrRole: string): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Check if provenance country matches country code or name (case-insensitive).
|
|
122
|
+
*/
|
|
123
|
+
hasCountry(country: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Convert Video object into a standard dictionary.
|
|
126
|
+
*/
|
|
127
|
+
toDict(): VideoData;
|
|
128
|
+
/**
|
|
129
|
+
* Serialize Video to JSON string.
|
|
130
|
+
*/
|
|
131
|
+
toJSON(indent?: number): string;
|
|
132
|
+
static fromDict(data: Partial<VideoData>): Video;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* VideoCollection container for rich query results, aggregations, and transformations.
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
declare class VideoCollection implements Iterable<Video> {
|
|
140
|
+
protected readonly _videos: Video[];
|
|
141
|
+
constructor(videos?: Video[] | readonly Video[]);
|
|
142
|
+
[Symbol.iterator](): Iterator<Video>;
|
|
143
|
+
get length(): number;
|
|
144
|
+
get(index: number): Video | undefined;
|
|
145
|
+
at(index: number): Video | undefined;
|
|
146
|
+
toArray(): Video[];
|
|
147
|
+
slice(start?: number, end?: number): VideoCollection;
|
|
148
|
+
includes(item: Video | string): boolean;
|
|
149
|
+
get isEmpty(): boolean;
|
|
150
|
+
get ids(): string[];
|
|
151
|
+
get urls(): string[];
|
|
152
|
+
get embedUrls(): string[];
|
|
153
|
+
get titles(): string[];
|
|
154
|
+
get totalDurationSeconds(): number;
|
|
155
|
+
get totalDurationFormatted(): string;
|
|
156
|
+
get averageDurationSeconds(): number;
|
|
157
|
+
get isoCodes(): string[];
|
|
158
|
+
get bcp47Codes(): string[];
|
|
159
|
+
get languageNames(): string[];
|
|
160
|
+
get languages(): Language[];
|
|
161
|
+
get countries(): string[];
|
|
162
|
+
get speakers(): Speaker[];
|
|
163
|
+
get speakerNames(): string[];
|
|
164
|
+
first(): Video | null;
|
|
165
|
+
last(): Video | null;
|
|
166
|
+
sample(k?: number, seed?: number): VideoCollection;
|
|
167
|
+
filter(predicate: (video: Video, index: number) => boolean): VideoCollection;
|
|
168
|
+
sortBy(key: string | ((video: Video) => any), descending?: boolean): VideoCollection;
|
|
169
|
+
limit(n: number): VideoCollection;
|
|
170
|
+
offset(n: number): VideoCollection;
|
|
171
|
+
page(page?: number, pageSize?: number): VideoCollection;
|
|
172
|
+
groupBy(key: string | ((video: Video) => string)): Record<string, VideoCollection>;
|
|
173
|
+
toDicts(): VideoData[];
|
|
174
|
+
toJSON(indent?: number): string;
|
|
175
|
+
toJSONL(): string;
|
|
176
|
+
toCSV(): string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Language Resolver module for Wikitongues Database.
|
|
181
|
+
* Resolves natural language search queries (ISO 639-3, BCP 47, Glottocode, English canonical names,
|
|
182
|
+
* multilingual common names like 'russe' / 'español', autonyms, and dialects)
|
|
183
|
+
* to matched language identifiers.
|
|
184
|
+
*/
|
|
185
|
+
declare function normalizeText(text?: string | null): string;
|
|
186
|
+
/**
|
|
187
|
+
* Common international / multilingual aliases for popular and regional languages.
|
|
188
|
+
*/
|
|
189
|
+
declare const MULTILINGUAL_ALIASES: Record<string, string>;
|
|
190
|
+
declare class LanguageResolver {
|
|
191
|
+
isoToName: Map<string, string>;
|
|
192
|
+
nameToIso: Map<string, string>;
|
|
193
|
+
glottoToIso: Map<string, string>;
|
|
194
|
+
isoToGlotto: Map<string, string>;
|
|
195
|
+
autonymToIso: Map<string, Set<string>>;
|
|
196
|
+
dialectToIso: Map<string, Set<string>>;
|
|
197
|
+
aliases: Map<string, string>;
|
|
198
|
+
constructor();
|
|
199
|
+
/**
|
|
200
|
+
* Dynamically register language metadata discovered from normalized records.
|
|
201
|
+
*/
|
|
202
|
+
registerDatasetLanguage(iso639_3: string, bcp47: string, name: string, glottocode?: string | null, autonym?: string | null, dialect?: string | null): void;
|
|
203
|
+
/**
|
|
204
|
+
* Resolve a search string to matching ISO 639-3 codes (and direct identifiers).
|
|
205
|
+
* Returns a set of matching ISO codes (or Glottocodes).
|
|
206
|
+
*/
|
|
207
|
+
resolve(query: string): Set<string>;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* In-memory Inverted Index engine for Wikitongues Database.
|
|
212
|
+
* Provides O(1) indexed lookups by ID, ISO 639-3, BCP 47, Glottocode, Country, Speaker, License, etc.
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
declare class DatasetIndex {
|
|
216
|
+
readonly videos: Video[];
|
|
217
|
+
readonly byId: Map<string, Video>;
|
|
218
|
+
readonly byIso: Map<string, Video[]>;
|
|
219
|
+
readonly byIsoPrimary: Map<string, Video[]>;
|
|
220
|
+
readonly byBcp47: Map<string, Video[]>;
|
|
221
|
+
readonly byGlottocode: Map<string, Video[]>;
|
|
222
|
+
readonly byCountryCode: Map<string, Video[]>;
|
|
223
|
+
readonly byCountryName: Map<string, Video[]>;
|
|
224
|
+
readonly bySpeakerRole: Map<string, Video[]>;
|
|
225
|
+
readonly bySpeakerName: Map<string, Video[]>;
|
|
226
|
+
readonly byContentType: Map<string, Video[]>;
|
|
227
|
+
readonly byLicense: Map<string, Video[]>;
|
|
228
|
+
readonly withSubtitles: Video[];
|
|
229
|
+
constructor(videos: Video[]);
|
|
230
|
+
private appendToMap;
|
|
231
|
+
private buildIndices;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Full-Text Search Engine with multi-field scoring and relevance ranking for Wikitongues records.
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
declare class SearchEngine {
|
|
239
|
+
readonly videos: readonly Video[];
|
|
240
|
+
readonly resolver?: LanguageResolver;
|
|
241
|
+
constructor(videos: readonly Video[], resolver?: LanguageResolver);
|
|
242
|
+
/**
|
|
243
|
+
* Execute full-text search across all video metadata and rank results by score.
|
|
244
|
+
*/
|
|
245
|
+
search(query: string, limit?: number, minScore?: number): VideoCollection;
|
|
246
|
+
private scoreVideo;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Fluent QueryBuilder for Wikitongues Database.
|
|
251
|
+
* Enables expressive, composable, and chainable querying over Wikitongues records.
|
|
252
|
+
*/
|
|
253
|
+
|
|
254
|
+
declare class QueryBuilder {
|
|
255
|
+
private readonly _sourceVideos;
|
|
256
|
+
private readonly _resolver?;
|
|
257
|
+
private _filters;
|
|
258
|
+
private _sortKey;
|
|
259
|
+
private _sortDescending;
|
|
260
|
+
private _limitVal;
|
|
261
|
+
private _offsetVal;
|
|
262
|
+
constructor(videos: readonly Video[], resolver?: LanguageResolver);
|
|
263
|
+
clone(): QueryBuilder;
|
|
264
|
+
language(query: string, includeAdditional?: boolean): this;
|
|
265
|
+
iso(code: string, includeAdditional?: boolean): this;
|
|
266
|
+
bcp47(tag: string, exact?: boolean): this;
|
|
267
|
+
glottocode(code: string): this;
|
|
268
|
+
country(countryCodeOrName: string): this;
|
|
269
|
+
speaker(options: {
|
|
270
|
+
name?: string;
|
|
271
|
+
role?: string;
|
|
272
|
+
origin?: string;
|
|
273
|
+
}): this;
|
|
274
|
+
contentType(...types: string[]): this;
|
|
275
|
+
license(...licenses: string[]): this;
|
|
276
|
+
creativeCommonsOnly(): this;
|
|
277
|
+
withSubtitles(lang?: string): this;
|
|
278
|
+
withoutSubtitles(): this;
|
|
279
|
+
minDuration(seconds: number): this;
|
|
280
|
+
maxDuration(seconds: number): this;
|
|
281
|
+
durationBetween(minSeconds: number, maxSeconds: number): this;
|
|
282
|
+
uploadedAfter(dateStr: string): this;
|
|
283
|
+
uploadedBefore(dateStr: string): this;
|
|
284
|
+
uploadedBetween(startDate: string, endDate: string): this;
|
|
285
|
+
recordedBy(name: string): this;
|
|
286
|
+
filter(predicate: (video: Video) => boolean): this;
|
|
287
|
+
orderBy(key: string | ((video: Video) => any), descending?: boolean): this;
|
|
288
|
+
limit(n: number): this;
|
|
289
|
+
offset(n: number): this;
|
|
290
|
+
page(page?: number, pageSize?: number): this;
|
|
291
|
+
all(): VideoCollection;
|
|
292
|
+
first(): Video | null;
|
|
293
|
+
last(): Video | null;
|
|
294
|
+
count(): number;
|
|
295
|
+
exists(): boolean;
|
|
296
|
+
random(n?: number, seed?: number): VideoCollection;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* High-Level Client for the Wikitongues Database.
|
|
301
|
+
* Provides instant O(1) lookups, fluent querying, full-text search, discovery, and analytics.
|
|
302
|
+
*/
|
|
303
|
+
|
|
304
|
+
interface WikitonguesDBOptions {
|
|
305
|
+
data?: (VideoData | Video)[];
|
|
306
|
+
records?: (VideoData | Video)[];
|
|
307
|
+
}
|
|
308
|
+
declare class WikitonguesDB {
|
|
309
|
+
protected readonly _videos: Video[];
|
|
310
|
+
readonly resolver: LanguageResolver;
|
|
311
|
+
readonly index: DatasetIndex;
|
|
312
|
+
readonly searchEngine: SearchEngine;
|
|
313
|
+
constructor(options?: WikitonguesDBOptions);
|
|
314
|
+
get length(): number;
|
|
315
|
+
/**
|
|
316
|
+
* Create a WikitonguesDB instance directly from an in-memory list of dicts or Videos.
|
|
317
|
+
*/
|
|
318
|
+
static fromRecords(records: (VideoData | Video)[]): WikitonguesDB;
|
|
319
|
+
/**
|
|
320
|
+
* Create a WikitonguesDB instance from a JSON string or JSON array.
|
|
321
|
+
*/
|
|
322
|
+
static fromJSON(json: string | VideoData[]): WikitonguesDB;
|
|
323
|
+
/**
|
|
324
|
+
* Create a WikitonguesDB instance from a JSON or JSONL file path (Node.js environments).
|
|
325
|
+
*/
|
|
326
|
+
static fromFile(filepath: string): WikitonguesDB;
|
|
327
|
+
/**
|
|
328
|
+
* Lookup a video by its YouTube ID in O(1) time.
|
|
329
|
+
*/
|
|
330
|
+
get(videoId: string): Video | null;
|
|
331
|
+
/**
|
|
332
|
+
* Lookup videos matching a 3-letter SIL ISO 639-3 code in O(1) time.
|
|
333
|
+
*/
|
|
334
|
+
getByIso(code: string): VideoCollection;
|
|
335
|
+
/**
|
|
336
|
+
* Lookup videos matching a BCP 47 language tag in O(1) time.
|
|
337
|
+
*/
|
|
338
|
+
getByBcp47(tag: string): VideoCollection;
|
|
339
|
+
/**
|
|
340
|
+
* Lookup videos matching a Glottolog code in O(1) time.
|
|
341
|
+
*/
|
|
342
|
+
getByGlottocode(glottocode: string): VideoCollection;
|
|
343
|
+
/**
|
|
344
|
+
* Lookup videos matching an ISO 3166-1 alpha-2 code or country name in O(1) time.
|
|
345
|
+
*/
|
|
346
|
+
getByCountry(countryCodeOrName: string): VideoCollection;
|
|
347
|
+
/**
|
|
348
|
+
* Lookup videos for a given speaker name.
|
|
349
|
+
*/
|
|
350
|
+
getBySpeaker(name: string): VideoCollection;
|
|
351
|
+
/**
|
|
352
|
+
* Intelligent language search: resolves natural names, multilingual aliases ('russe'),
|
|
353
|
+
* ISO 639-3 ('rus'), BCP 47 ('ru'), autonyms ('Русский'), and dialects.
|
|
354
|
+
*/
|
|
355
|
+
findByLanguage(languageQuery: string, includeAdditional?: boolean): VideoCollection;
|
|
356
|
+
/**
|
|
357
|
+
* Shortcut method to filter videos by common criteria.
|
|
358
|
+
*/
|
|
359
|
+
find(filters?: FilterOptions): VideoCollection;
|
|
360
|
+
/**
|
|
361
|
+
* Initialize a new fluent QueryBuilder.
|
|
362
|
+
*/
|
|
363
|
+
query(): QueryBuilder;
|
|
364
|
+
/**
|
|
365
|
+
* Execute weighted full-text search across all metadata.
|
|
366
|
+
*/
|
|
367
|
+
search(query: string, limit?: number): VideoCollection;
|
|
368
|
+
/**
|
|
369
|
+
* Return all videos as a VideoCollection.
|
|
370
|
+
*/
|
|
371
|
+
all(): VideoCollection;
|
|
372
|
+
/**
|
|
373
|
+
* Return n random videos, optionally filtered by criteria.
|
|
374
|
+
*/
|
|
375
|
+
random(n?: number, seed?: number, filters?: FilterOptions): VideoCollection;
|
|
376
|
+
/**
|
|
377
|
+
* Return a structured inventory of all represented languages with summary metrics.
|
|
378
|
+
*/
|
|
379
|
+
languages(): LanguageSummary[];
|
|
380
|
+
/**
|
|
381
|
+
* Return a structured inventory of all represented countries with summary metrics.
|
|
382
|
+
*/
|
|
383
|
+
countries(): CountrySummary[];
|
|
384
|
+
/**
|
|
385
|
+
* Return a structured inventory of all speakers in the dataset.
|
|
386
|
+
*/
|
|
387
|
+
speakers(): SpeakerSummary[];
|
|
388
|
+
/**
|
|
389
|
+
* Compute aggregate dataset statistics.
|
|
390
|
+
*/
|
|
391
|
+
stats(): DatasetStats;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export { CountrySummary, DatasetIndex, DatasetStats, FilterOptions, Language, LanguageData, LanguageResolver, LanguageSummary, MULTILINGUAL_ALIASES, Provenance, ProvenanceData, QueryBuilder, RawMetadata, RawMetadataData, SearchEngine, Speaker, SpeakerData, SpeakerSummary, Transcription, TranscriptionData, Video, VideoCollection, VideoData, WikitonguesDB, type WikitonguesDBOptions, normalizeText };
|