glost-core 0.5.0 → 0.6.2
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/CHANGELOG.md +27 -0
- package/LICENSE +21 -21
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/__benchmarks__/document-creation.bench.d.ts +7 -0
- package/src/__benchmarks__/document-creation.bench.d.ts.map +1 -0
- package/src/__benchmarks__/document-creation.bench.js +71 -0
- package/src/__benchmarks__/document-creation.bench.js.map +1 -0
- package/src/__benchmarks__/traversal.bench.d.ts +7 -0
- package/src/__benchmarks__/traversal.bench.d.ts.map +1 -0
- package/src/__benchmarks__/traversal.bench.js +124 -0
- package/src/__benchmarks__/traversal.bench.js.map +1 -0
- package/src/__tests__/example.d.ts +10 -0
- package/src/__tests__/example.d.ts.map +1 -0
- package/src/__tests__/example.js +140 -0
- package/src/__tests__/example.js.map +1 -0
- package/src/__tests__/mock-data.d.ts +35 -0
- package/src/__tests__/mock-data.d.ts.map +1 -0
- package/src/__tests__/mock-data.js +591 -0
- package/src/__tests__/mock-data.js.map +1 -0
- package/src/cli/migrate.d.ts +8 -0
- package/src/cli/migrate.d.ts.map +1 -0
- package/src/cli/migrate.js +229 -0
- package/src/cli/migrate.js.map +1 -0
- package/src/errors.d.ts +168 -0
- package/src/errors.d.ts.map +1 -0
- package/src/errors.js +300 -0
- package/src/errors.js.map +1 -0
- package/src/guards.d.ts +103 -0
- package/src/guards.d.ts.map +1 -0
- package/src/guards.js +264 -0
- package/src/guards.js.map +1 -0
- package/src/index.d.ts +9 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +25 -0
- package/src/index.js.map +1 -0
- package/src/nodes.d.ts +227 -0
- package/src/nodes.d.ts.map +1 -0
- package/src/nodes.js +243 -0
- package/src/nodes.js.map +1 -0
- package/src/types.d.ts +442 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.js +51 -0
- package/src/types.js.map +1 -0
- package/src/utils.d.ts +247 -0
- package/src/utils.d.ts.map +1 -0
- package/src/utils.js +564 -0
- package/src/utils.js.map +1 -0
- package/src/validators.d.ts +1876 -0
- package/src/validators.d.ts.map +1 -0
- package/src/validators.js +302 -0
- package/src/validators.js.map +1 -0
- package/tsconfig.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# glost
|
|
2
2
|
|
|
3
|
+
## 0.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Patch version bump for republishing
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- glost-common@0.4.2
|
|
10
|
+
|
|
11
|
+
## 0.6.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Patch version bump for republishing
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- glost-common@0.4.1
|
|
18
|
+
|
|
19
|
+
## 0.6.0
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- Minor version bump for npm deployment
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
- glost-common@0.4.0
|
|
29
|
+
|
|
3
30
|
## 0.4.0
|
|
4
31
|
|
|
5
32
|
### Major Changes
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 GLOST Contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 GLOST Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -187,7 +187,7 @@ See [glost-ja documentation](../languages/ja/README.md).
|
|
|
187
187
|
|
|
188
188
|
### Core Packages
|
|
189
189
|
- `glost-common` - Shared utilities and language configs
|
|
190
|
-
- `glost-
|
|
190
|
+
- `glost-plugins` - Extension system for transforming GLOST trees
|
|
191
191
|
- `glost-utils` - Utilities for working with GLOST documents
|
|
192
192
|
|
|
193
193
|
### Language Packages
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glost-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Core types, nodes, and utilities for GLOST (Glossed Syntax Tree)",
|
|
5
5
|
"author": "fustilio",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"unist-util-select": "^5.1.0",
|
|
49
49
|
"unist-util-visit": "^5.0.0",
|
|
50
50
|
"zod": "^3.23.8",
|
|
51
|
-
"glost-common": "0.2
|
|
51
|
+
"glost-common": "0.4.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/nlcst": "^2.0.3",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-creation.bench.d.ts","sourceRoot":"","sources":["document-creation.bench.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document Creation Performance Benchmarks
|
|
3
|
+
*
|
|
4
|
+
* Compares different approaches to creating GLOST documents
|
|
5
|
+
*/
|
|
6
|
+
import { bench, describe } from 'vitest';
|
|
7
|
+
import { createSimpleDocument, createGLOSTWordNode, createDocumentFromSentences, createSentenceFromWords, createParagraphFromSentences, createDocumentFromParagraphs, } from '../index.js';
|
|
8
|
+
describe('Document Creation: Comparing Approaches', () => {
|
|
9
|
+
// Setup: Create test data once
|
|
10
|
+
const words100 = Array.from({ length: 100 }, (_, i) => createGLOSTWordNode({ value: `word${i}` }));
|
|
11
|
+
describe('Compare: Simple vs Full Hierarchy (100 words)', () => {
|
|
12
|
+
bench('createSimpleDocument (recommended)', () => {
|
|
13
|
+
createSimpleDocument(words100, "en", "latin");
|
|
14
|
+
});
|
|
15
|
+
bench('createDocumentFromSentences', () => {
|
|
16
|
+
const sentence = createSentenceFromWords(words100, "en", "latin", "text");
|
|
17
|
+
createDocumentFromSentences([sentence], "en", "latin");
|
|
18
|
+
});
|
|
19
|
+
bench('createDocumentFromParagraphs (full hierarchy)', () => {
|
|
20
|
+
const sentence = createSentenceFromWords(words100, "en", "latin", "text");
|
|
21
|
+
const paragraph = createParagraphFromSentences([sentence]);
|
|
22
|
+
createDocumentFromParagraphs([paragraph], "en", "latin");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('Compare: Word Node Creation Approaches', () => {
|
|
26
|
+
bench('minimal word node', () => {
|
|
27
|
+
createGLOSTWordNode({ value: "test" });
|
|
28
|
+
});
|
|
29
|
+
bench('word with transcription', () => {
|
|
30
|
+
createGLOSTWordNode({
|
|
31
|
+
value: "test",
|
|
32
|
+
transcription: {
|
|
33
|
+
ipa: { text: "test", syllables: ["test"] }
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
bench('word with full metadata', () => {
|
|
38
|
+
createGLOSTWordNode({
|
|
39
|
+
value: "test",
|
|
40
|
+
transcription: {
|
|
41
|
+
ipa: { text: "test", syllables: ["test"] }
|
|
42
|
+
},
|
|
43
|
+
metadata: {
|
|
44
|
+
partOfSpeech: "noun",
|
|
45
|
+
meaning: "a test",
|
|
46
|
+
usage: "testing"
|
|
47
|
+
},
|
|
48
|
+
lang: "en",
|
|
49
|
+
script: "latin",
|
|
50
|
+
extras: {
|
|
51
|
+
translations: { th: "ทดสอบ" },
|
|
52
|
+
metadata: { frequency: "common" }
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('Compare: Sentence Creation Strategies', () => {
|
|
58
|
+
const words10 = Array.from({ length: 10 }, (_, i) => createGLOSTWordNode({ value: `word${i}` }));
|
|
59
|
+
bench('createDocumentFromSentences - multiple small sentences', () => {
|
|
60
|
+
const sentences = Array.from({ length: 10 }, (_, i) => {
|
|
61
|
+
const sentenceWords = words10.slice(i, i + 5);
|
|
62
|
+
return createSentenceFromWords(sentenceWords, "en", "latin", `Sentence ${i}`);
|
|
63
|
+
});
|
|
64
|
+
createDocumentFromSentences(sentences, "en", "latin");
|
|
65
|
+
});
|
|
66
|
+
bench('createSimpleDocument - single sentence', () => {
|
|
67
|
+
createSimpleDocument(words10, "en", "latin");
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=document-creation.bench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-creation.bench.js","sourceRoot":"","sources":["document-creation.bench.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AAErB,QAAQ,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACvD,+BAA+B;IAC/B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACpD,mBAAmB,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAC3C,CAAC;IAEF,QAAQ,CAAC,+CAA+C,EAA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EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traversal.bench.d.ts","sourceRoot":"","sources":["traversal.bench.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document Traversal Performance Benchmarks
|
|
3
|
+
*
|
|
4
|
+
* Compares different approaches to traversing and accessing GLOST documents
|
|
5
|
+
*/
|
|
6
|
+
import { bench, describe } from 'vitest';
|
|
7
|
+
import { createSimpleDocument, createGLOSTWordNode, getAllWords, getFirstWord, getWordAtPath, } from '../index.js';
|
|
8
|
+
import { visit } from 'unist-util-visit';
|
|
9
|
+
import { NODE_TYPES } from '../types.js';
|
|
10
|
+
// Helper to create test documents
|
|
11
|
+
function createTestDocument(wordCount) {
|
|
12
|
+
const words = Array.from({ length: wordCount }, (_, i) => createGLOSTWordNode({
|
|
13
|
+
value: `word${i}`,
|
|
14
|
+
transcription: {
|
|
15
|
+
ipa: { text: `wɜːrd${i}`, syllables: [`word${i}`] }
|
|
16
|
+
},
|
|
17
|
+
metadata: { partOfSpeech: i % 2 === 0 ? "noun" : "verb" }
|
|
18
|
+
}));
|
|
19
|
+
return createSimpleDocument(words, "en", "latin");
|
|
20
|
+
}
|
|
21
|
+
describe('Traversal: Comparing Access Patterns', () => {
|
|
22
|
+
const doc1000 = createTestDocument(1000);
|
|
23
|
+
describe('Compare: Getting All Words', () => {
|
|
24
|
+
bench('getAllWords (helper)', () => {
|
|
25
|
+
getAllWords(doc1000);
|
|
26
|
+
});
|
|
27
|
+
bench('visit with type filter', () => {
|
|
28
|
+
const words = [];
|
|
29
|
+
visit(doc1000, NODE_TYPES.WORD, (node) => {
|
|
30
|
+
words.push(node);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
bench('manual recursive traversal', () => {
|
|
34
|
+
const words = [];
|
|
35
|
+
function traverse(node) {
|
|
36
|
+
if (node.type === NODE_TYPES.WORD) {
|
|
37
|
+
words.push(node);
|
|
38
|
+
}
|
|
39
|
+
if (node.children) {
|
|
40
|
+
node.children.forEach(traverse);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
traverse(doc1000);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe('Compare: Finding First Word', () => {
|
|
47
|
+
bench('getFirstWord (optimized with SKIP)', () => {
|
|
48
|
+
getFirstWord(doc1000);
|
|
49
|
+
});
|
|
50
|
+
bench('getAllWords then [0]', () => {
|
|
51
|
+
getAllWords(doc1000)[0];
|
|
52
|
+
});
|
|
53
|
+
bench('manual early-exit traversal', () => {
|
|
54
|
+
let found;
|
|
55
|
+
function traverse(node) {
|
|
56
|
+
if (node.type === NODE_TYPES.WORD) {
|
|
57
|
+
found = node;
|
|
58
|
+
return true; // exit early
|
|
59
|
+
}
|
|
60
|
+
if (node.children) {
|
|
61
|
+
for (const child of node.children) {
|
|
62
|
+
if (traverse(child))
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
traverse(doc1000);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe('Compare: Direct Path Access', () => {
|
|
72
|
+
bench('getWordAtPath (direct indexing)', () => {
|
|
73
|
+
getWordAtPath(doc1000, { paragraph: 0, sentence: 0, word: 500 });
|
|
74
|
+
});
|
|
75
|
+
bench('getAllWords then filter by index', () => {
|
|
76
|
+
getAllWords(doc1000)[500];
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe('Traversal: Comparing Filter Strategies', () => {
|
|
81
|
+
const doc500 = createTestDocument(500);
|
|
82
|
+
describe('Compare: Filter by Part of Speech', () => {
|
|
83
|
+
bench('getAllWords + array filter', () => {
|
|
84
|
+
const words = getAllWords(doc500);
|
|
85
|
+
words.filter(w => w.metadata?.partOfSpeech === "noun");
|
|
86
|
+
});
|
|
87
|
+
bench('visit with conditional push', () => {
|
|
88
|
+
const nouns = [];
|
|
89
|
+
visit(doc500, NODE_TYPES.WORD, (node) => {
|
|
90
|
+
if (node.metadata?.partOfSpeech === "noun") {
|
|
91
|
+
nouns.push(node);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
describe('Compare: Extract Word Text', () => {
|
|
97
|
+
const words = getAllWords(doc500);
|
|
98
|
+
bench('map with type guard', () => {
|
|
99
|
+
words.map(w => {
|
|
100
|
+
const textNode = w.children[0];
|
|
101
|
+
return textNode && 'value' in textNode ? textNode.value : '';
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
bench('reduce to array', () => {
|
|
105
|
+
words.reduce((acc, w) => {
|
|
106
|
+
const textNode = w.children[0];
|
|
107
|
+
if (textNode && 'value' in textNode) {
|
|
108
|
+
acc.push(textNode.value);
|
|
109
|
+
}
|
|
110
|
+
return acc;
|
|
111
|
+
}, []);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
describe('Compare: Count with Condition', () => {
|
|
115
|
+
const words = getAllWords(doc500);
|
|
116
|
+
bench('filter then length', () => {
|
|
117
|
+
words.filter(w => w.transcription !== undefined).length;
|
|
118
|
+
});
|
|
119
|
+
bench('reduce with counter', () => {
|
|
120
|
+
words.reduce((count, w) => count + (w.transcription ? 1 : 0), 0);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
//# sourceMappingURL=traversal.bench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traversal.bench.js","sourceRoot":"","sources":["traversal.bench.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACn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AE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const thaiWords: any[];
|
|
2
|
+
declare const thaiSentence: any;
|
|
3
|
+
declare const japaneseWords: any[];
|
|
4
|
+
declare const japaneseSentence: any;
|
|
5
|
+
declare const thaiParagraph: any;
|
|
6
|
+
declare const japaneseParagraph: any;
|
|
7
|
+
declare const document: any;
|
|
8
|
+
export declare function demonstrateUtilities(): void;
|
|
9
|
+
export { thaiWords, japaneseWords, thaiSentence, japaneseSentence, thaiParagraph, japaneseParagraph, document };
|
|
10
|
+
//# sourceMappingURL=example.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["example.ts"],"names":[],"mappings":"AAiBA,QAAA,MAAM,SAAS,OAoCd,CAAC;AAEF,QAAA,MAAM,YAAY,KAKjB,CAAC;AAMF,QAAA,MAAM,aAAa,OAkClB,CAAC;AAEF,QAAA,MAAM,gBAAgB,KAKrB,CAAC;AAMF,QAAA,MAAM,aAAa,KAA+C,CAAC;AACnE,QAAA,MAAM,iBAAiB,KAAmD,CAAC;AAE3E,QAAA,MAAM,QAAQ,KAQb,CAAC;AAMF,wBAAgB,oBAAoB,SA4CnC;AAGD,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACT,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Example usage of the GLOST package
|
|
2
|
+
import { createSentenceFromWords, createParagraphFromSentences, createDocumentFromParagraphs, getAllWords, getWordTranscription, validateGLOSTTree, getWordText } from '../index';
|
|
3
|
+
import { createThaiWord } from 'glost-th';
|
|
4
|
+
import { createJapaneseWord } from 'glost-ja';
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// Thai Example: "สวัสดีครับ ผมชื่อสมชาย" (Hello, my name is Somchai)
|
|
7
|
+
// ============================================================================
|
|
8
|
+
const thaiWords = [
|
|
9
|
+
createThaiWord({
|
|
10
|
+
text: 'สวัสดี',
|
|
11
|
+
rtgs: 'sà-wàt-dii',
|
|
12
|
+
partOfSpeech: 'interjection',
|
|
13
|
+
tone: 2,
|
|
14
|
+
syllables: ['sa', 'wat', 'dii']
|
|
15
|
+
}),
|
|
16
|
+
createThaiWord({
|
|
17
|
+
text: 'ครับ',
|
|
18
|
+
rtgs: 'khráp',
|
|
19
|
+
partOfSpeech: 'particle',
|
|
20
|
+
tone: 2,
|
|
21
|
+
syllables: ['khrap']
|
|
22
|
+
}),
|
|
23
|
+
createThaiWord({
|
|
24
|
+
text: 'ผม',
|
|
25
|
+
rtgs: 'phǒm',
|
|
26
|
+
partOfSpeech: 'pronoun',
|
|
27
|
+
tone: 3,
|
|
28
|
+
syllables: ['phom']
|
|
29
|
+
}),
|
|
30
|
+
createThaiWord({
|
|
31
|
+
text: 'ชื่อ',
|
|
32
|
+
rtgs: 'chûue',
|
|
33
|
+
partOfSpeech: 'noun',
|
|
34
|
+
tone: 3,
|
|
35
|
+
syllables: ['chue']
|
|
36
|
+
}),
|
|
37
|
+
createThaiWord({
|
|
38
|
+
text: 'สมชาย',
|
|
39
|
+
rtgs: 'sǒm-chaai',
|
|
40
|
+
partOfSpeech: 'proper noun',
|
|
41
|
+
tone: 3,
|
|
42
|
+
syllables: ['som', 'chaai']
|
|
43
|
+
})
|
|
44
|
+
];
|
|
45
|
+
const thaiSentence = createSentenceFromWords(thaiWords, 'th', 'thai', 'สวัสดีครับ ผมชื่อสมชาย');
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// Japanese Example: "私の名前は田中です。" (My name is Tanaka)
|
|
48
|
+
// ============================================================================
|
|
49
|
+
const japaneseWords = [
|
|
50
|
+
createJapaneseWord({
|
|
51
|
+
text: '私',
|
|
52
|
+
romaji: 'watashi',
|
|
53
|
+
partOfSpeech: 'pronoun',
|
|
54
|
+
furigana: 'わたし'
|
|
55
|
+
}),
|
|
56
|
+
createJapaneseWord({
|
|
57
|
+
text: 'の',
|
|
58
|
+
romaji: 'no',
|
|
59
|
+
partOfSpeech: 'particle'
|
|
60
|
+
}),
|
|
61
|
+
createJapaneseWord({
|
|
62
|
+
text: '名前',
|
|
63
|
+
romaji: 'namae',
|
|
64
|
+
partOfSpeech: 'noun',
|
|
65
|
+
furigana: 'なまえ'
|
|
66
|
+
}),
|
|
67
|
+
createJapaneseWord({
|
|
68
|
+
text: 'は',
|
|
69
|
+
romaji: 'wa',
|
|
70
|
+
partOfSpeech: 'particle'
|
|
71
|
+
}),
|
|
72
|
+
createJapaneseWord({
|
|
73
|
+
text: '田中',
|
|
74
|
+
romaji: 'tanaka',
|
|
75
|
+
partOfSpeech: 'proper noun',
|
|
76
|
+
furigana: 'たなか'
|
|
77
|
+
}),
|
|
78
|
+
createJapaneseWord({
|
|
79
|
+
text: 'です',
|
|
80
|
+
romaji: 'desu',
|
|
81
|
+
partOfSpeech: 'copula'
|
|
82
|
+
})
|
|
83
|
+
];
|
|
84
|
+
const japaneseSentence = createSentenceFromWords(japaneseWords, 'ja', 'mixed', '私の名前は田中です。');
|
|
85
|
+
// ============================================================================
|
|
86
|
+
// Create Document Structure
|
|
87
|
+
// ============================================================================
|
|
88
|
+
const thaiParagraph = createParagraphFromSentences([thaiSentence]);
|
|
89
|
+
const japaneseParagraph = createParagraphFromSentences([japaneseSentence]);
|
|
90
|
+
const document = createDocumentFromParagraphs([thaiParagraph, japaneseParagraph], 'mixed', 'mixed', {
|
|
91
|
+
title: 'Multilingual Greeting Examples',
|
|
92
|
+
description: 'Examples of greetings in Thai and Japanese with transcriptions'
|
|
93
|
+
});
|
|
94
|
+
// ============================================================================
|
|
95
|
+
// Demonstrate Utilities
|
|
96
|
+
// ============================================================================
|
|
97
|
+
export function demonstrateUtilities() {
|
|
98
|
+
console.log('=== GLOST Package Demo ===\n');
|
|
99
|
+
// Get all words from the document
|
|
100
|
+
const allWords = getAllWords(document);
|
|
101
|
+
console.log(`Total words: ${allWords.length}`);
|
|
102
|
+
// Show Thai words with RTGS transcriptions
|
|
103
|
+
const thaiWordsOnly = allWords.filter(word => word.lang === 'th');
|
|
104
|
+
console.log('\n=== Thai Words ===');
|
|
105
|
+
thaiWordsOnly.forEach(word => {
|
|
106
|
+
const rtgs = getWordTranscription(word, 'rtgs');
|
|
107
|
+
console.log(`${getWordText(word)} → ${rtgs} (${word.metadata.partOfSpeech})`);
|
|
108
|
+
});
|
|
109
|
+
// Show Japanese words with romaji
|
|
110
|
+
const japaneseWordsOnly = allWords.filter(word => word.lang === 'ja');
|
|
111
|
+
console.log('\n=== Japanese Words ===');
|
|
112
|
+
japaneseWordsOnly.forEach(word => {
|
|
113
|
+
const romaji = getWordTranscription(word, 'romaji');
|
|
114
|
+
console.log(`${getWordText(word)} → ${romaji} (${word.metadata.partOfSpeech})`);
|
|
115
|
+
});
|
|
116
|
+
// Validate the tree
|
|
117
|
+
const validationErrors = validateGLOSTTree(document);
|
|
118
|
+
if (validationErrors.length === 0) {
|
|
119
|
+
console.log('\n✅ Document is valid!');
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
console.log('\n❌ Validation errors:');
|
|
123
|
+
validationErrors.forEach((error) => console.log(` - ${error}`));
|
|
124
|
+
}
|
|
125
|
+
// Show document structure
|
|
126
|
+
console.log('\n=== Document Structure ===');
|
|
127
|
+
console.log(`Language: ${document.lang}`);
|
|
128
|
+
console.log(`Script: ${document.script}`);
|
|
129
|
+
console.log(`Paragraphs: ${document.children.length}`);
|
|
130
|
+
console.log(`Sentences: ${document.children.reduce((acc, p) => {
|
|
131
|
+
if (p.type === 'ParagraphNode') {
|
|
132
|
+
return acc + (p.children?.length || 0);
|
|
133
|
+
}
|
|
134
|
+
return acc;
|
|
135
|
+
}, 0)}`);
|
|
136
|
+
console.log(`Words: ${allWords.length}`);
|
|
137
|
+
}
|
|
138
|
+
// Export for use in other files
|
|
139
|
+
export { thaiWords, japaneseWords, thaiSentence, japaneseSentence, thaiParagraph, japaneseParagraph, document };
|
|
140
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","sourceRoot":"","sources":["example.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,+EAA+E;AAC/E,qEAAqE;AACrE,+EAA+E;AAE/E,MAAM,SAAS,GAAG;IAChB,cAAc,CAAC;QACb,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,YAAY;QAClB,YAAY,EAAE,cAAc;QAC5B,IAAI,EAAE,CAAC;QACP,SAAS,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC;KAChC,CAAC;IACF,cAAc,CAAC;QACb,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,OAAO;QACb,YAAY,EAAE,UAAU;QACxB,IAAI,EAAE,CAAC;QACP,SAAS,EAAE,CAAC,OAAO,CAAC;KACrB,CAAC;IACF,cAAc,CAAC;QACb,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,MAAM;QACZ,YAAY,EAAE,SAAS;QACvB,IAAI,EAAE,CAAC;QACP,SAAS,EAAE,CAAC,MAAM,CAAC;KACpB,CAAC;IACF,cAAc,CAAC;QACb,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,OAAO;QACb,YAAY,EAAE,MAAM;QACpB,IAAI,EAAE,CAAC;QACP,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G,CAAC;IACb,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACT,OAAO,CAAC,GAAG,CAAC,UAAU,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,gCAAgC;AAChC,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACT,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { GLOSTWord } from '../types.js';
|
|
2
|
+
declare const thaiWordsWithExtras: GLOSTWord[];
|
|
3
|
+
declare const japaneseWordsWithExtras: GLOSTWord[];
|
|
4
|
+
declare const thaiSentenceWithExtras: import("glost-core").GLOSTSentence;
|
|
5
|
+
declare const japaneseSentenceWithExtras: import("glost-core").GLOSTSentence;
|
|
6
|
+
declare const thaiParagraphWithExtras: import("glost-core").GLOSTParagraph;
|
|
7
|
+
declare const japaneseParagraphWithExtras: import("glost-core").GLOSTParagraph;
|
|
8
|
+
export declare const thaiDocumentWithExtras: import("glost-core").GLOSTRoot;
|
|
9
|
+
export declare const japaneseDocumentWithExtras: import("glost-core").GLOSTRoot;
|
|
10
|
+
/**
|
|
11
|
+
* Get quick translation for a word in a specific language
|
|
12
|
+
*/
|
|
13
|
+
export declare function getQuickTranslation(word: GLOSTWord, targetLang: string): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Get all available translations for a word
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAllTranslations(word: GLOSTWord): Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Get difficulty level for a word
|
|
20
|
+
*/
|
|
21
|
+
export declare function getDifficulty(word: GLOSTWord): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Get cultural notes for a word
|
|
24
|
+
*/
|
|
25
|
+
export declare function getCulturalNotes(word: GLOSTWord): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Get related words for a word
|
|
28
|
+
*/
|
|
29
|
+
export declare function getRelatedWords(word: GLOSTWord): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Get example sentences for a word
|
|
32
|
+
*/
|
|
33
|
+
export declare function getExamples(word: GLOSTWord): string[];
|
|
34
|
+
export { thaiWordsWithExtras, japaneseWordsWithExtras, thaiSentenceWithExtras, japaneseSentenceWithExtras, thaiParagraphWithExtras, japaneseParagraphWithExtras };
|
|
35
|
+
//# sourceMappingURL=mock-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-data.d.ts","sourceRoot":"","sources":["mock-data.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,SAAS,EAAC,MAAM,aAAa,CAAC;AAMhC,QAAA,MAAM,mBAAmB,EAAE,SAAS,EAiPnC,CAAC;AAMF,QAAA,MAAM,uBAAuB,EAAE,SAAS,EA6PvC,CAAC;AAMF,QAAA,MAAM,sBAAsB,oCAK1B,CAAC;AAEH,QAAA,MAAM,0BAA0B,oCAK9B,CAAC;AAEH,QAAA,MAAM,uBAAuB,qCAAqD,CAAC;AACnF,QAAA,MAAM,2BAA2B,qCAAyD,CAAC;AAE3F,eAAO,MAAM,sBAAsB,gCAQjC,CAAC;AAEH,eAAO,MAAM,0BAA0B,gCAQrC,CAAC;AAMH;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE3F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAW1E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAEjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAEpE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SA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