glost 0.4.0 → 0.5.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.
Files changed (67) hide show
  1. package/README.md +253 -114
  2. package/dist/index.d.ts +29 -8
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +38 -24
  5. package/dist/index.js.map +1 -1
  6. package/dist/presets.d.ts +7 -0
  7. package/dist/presets.d.ts.map +1 -0
  8. package/dist/presets.js +7 -0
  9. package/dist/presets.js.map +1 -0
  10. package/dist/processor.d.ts +8 -0
  11. package/dist/processor.d.ts.map +1 -0
  12. package/dist/processor.js +7 -0
  13. package/dist/processor.js.map +1 -0
  14. package/dist/registry.d.ts +8 -0
  15. package/dist/registry.d.ts.map +1 -0
  16. package/dist/registry.js +7 -0
  17. package/dist/registry.js.map +1 -0
  18. package/package.json +27 -40
  19. package/src/index.ts +126 -69
  20. package/src/presets.ts +18 -0
  21. package/src/processor.ts +24 -0
  22. package/src/registry.ts +23 -0
  23. package/tsconfig.json +6 -3
  24. package/CHANGELOG.md +0 -296
  25. package/dist/cli/migrate.d.ts +0 -8
  26. package/dist/cli/migrate.d.ts.map +0 -1
  27. package/dist/cli/migrate.js +0 -229
  28. package/dist/cli/migrate.js.map +0 -1
  29. package/dist/errors.d.ts +0 -168
  30. package/dist/errors.d.ts.map +0 -1
  31. package/dist/errors.js +0 -300
  32. package/dist/errors.js.map +0 -1
  33. package/dist/example.d.ts +0 -10
  34. package/dist/example.d.ts.map +0 -1
  35. package/dist/example.js +0 -138
  36. package/dist/example.js.map +0 -1
  37. package/dist/guards.d.ts +0 -103
  38. package/dist/guards.d.ts.map +0 -1
  39. package/dist/guards.js +0 -264
  40. package/dist/guards.js.map +0 -1
  41. package/dist/nodes.d.ts +0 -163
  42. package/dist/nodes.d.ts.map +0 -1
  43. package/dist/nodes.js +0 -185
  44. package/dist/nodes.js.map +0 -1
  45. package/dist/types.d.ts +0 -395
  46. package/dist/types.d.ts.map +0 -1
  47. package/dist/types.js +0 -6
  48. package/dist/types.js.map +0 -1
  49. package/dist/utils.d.ts +0 -203
  50. package/dist/utils.d.ts.map +0 -1
  51. package/dist/utils.js +0 -497
  52. package/dist/utils.js.map +0 -1
  53. package/dist/validators.d.ts +0 -1876
  54. package/dist/validators.d.ts.map +0 -1
  55. package/dist/validators.js +0 -302
  56. package/dist/validators.js.map +0 -1
  57. package/src/__tests__/README.md +0 -20
  58. package/src/__tests__/example.test.ts +0 -43
  59. package/src/__tests__/example.ts +0 -186
  60. package/src/__tests__/mock-data.ts +0 -624
  61. package/src/cli/migrate.ts +0 -294
  62. package/src/errors.ts +0 -394
  63. package/src/guards.ts +0 -341
  64. package/src/nodes.ts +0 -326
  65. package/src/types.ts +0 -581
  66. package/src/utils.ts +0 -652
  67. package/src/validators.ts +0 -336
package/dist/guards.js DELETED
@@ -1,264 +0,0 @@
1
- // ============================================================================
2
- // GLOST Type Guards for Better Developer Experience
3
- // ============================================================================
4
- // ============================================================================
5
- // Core Node Type Guards
6
- // ============================================================================
7
- /**
8
- * Type guard to check if a node is an GLOSTWord
9
- */
10
- export function isGLOSTWord(node) {
11
- return (typeof node === "object" &&
12
- node !== null &&
13
- "type" in node &&
14
- node.type === "WordNode" &&
15
- "children" in node &&
16
- "lang" in node &&
17
- "script" in node &&
18
- "level" in node &&
19
- "metadata" in node &&
20
- "transcription" in node &&
21
- "extras" in node);
22
- }
23
- /**
24
- * Type guard to check if a node is an GLOSTSentence
25
- */
26
- export function isGLOSTSentence(node) {
27
- return (typeof node === "object" &&
28
- node !== null &&
29
- "type" in node &&
30
- node.type === "SentenceNode" &&
31
- "children" in node &&
32
- "lang" in node &&
33
- "script" in node &&
34
- "level" in node &&
35
- "metadata" in node);
36
- }
37
- /**
38
- * Type guard to check if a node is an GLOSTParagraph
39
- */
40
- export function isGLOSTParagraph(node) {
41
- return (typeof node === "object" &&
42
- node !== null &&
43
- "type" in node &&
44
- node.type === "ParagraphNode" &&
45
- "children" in node &&
46
- "lang" in node &&
47
- "script" in node &&
48
- "level" in node &&
49
- "metadata" in node);
50
- }
51
- /**
52
- * Type guard to check if a node is an GLOSTRoot
53
- */
54
- export function isGLOSTRoot(node) {
55
- return (typeof node === "object" &&
56
- node !== null &&
57
- "type" in node &&
58
- node.type === "RootNode" &&
59
- "children" in node &&
60
- "lang" in node &&
61
- "script" in node &&
62
- "level" in node &&
63
- "metadata" in node);
64
- }
65
- /**
66
- * Type guard to check if a node is an GLOSTText
67
- */
68
- export function isGLOSTText(node) {
69
- return (typeof node === "object" &&
70
- node !== null &&
71
- "type" in node &&
72
- node.type === "TextNode" &&
73
- "value" in node &&
74
- typeof node.value === "string");
75
- }
76
- /**
77
- * Type guard to check if a node is an GLOSTPunctuation
78
- */
79
- export function isGLOSTPunctuation(node) {
80
- return (typeof node === "object" &&
81
- node !== null &&
82
- "type" in node &&
83
- node.type === "PunctuationNode" &&
84
- "value" in node &&
85
- typeof node.value === "string");
86
- }
87
- /**
88
- * Type guard to check if a node is an GLOSTSymbol
89
- */
90
- export function isGLOSTSymbol(node) {
91
- return (typeof node === "object" &&
92
- node !== null &&
93
- "type" in node &&
94
- node.type === "SymbolNode" &&
95
- "value" in node &&
96
- typeof node.value === "string");
97
- }
98
- /**
99
- * Type guard to check if a node is an GLOSTWhiteSpace
100
- */
101
- export function isGLOSTWhiteSpace(node) {
102
- return (typeof node === "object" &&
103
- node !== null &&
104
- "type" in node &&
105
- node.type === "WhiteSpaceNode" &&
106
- "value" in node &&
107
- typeof node.value === "string");
108
- }
109
- /**
110
- * Type guard to check if a node is an GLOSTSource
111
- */
112
- export function isGLOSTSource(node) {
113
- return (typeof node === "object" &&
114
- node !== null &&
115
- "type" in node &&
116
- node.type === "SourceNode" &&
117
- "value" in node &&
118
- typeof node.value === "string");
119
- }
120
- // ============================================================================
121
- // Content Type Guards
122
- // ============================================================================
123
- /**
124
- * Type guard to check if a node is GLOSTNode (any GLOST node)
125
- */
126
- export function isGLOSTNode(node) {
127
- return (isGLOSTWord(node) ||
128
- isGLOSTSentence(node) ||
129
- isGLOSTParagraph(node) ||
130
- isGLOSTText(node) ||
131
- isGLOSTPunctuation(node) ||
132
- isGLOSTSymbol(node) ||
133
- isGLOSTWhiteSpace(node) ||
134
- isGLOSTSource(node) ||
135
- isGLOSTRoot(node));
136
- }
137
- // ============================================================================
138
- // Document Type Guards
139
- // ============================================================================
140
- /**
141
- * Type guard to check if a node is an GLOSTDocument (Root or Content)
142
- */
143
- export function isGLOSTDocument(node) {
144
- return isGLOSTRoot(node);
145
- }
146
- // ============================================================================
147
- // Array Type Guards
148
- // ============================================================================
149
- /**
150
- * Type guard to check if an array contains only GLOSTWord nodes
151
- */
152
- export function isGLOSTWordArray(nodes) {
153
- return nodes.every(isGLOSTWord);
154
- }
155
- /**
156
- * Type guard to check if an array contains only GLOSTSentence nodes
157
- */
158
- export function isGLOSTSentenceArray(nodes) {
159
- return nodes.every(isGLOSTSentence);
160
- }
161
- /**
162
- * Type guard to check if an array contains only GLOSTParagraph nodes
163
- */
164
- export function isGLOSTParagraphArray(nodes) {
165
- return nodes.every(isGLOSTParagraph);
166
- }
167
- /**
168
- * Type guard to check if an array contains only GLOSTContent nodes
169
- */
170
- export function isGLOSTContentArray(nodes) {
171
- return nodes.every(node => isGLOSTWord(node) ||
172
- isGLOSTSentence(node) ||
173
- isGLOSTParagraph(node) ||
174
- isGLOSTText(node) ||
175
- isGLOSTPunctuation(node) ||
176
- isGLOSTSymbol(node) ||
177
- isGLOSTWhiteSpace(node) ||
178
- isGLOSTSource(node));
179
- }
180
- // ============================================================================
181
- // Utility Type Guards
182
- // ============================================================================
183
- /**
184
- * Type guard to check if a node has children
185
- */
186
- export function hasChildren(node) {
187
- return (typeof node === "object" &&
188
- node !== null &&
189
- "children" in node &&
190
- Array.isArray(node.children));
191
- }
192
- /**
193
- * Type guard to check if a node has metadata
194
- */
195
- export function hasMetadata(node) {
196
- return (typeof node === "object" &&
197
- node !== null &&
198
- "metadata" in node &&
199
- typeof node.metadata === "object" &&
200
- node.metadata !== null);
201
- }
202
- /**
203
- * Type guard to check if a node has transcription
204
- */
205
- export function hasTranscription(node) {
206
- return (typeof node === "object" &&
207
- node !== null &&
208
- "transcription" in node &&
209
- typeof node.transcription === "object" &&
210
- node.transcription !== null);
211
- }
212
- /**
213
- * Type guard to check if a node has extras
214
- */
215
- export function hasExtras(node) {
216
- return (typeof node === "object" &&
217
- node !== null &&
218
- "extras" in node &&
219
- typeof node.extras === "object" &&
220
- node.extras !== null);
221
- }
222
- // ============================================================================
223
- // Validation Helpers
224
- // ============================================================================
225
- /**
226
- * Check if a node has valid GLOST structure (type guard based validation)
227
- * For schema-based validation, use validateGLOSTNode from validators.ts
228
- */
229
- export function isGLOSTNodeWithValidChildren(node) {
230
- if (!isGLOSTNode(node)) {
231
- return false;
232
- }
233
- // Additional validation for nodes with children
234
- if (hasChildren(node)) {
235
- return node.children.every(isGLOSTNode);
236
- }
237
- return true;
238
- }
239
- /**
240
- * Check if an array contains valid GLOST nodes (type guard based)
241
- */
242
- export function isGLOSTNodeArrayValid(nodes) {
243
- return nodes.every(isGLOSTNodeWithValidChildren);
244
- }
245
- /**
246
- * Check if a node is a leaf node (no children)
247
- */
248
- export function isLeafNode(node) {
249
- return (isGLOSTText(node) ||
250
- isGLOSTPunctuation(node) ||
251
- isGLOSTSymbol(node) ||
252
- isGLOSTWhiteSpace(node) ||
253
- isGLOSTSource(node));
254
- }
255
- /**
256
- * Check if a node is a container node (has children)
257
- */
258
- export function isContainerNode(node) {
259
- return (isGLOSTWord(node) ||
260
- isGLOSTSentence(node) ||
261
- isGLOSTParagraph(node) ||
262
- isGLOSTRoot(node));
263
- }
264
- //# sourceMappingURL=guards.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guards.js","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,oDAAoD;AACpD,+EAA+E;AAe/E,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E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IAAI,CACrB,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,IAAa;IACxD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gDAAgD;IAChD,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAQ,IAAI,CAAC,QAAsB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAgB;IACpD,OAAO,KAAK,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAe;IACxC,OAAO,CACL,WAAW,CAAC,IAAI,CAAC;QACjB,kBAAkB,CAAC,IAAI,CAAC;QACxB,aAAa,CAAC,IAAI,CAAC;QACnB,iBAAiB,CAAC,IAAI,CAAC;QACvB,aAAa,CAAC,IAAI,CAAC,CACpB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAe;IAC7C,OAAO,CACL,WAAW,CAAC,IAAI,CAAC;QACjB,eAAe,CAAC,IAAI,CAAC;QACrB,gBAAgB,CAAC,IAAI,CAAC;QACtB,WAAW,CAAC,IAAI,CAAC,CAClB,CAAC;AACJ,CAAC"}
package/dist/nodes.d.ts DELETED
@@ -1,163 +0,0 @@
1
- import type { LanguageCode, LinguisticMetadata, GLOSTExtras, GLOSTParagraph, GLOSTPunctuation, GLOSTRoot, GLOSTSentence, GLOSTSymbol, GLOSTText, GLOSTWhiteSpace, GLOSTWord, ScriptSystem, TransliterationData } from "./types.js";
2
- /**
3
- * Options for creating a GLOST word node
4
- */
5
- export interface CreateWordNodeOptions {
6
- /** The text value of the word */
7
- value: string;
8
- /** Transcription data (IPA, romanization, etc.) */
9
- transcription: TransliterationData;
10
- /** Linguistic metadata (part of speech, etc.) */
11
- metadata: LinguisticMetadata;
12
- /** Language code (ISO-639-1, ISO-639-3, or BCP-47) */
13
- lang?: LanguageCode;
14
- /** Script system used */
15
- script?: ScriptSystem;
16
- /** Additional extension data */
17
- extras?: GLOSTExtras;
18
- }
19
- /**
20
- * Options for creating a GLOST sentence node
21
- */
22
- export interface CreateSentenceNodeOptions {
23
- /** The original text of the sentence */
24
- originalText: string;
25
- /** Language code */
26
- lang: LanguageCode;
27
- /** Script system used */
28
- script: ScriptSystem;
29
- /** Word nodes in the sentence */
30
- children?: GLOSTWord[];
31
- /** Optional transcription data */
32
- transcription?: TransliterationData;
33
- /** Additional extension data */
34
- extras?: GLOSTExtras;
35
- }
36
- /**
37
- * Options for creating a GLOST root node
38
- */
39
- export interface CreateRootNodeOptions {
40
- /** Language code */
41
- lang: LanguageCode;
42
- /** Script system used */
43
- script: ScriptSystem;
44
- /** Paragraph nodes */
45
- children?: GLOSTParagraph[];
46
- /** Document metadata */
47
- metadata?: {
48
- title?: string;
49
- author?: string;
50
- date?: string;
51
- description?: string;
52
- };
53
- /** Additional extension data */
54
- extras?: GLOSTExtras;
55
- }
56
- /**
57
- * Options for creating a simple word node
58
- */
59
- export interface CreateSimpleWordOptions {
60
- /** The text value of the word */
61
- text: string;
62
- /** Transliteration text */
63
- transliteration: string;
64
- /** Transcription system (default: "ipa") */
65
- system?: string;
66
- /** Part of speech (default: "unknown") */
67
- partOfSpeech?: string;
68
- }
69
- /**
70
- * Create a GLOST word node
71
- *
72
- * @example
73
- * ```typescript
74
- * const word = createGLOSTWordNode({
75
- * value: "hello",
76
- * transcription: { ipa: { text: "həˈloʊ", system: "ipa" } },
77
- * metadata: { partOfSpeech: "interjection" },
78
- * lang: "en",
79
- * script: "latin"
80
- * });
81
- * ```
82
- */
83
- export declare function createGLOSTWordNode(options: CreateWordNodeOptions): GLOSTWord;
84
- /**
85
- * Create a GLOST sentence node
86
- *
87
- * @example
88
- * ```typescript
89
- * const sentence = createGLOSTSentenceNode({
90
- * originalText: "Hello world",
91
- * lang: "en",
92
- * script: "latin",
93
- * children: [wordNode1, wordNode2]
94
- * });
95
- * ```
96
- */
97
- export declare function createGLOSTSentenceNode(options: CreateSentenceNodeOptions): GLOSTSentence;
98
- /**
99
- * Create a GLOST paragraph node
100
- */
101
- export declare function createGLOSTParagraphNode(children?: GLOSTSentence[], extras?: GLOSTExtras): GLOSTParagraph;
102
- /**
103
- * Create a GLOST root node
104
- *
105
- * @example
106
- * ```typescript
107
- * const root = createGLOSTRootNode({
108
- * lang: "en",
109
- * script: "latin",
110
- * children: [paragraphNode],
111
- * metadata: { title: "My Document" }
112
- * });
113
- * ```
114
- */
115
- export declare function createGLOSTRootNode(options: CreateRootNodeOptions): GLOSTRoot;
116
- /**
117
- * Create a simple word node with basic transcription
118
- *
119
- * @example
120
- * ```typescript
121
- * const word = createSimpleWord({
122
- * text: "hello",
123
- * transliteration: "həˈloʊ",
124
- * system: "ipa",
125
- * partOfSpeech: "interjection"
126
- * });
127
- * ```
128
- */
129
- export declare function createSimpleWord(options: CreateSimpleWordOptions): GLOSTWord;
130
- /**
131
- * Create a sentence from an array of words
132
- */
133
- export declare function createSentenceFromWords(words: GLOSTWord[], lang: LanguageCode, script: ScriptSystem, originalText?: string): GLOSTSentence;
134
- /**
135
- * Create a paragraph from an array of sentences
136
- */
137
- export declare function createParagraphFromSentences(sentences: GLOSTSentence[]): GLOSTParagraph;
138
- /**
139
- * Create a document from an array of paragraphs
140
- */
141
- export declare function createDocumentFromParagraphs(paragraphs: GLOSTParagraph[], lang: LanguageCode, script: ScriptSystem, metadata?: {
142
- title?: string;
143
- author?: string;
144
- date?: string;
145
- description?: string;
146
- }): GLOSTRoot;
147
- /**
148
- * Create a GLOST punctuation node
149
- */
150
- export declare function createGLOSTPunctuationNode(value: string): GLOSTPunctuation;
151
- /**
152
- * Create a GLOST whitespace node
153
- */
154
- export declare function createGLOSTWhiteSpaceNode(value: string): GLOSTWhiteSpace;
155
- /**
156
- * Create a GLOST symbol node
157
- */
158
- export declare function createGLOSTSymbolNode(value: string): GLOSTSymbol;
159
- /**
160
- * Create a GLOST text node
161
- */
162
- export declare function createGLOSTTextNode(value: string): GLOSTText;
163
- //# sourceMappingURL=nodes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,WAAW,EACX,SAAS,EACT,eAAe,EACf,SAAS,EACT,YAAY,EACZ,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAMpB;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,aAAa,EAAE,mBAAmB,CAAC;IACnC,iDAAiD;IACjD,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,sDAAsD;IACtD,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,yBAAyB;IACzB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,gCAAgC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,yBAAyB;IACzB,MAAM,EAAE,YAAY,CAAC;IACrB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IACvB,kCAAkC;IAClC,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,gCAAgC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,oBAAoB;I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EAAE,MAAM,GACpB,aAAa,CAaf;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,aAAa,EAAE,GACzB,cAAc,CAEhB;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,cAAc,EAAE,EAC5B,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,YAAY,EACpB,QAAQ,CAAC,EAAE;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACA,SAAS,CAEX;AAMD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAK1E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAKxE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAKhE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAK5D"}
package/dist/nodes.js DELETED
@@ -1,185 +0,0 @@
1
- // ============================================================================
2
- // Node Factory Functions
3
- // ============================================================================
4
- /**
5
- * Create a GLOST word node
6
- *
7
- * @example
8
- * ```typescript
9
- * const word = createGLOSTWordNode({
10
- * value: "hello",
11
- * transcription: { ipa: { text: "həˈloʊ", system: "ipa" } },
12
- * metadata: { partOfSpeech: "interjection" },
13
- * lang: "en",
14
- * script: "latin"
15
- * });
16
- * ```
17
- */
18
- export function createGLOSTWordNode(options) {
19
- const { value, transcription, metadata, lang, script, extras } = options;
20
- return {
21
- type: "WordNode",
22
- lang,
23
- script,
24
- transcription,
25
- metadata,
26
- extras,
27
- children: [createGLOSTTextNode(value)],
28
- };
29
- }
30
- /**
31
- * Create a GLOST sentence node
32
- *
33
- * @example
34
- * ```typescript
35
- * const sentence = createGLOSTSentenceNode({
36
- * originalText: "Hello world",
37
- * lang: "en",
38
- * script: "latin",
39
- * children: [wordNode1, wordNode2]
40
- * });
41
- * ```
42
- */
43
- export function createGLOSTSentenceNode(options) {
44
- const { originalText, lang, script, children = [], transcription, extras, } = options;
45
- return {
46
- type: "SentenceNode",
47
- originalText,
48
- lang,
49
- script,
50
- transcription,
51
- children,
52
- extras,
53
- };
54
- }
55
- /**
56
- * Create a GLOST paragraph node
57
- */
58
- export function createGLOSTParagraphNode(children = [], extras) {
59
- return {
60
- type: "ParagraphNode",
61
- children,
62
- position: undefined,
63
- extras,
64
- };
65
- }
66
- /**
67
- * Create a GLOST root node
68
- *
69
- * @example
70
- * ```typescript
71
- * const root = createGLOSTRootNode({
72
- * lang: "en",
73
- * script: "latin",
74
- * children: [paragraphNode],
75
- * metadata: { title: "My Document" }
76
- * });
77
- * ```
78
- */
79
- export function createGLOSTRootNode(options) {
80
- const { lang, script, children = [], metadata, extras } = options;
81
- return {
82
- type: "RootNode",
83
- lang,
84
- script,
85
- metadata,
86
- children,
87
- position: undefined,
88
- extras,
89
- };
90
- }
91
- // ============================================================================
92
- // Helper Functions for Common Patterns
93
- // ============================================================================
94
- /**
95
- * Create a simple word node with basic transcription
96
- *
97
- * @example
98
- * ```typescript
99
- * const word = createSimpleWord({
100
- * text: "hello",
101
- * transliteration: "həˈloʊ",
102
- * system: "ipa",
103
- * partOfSpeech: "interjection"
104
- * });
105
- * ```
106
- */
107
- export function createSimpleWord(options) {
108
- const { text, transliteration, system = "ipa", partOfSpeech = "unknown" } = options;
109
- const transcription = {
110
- [system]: {
111
- text: transliteration,
112
- syllables: [text],
113
- },
114
- };
115
- const metadata = {
116
- partOfSpeech,
117
- };
118
- return createGLOSTWordNode({ value: text, transcription, metadata });
119
- }
120
- /**
121
- * Create a sentence from an array of words
122
- */
123
- export function createSentenceFromWords(words, lang, script, originalText) {
124
- const text = originalText ||
125
- words
126
- .map((w) => {
127
- // Extract text from word's Text node children
128
- const textNode = w.children.find((child) => child.type === "TextNode");
129
- return textNode ? textNode.value : "";
130
- })
131
- .join("");
132
- return createGLOSTSentenceNode({ originalText: text, lang, script, children: words });
133
- }
134
- /**
135
- * Create a paragraph from an array of sentences
136
- */
137
- export function createParagraphFromSentences(sentences) {
138
- return createGLOSTParagraphNode(sentences);
139
- }
140
- /**
141
- * Create a document from an array of paragraphs
142
- */
143
- export function createDocumentFromParagraphs(paragraphs, lang, script, metadata) {
144
- return createGLOSTRootNode({ lang, script, children: paragraphs, metadata });
145
- }
146
- // ============================================================================
147
- // NLCST Node Factory Functions
148
- // ============================================================================
149
- /**
150
- * Create a GLOST punctuation node
151
- */
152
- export function createGLOSTPunctuationNode(value) {
153
- return {
154
- type: "PunctuationNode",
155
- value,
156
- };
157
- }
158
- /**
159
- * Create a GLOST whitespace node
160
- */
161
- export function createGLOSTWhiteSpaceNode(value) {
162
- return {
163
- type: "WhiteSpaceNode",
164
- value,
165
- };
166
- }
167
- /**
168
- * Create a GLOST symbol node
169
- */
170
- export function createGLOSTSymbolNode(value) {
171
- return {
172
- type: "SymbolNode",
173
- value,
174
- };
175
- }
176
- /**
177
- * Create a GLOST text node
178
- */
179
- export function createGLOSTTextNode(value) {
180
- return {
181
- type: "TextNode",
182
- value,
183
- };
184
- }
185
- //# sourceMappingURL=nodes.js.map
package/dist/nodes.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AA4FA,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA8B;IAChE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACzE,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,IAAI;QACJ,MAAM;QACN,aAAa;QACb,QAAQ;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