glost 0.1.0 → 0.2.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.
@@ -3,19 +3,19 @@ import {
3
3
  createGLOSTSentenceNode,
4
4
  createGLOSTParagraphNode,
5
5
  createGLOSTRootNode
6
- } from './nodes';
6
+ } from 'glost/nodes';
7
7
 
8
8
  import type {
9
- GLOSTWord} from './types';
9
+ GLOSTWord} from '../types.js';
10
10
 
11
11
  // ============================================================================
12
12
  // Enhanced Thai Example with Extras
13
13
  // ============================================================================
14
14
 
15
15
  const thaiWordsWithExtras: GLOSTWord[] = [
16
- createGLOSTWordNode(
17
- 'สวัสดี',
18
- {
16
+ createGLOSTWordNode({
17
+ value: 'สวัสดี',
18
+ transcription: {
19
19
  rtgs: {
20
20
  text: 'sà-wàt-dii',
21
21
  system: 'rtgs',
@@ -38,15 +38,14 @@ const thaiWordsWithExtras: GLOSTWord[] = [
38
38
  syllables: ['sa', 'wat', 'diː']
39
39
  }
40
40
  },
41
- {
41
+ metadata: {
42
42
  meaning: 'hello, hi',
43
43
  partOfSpeech: 'interjection',
44
44
  usage: 'greeting, formal and informal'
45
45
  },
46
- 'word',
47
- 'th',
48
- 'thai',
49
- {
46
+ lang: 'th',
47
+ script: 'thai',
48
+ extras: {
50
49
  translations: {
51
50
  en: 'hello, hi',
52
51
  ja: 'こんにちは',
@@ -61,10 +60,10 @@ const thaiWordsWithExtras: GLOSTWord[] = [
61
60
  examples: ['สวัสดีครับ', 'สวัสดีค่ะ', 'สวัสดีทุกคน']
62
61
  }
63
62
  }
64
- ),
65
- createGLOSTWordNode(
66
- 'ครับ',
67
- {
63
+ }),
64
+ createGLOSTWordNode({
65
+ value: 'ครับ',
66
+ transcription: {
68
67
  rtgs: {
69
68
  text: 'khráp',
70
69
  system: 'rtgs',
@@ -87,15 +86,14 @@ const thaiWordsWithExtras: GLOSTWord[] = [
87
86
  syllables: ['khrap']
88
87
  }
89
88
  },
90
- {
89
+ metadata: {
91
90
  meaning: 'polite particle for male speakers',
92
91
  partOfSpeech: 'particle',
93
92
  usage: 'sentence ending, formal speech'
94
93
  },
95
- 'word',
96
- 'th',
97
- 'thai',
98
- {
94
+ lang: 'th',
95
+ script: 'thai',
96
+ extras: {
99
97
  translations: {
100
98
  en: 'polite particle (male)',
101
99
  ja: '丁寧語の助詞(男性)',
@@ -110,10 +108,10 @@ const thaiWordsWithExtras: GLOSTWord[] = [
110
108
  examples: ['ขอบคุณครับ', 'ไม่เป็นไรครับ', 'ครับครับ']
111
109
  }
112
110
  }
113
- ),
114
- createGLOSTWordNode(
115
- 'ผม',
116
- {
111
+ }),
112
+ createGLOSTWordNode({
113
+ value: 'ผม',
114
+ transcription: {
117
115
  rtgs: {
118
116
  text: 'phǒm',
119
117
  system: 'rtgs',
@@ -136,15 +134,14 @@ const thaiWordsWithExtras: GLOSTWord[] = [
136
134
  syllables: ['phom']
137
135
  }
138
136
  },
139
- {
137
+ metadata: {
140
138
  meaning: 'I, me (male)',
141
139
  partOfSpeech: 'pronoun',
142
140
  usage: 'first person singular, male speaker'
143
141
  },
144
- 'word',
145
- 'th',
146
- 'thai',
147
- {
142
+ lang: 'th',
143
+ script: 'thai',
144
+ extras: {
148
145
  translations: {
149
146
  en: 'I, me (male)',
150
147
  ja: '私(男性)',
@@ -159,10 +156,10 @@ const thaiWordsWithExtras: GLOSTWord[] = [
159
156
  examples: ['ผมชื่อ...', 'ผมชอบ...', 'ผมจะไป...']
160
157
  }
161
158
  }
162
- ),
163
- createGLOSTWordNode(
164
- 'ชื่อ',
165
- {
159
+ }),
160
+ createGLOSTWordNode({
161
+ value: 'ชื่อ',
162
+ transcription: {
166
163
  rtgs: {
167
164
  text: 'chûue',
168
165
  system: 'rtgs',
@@ -185,15 +182,14 @@ const thaiWordsWithExtras: GLOSTWord[] = [
185
182
  syllables: ['chue']
186
183
  }
187
184
  },
188
- {
185
+ metadata: {
189
186
  meaning: 'name',
190
187
  partOfSpeech: 'noun',
191
188
  usage: 'noun, can be used as verb \'to be named\''
192
189
  },
193
- 'word',
194
- 'th',
195
- 'thai',
196
- {
190
+ lang: 'th',
191
+ script: 'thai',
192
+ extras: {
197
193
  translations: {
198
194
  en: 'name',
199
195
  ja: '名前',
@@ -208,10 +204,10 @@ const thaiWordsWithExtras: GLOSTWord[] = [
208
204
  examples: ['ชื่ออะไรครับ', 'ชื่อของผมคือ...', 'ตั้งชื่อ']
209
205
  }
210
206
  }
211
- ),
212
- createGLOSTWordNode(
213
- 'สมชาย',
214
- {
207
+ }),
208
+ createGLOSTWordNode({
209
+ value: 'สมชาย',
210
+ transcription: {
215
211
  rtgs: {
216
212
  text: 'sǒm-chaai',
217
213
  system: 'rtgs',
@@ -234,15 +230,14 @@ const thaiWordsWithExtras: GLOSTWord[] = [
234
230
  syllables: ['som', 'chaai']
235
231
  }
236
232
  },
237
- {
233
+ metadata: {
238
234
  meaning: 'male given name',
239
235
  partOfSpeech: 'proper noun',
240
236
  usage: 'personal name, common Thai male name'
241
237
  },
242
- 'word',
243
- 'th',
244
- 'thai',
245
- {
238
+ lang: 'th',
239
+ script: 'thai',
240
+ extras: {
246
241
  translations: {
247
242
  en: 'Somchai (male name)',
248
243
  ja: 'ソムチャイ(男性名)',
@@ -257,7 +252,7 @@ const thaiWordsWithExtras: GLOSTWord[] = [
257
252
  examples: ['คุณสมชาย', 'สมชายเป็นคนดี', 'เพื่อนของสมชาย']
258
253
  }
259
254
  }
260
- )
255
+ })
261
256
  ];
262
257
 
263
258
  // ============================================================================
@@ -265,9 +260,9 @@ const thaiWordsWithExtras: GLOSTWord[] = [
265
260
  // ============================================================================
266
261
 
267
262
  const japaneseWordsWithExtras: GLOSTWord[] = [
268
- createGLOSTWordNode(
269
- '私',
270
- {
263
+ createGLOSTWordNode({
264
+ value: '私',
265
+ transcription: {
271
266
  romaji: {
272
267
  text: 'watashi',
273
268
  system: 'romaji',
@@ -284,15 +279,14 @@ const japaneseWordsWithExtras: GLOSTWord[] = [
284
279
  syllables: ['wa', 'ta', 'shi']
285
280
  }
286
281
  },
287
- {
282
+ metadata: {
288
283
  meaning: 'I, me',
289
284
  partOfSpeech: 'pronoun',
290
285
  usage: 'first person singular, formal and informal'
291
286
  },
292
- 'word',
293
- 'ja',
294
- 'mixed',
295
- {
287
+ lang: 'ja',
288
+ script: 'mixed',
289
+ extras: {
296
290
  translations: {
297
291
  en: 'I, me',
298
292
  th: 'ผม/ดิฉัน',
@@ -307,10 +301,10 @@ const japaneseWordsWithExtras: GLOSTWord[] = [
307
301
  examples: ['私は学生です', '私の名前は...', '私も行きます']
308
302
  }
309
303
  }
310
- ),
311
- createGLOSTWordNode(
312
- 'の',
313
- {
304
+ }),
305
+ createGLOSTWordNode({
306
+ value: 'の',
307
+ transcription: {
314
308
  romaji: {
315
309
  text: 'no',
316
310
  system: 'romaji',
@@ -327,15 +321,14 @@ const japaneseWordsWithExtras: GLOSTWord[] = [
327
321
  syllables: ['no']
328
322
  }
329
323
  },
330
- {
324
+ metadata: {
331
325
  meaning: 'possessive particle',
332
326
  partOfSpeech: 'particle',
333
327
  usage: 'indicates possession or relationship'
334
328
  },
335
- 'word',
336
- 'ja',
337
- 'mixed',
338
- {
329
+ lang: 'ja',
330
+ script: 'mixed',
331
+ extras: {
339
332
  translations: {
340
333
  en: 'possessive particle',
341
334
  th: 'คำบุพบทแสดงความเป็นเจ้าของ',
@@ -350,10 +343,10 @@ const japaneseWordsWithExtras: GLOSTWord[] = [
350
343
  examples: ['私の本', '日本の文化', '友達の家']
351
344
  }
352
345
  }
353
- ),
354
- createGLOSTWordNode(
355
- '名前',
356
- {
346
+ }),
347
+ createGLOSTWordNode({
348
+ value: '名前',
349
+ transcription: {
357
350
  romaji: {
358
351
  text: 'namae',
359
352
  system: 'romaji',
@@ -370,15 +363,14 @@ const japaneseWordsWithExtras: GLOSTWord[] = [
370
363
  syllables: ['na', 'mae']
371
364
  }
372
365
  },
373
- {
366
+ metadata: {
374
367
  meaning: 'name',
375
368
  partOfSpeech: 'noun',
376
369
  usage: 'noun, refers to a person\'s name'
377
370
  },
378
- 'word',
379
- 'ja',
380
- 'mixed',
381
- {
371
+ lang: 'ja',
372
+ script: 'mixed',
373
+ extras: {
382
374
  translations: {
383
375
  en: 'name',
384
376
  th: 'ชื่อ',
@@ -393,10 +385,10 @@ const japaneseWordsWithExtras: GLOSTWord[] = [
393
385
  examples: ['お名前は?', '名前を教えてください', '美しい名前']
394
386
  }
395
387
  }
396
- ),
397
- createGLOSTWordNode(
398
- 'は',
399
- {
388
+ }),
389
+ createGLOSTWordNode({
390
+ value: 'は',
391
+ transcription: {
400
392
  romaji: {
401
393
  text: 'wa',
402
394
  system: 'romaji',
@@ -413,15 +405,14 @@ const japaneseWordsWithExtras: GLOSTWord[] = [
413
405
  syllables: ['wa']
414
406
  }
415
407
  },
416
- {
408
+ metadata: {
417
409
  meaning: 'topic particle',
418
410
  partOfSpeech: 'particle',
419
411
  usage: 'marks the topic of the sentence'
420
412
  },
421
- 'word',
422
- 'ja',
423
- 'mixed',
424
- {
413
+ lang: 'ja',
414
+ script: 'mixed',
415
+ extras: {
425
416
  translations: {
426
417
  en: 'topic particle',
427
418
  th: 'คำบุพบทแสดงหัวข้อ',
@@ -436,10 +427,10 @@ const japaneseWordsWithExtras: GLOSTWord[] = [
436
427
  examples: ['私は学生です', 'これは本です', '日本は美しい国です']
437
428
  }
438
429
  }
439
- ),
440
- createGLOSTWordNode(
441
- '田中',
442
- {
430
+ }),
431
+ createGLOSTWordNode({
432
+ value: '田中',
433
+ transcription: {
443
434
  romaji: {
444
435
  text: 'tanaka',
445
436
  system: 'romaji',
@@ -456,15 +447,14 @@ const japaneseWordsWithExtras: GLOSTWord[] = [
456
447
  syllables: ['ta', 'na', 'ka']
457
448
  }
458
449
  },
459
- {
450
+ metadata: {
460
451
  meaning: 'surname Tanaka',
461
452
  partOfSpeech: 'proper noun',
462
453
  usage: 'family name, very common Japanese surname'
463
454
  },
464
- 'word',
465
- 'ja',
466
- 'mixed',
467
- {
455
+ lang: 'ja',
456
+ script: 'mixed',
457
+ extras: {
468
458
  translations: {
469
459
  en: 'Tanaka (surname)',
470
460
  th: 'ทานากะ (นามสกุล)',
@@ -479,10 +469,10 @@ const japaneseWordsWithExtras: GLOSTWord[] = [
479
469
  examples: ['田中さん', '田中先生', '田中家']
480
470
  }
481
471
  }
482
- ),
483
- createGLOSTWordNode(
484
- 'です',
485
- {
472
+ }),
473
+ createGLOSTWordNode({
474
+ value: 'です',
475
+ transcription: {
486
476
  romaji: {
487
477
  text: 'desu',
488
478
  system: 'romaji',
@@ -499,15 +489,14 @@ const japaneseWordsWithExtras: GLOSTWord[] = [
499
489
  syllables: ['de', 'su']
500
490
  }
501
491
  },
502
- {
492
+ metadata: {
503
493
  meaning: 'copula (is, am, are)',
504
494
  partOfSpeech: 'copula',
505
495
  usage: 'polite form of the copula, formal speech'
506
496
  },
507
- 'word',
508
- 'ja',
509
- 'mixed',
510
- {
497
+ lang: 'ja',
498
+ script: 'mixed',
499
+ extras: {
511
500
  translations: {
512
501
  en: 'is, am, are (polite)',
513
502
  th: 'เป็น, คือ (สุภาพ)',
@@ -522,49 +511,49 @@ const japaneseWordsWithExtras: GLOSTWord[] = [
522
511
  examples: ['私は学生です', 'これは本です', '田中さんです']
523
512
  }
524
513
  }
525
- )
514
+ })
526
515
  ];
527
516
 
528
517
  // ============================================================================
529
518
  // Create Enhanced Document Structure
530
519
  // ============================================================================
531
520
 
532
- const thaiSentenceWithExtras = createGLOSTSentenceNode(
533
- 'สวัสดีครับ ผมชื่อสมชาย',
534
- 'th',
535
- 'thai',
536
- thaiWordsWithExtras
537
- );
521
+ const thaiSentenceWithExtras = createGLOSTSentenceNode({
522
+ originalText: 'สวัสดีครับ ผมชื่อสมชาย',
523
+ lang: 'th',
524
+ script: 'thai',
525
+ children: thaiWordsWithExtras
526
+ });
538
527
 
539
- const japaneseSentenceWithExtras = createGLOSTSentenceNode(
540
- '私の名前は田中です。',
541
- 'ja',
542
- 'mixed',
543
- japaneseWordsWithExtras
544
- );
528
+ const japaneseSentenceWithExtras = createGLOSTSentenceNode({
529
+ originalText: '私の名前は田中です。',
530
+ lang: 'ja',
531
+ script: 'mixed',
532
+ children: japaneseWordsWithExtras
533
+ });
545
534
 
546
- const thaiParagraphWithExtras = createGLOSTParagraphNode( [thaiSentenceWithExtras]);
547
- const japaneseParagraphWithExtras = createGLOSTParagraphNode( [japaneseSentenceWithExtras]);
535
+ const thaiParagraphWithExtras = createGLOSTParagraphNode([thaiSentenceWithExtras]);
536
+ const japaneseParagraphWithExtras = createGLOSTParagraphNode([japaneseSentenceWithExtras]);
548
537
 
549
- export const thaiDocumentWithExtras = createGLOSTRootNode(
550
- 'th',
551
- 'thai',
552
- [thaiParagraphWithExtras],
553
- {
538
+ export const thaiDocumentWithExtras = createGLOSTRootNode({
539
+ lang: 'th',
540
+ script: 'thai',
541
+ children: [thaiParagraphWithExtras],
542
+ metadata: {
554
543
  title: 'Thai Greeting Example with Extras',
555
544
  description: 'Enhanced Thai example with i18n translations and metadata'
556
545
  }
557
- );
546
+ });
558
547
 
559
- export const japaneseDocumentWithExtras = createGLOSTRootNode(
560
- 'ja',
561
- 'mixed',
562
- [japaneseParagraphWithExtras],
563
- {
548
+ export const japaneseDocumentWithExtras = createGLOSTRootNode({
549
+ lang: 'ja',
550
+ script: 'mixed',
551
+ children: [japaneseParagraphWithExtras],
552
+ metadata: {
564
553
  title: 'Japanese Greeting Example with Extras',
565
554
  description: 'Enhanced Japanese example with i18n translations and metadata'
566
555
  }
567
- );
556
+ });
568
557
 
569
558
  // ============================================================================
570
559
  // Utility Functions for Working with Extras
@@ -583,7 +572,7 @@ export function getQuickTranslation(word: GLOSTWord, targetLang: string): string
583
572
  export function getAllTranslations(word: GLOSTWord): Record<string, string> {
584
573
  const translations = word.extras?.translations;
585
574
  if (!translations) return {};
586
-
575
+
587
576
  const result: Record<string, string> = {};
588
577
  Object.entries(translations).forEach(([lang, text]) => {
589
578
  if (text !== undefined) {
package/src/index.ts CHANGED
@@ -7,7 +7,6 @@ export * from "./utils";
7
7
  export * from "./validators";
8
8
  export * from "./guards";
9
9
  // export * from './example';
10
- export * from "./mock-data";
11
10
 
12
11
  // Re-export utility types
13
12
  export type { ParagraphLike } from "./utils";