glost 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 +62 -0
- package/dist/example.d.ts +10 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +82 -0
- package/dist/example.js.map +1 -0
- package/dist/guards.d.ts +103 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +264 -0
- package/dist/guards.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/mock-data.d.ts +35 -0
- package/dist/mock-data.d.ts.map +1 -0
- package/dist/mock-data.js +494 -0
- package/dist/mock-data.js.map +1 -0
- package/dist/nodes.d.ts +68 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/nodes.js +181 -0
- package/dist/nodes.js.map +1 -0
- package/dist/types.d.ts +379 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +203 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +497 -0
- package/dist/utils.js.map +1 -0
- package/dist/validators.d.ts +1876 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +302 -0
- package/dist/validators.js.map +1 -0
- package/package.json +67 -0
- package/src/example.ts +186 -0
- package/src/guards.ts +341 -0
- package/src/index.ts +69 -0
- package/src/mock-data.ts +635 -0
- package/src/nodes.ts +301 -0
- package/src/types.ts +565 -0
- package/src/utils.ts +653 -0
- package/src/validators.ts +336 -0
- package/tsconfig.json +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +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.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @glost/core
|
|
2
|
+
|
|
3
|
+
Core types and node creation for GLOST (Glossed Syntax Tree).
|
|
4
|
+
|
|
5
|
+
## What is GLOST?
|
|
6
|
+
|
|
7
|
+
GLOST (Glossed Syntax Tree) is a Concrete Syntax Tree format that extends nlcst to support rich language learning annotations:
|
|
8
|
+
|
|
9
|
+
- **Translations and glosses** in multiple languages
|
|
10
|
+
- **Difficulty levels** and word frequency data
|
|
11
|
+
- **Pronunciation guides** (IPA, romanization, transcription systems)
|
|
12
|
+
- **Cultural context** and usage notes
|
|
13
|
+
- **Part-of-speech** tagging
|
|
14
|
+
- **Grammar metadata** for language learners
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add @glost/core
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { createGLOSTWordNode, createGLOSTRootNode } from "@glost/core";
|
|
26
|
+
import type { GLOSTWord, GLOSTRoot } from "@glost/core";
|
|
27
|
+
|
|
28
|
+
// Create a word node with annotations
|
|
29
|
+
// Language codes: ISO-639-1, ISO-639-3, or BCP-47 all work
|
|
30
|
+
const word = createGLOSTWordNode(
|
|
31
|
+
"สวัสดี", // Thai: hello
|
|
32
|
+
{
|
|
33
|
+
rtgs: { text: "sà-wàt-dii", system: "rtgs" },
|
|
34
|
+
ipa: { text: "sa.wàt.diː", system: "ipa" }
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
partOfSpeech: "interjection",
|
|
38
|
+
usage: "greeting"
|
|
39
|
+
},
|
|
40
|
+
"word",
|
|
41
|
+
"th", // Can also use "tha" (ISO-639-3) or "th-TH" (BCP-47)
|
|
42
|
+
"thai"
|
|
43
|
+
);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
- Full TypeScript support
|
|
49
|
+
- Extends nlcst (Natural Language Concrete Syntax Tree)
|
|
50
|
+
- Compatible with unist ecosystem
|
|
51
|
+
- Framework-agnostic
|
|
52
|
+
- Zod validation schemas included
|
|
53
|
+
|
|
54
|
+
## Related Packages
|
|
55
|
+
|
|
56
|
+
- `@glost/extensions` - Extension system for transforming GLOST trees
|
|
57
|
+
- `@glost/utils` - Utilities for working with GLOST documents
|
|
58
|
+
- `@glost/common` - Shared utilities and language configs
|
|
59
|
+
|
|
60
|
+
## Documentation
|
|
61
|
+
|
|
62
|
+
See the main GLOST repository for full documentation.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const thaiWords: import("./types").GLOSTWord[];
|
|
2
|
+
declare const thaiSentence: import("./types").GLOSTSentence;
|
|
3
|
+
declare const japaneseWords: import("./types").GLOSTWord[];
|
|
4
|
+
declare const japaneseSentence: import("./types").GLOSTSentence;
|
|
5
|
+
declare const thaiParagraph: import("./types").GLOSTParagraph;
|
|
6
|
+
declare const japaneseParagraph: import("./types").GLOSTParagraph;
|
|
7
|
+
declare const document: import("./types").GLOSTRoot;
|
|
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":["../src/example.ts"],"names":[],"mappings":"AAiBA,QAAA,MAAM,SAAS,+BAoCd,CAAC;AAEF,QAAA,MAAM,YAAY,iCAKjB,CAAC;AAMF,QAAA,MAAM,aAAa,+BAkClB,CAAC;AAEF,QAAA,MAAM,gBAAgB,iCAKrB,CAAC;AAMF,QAAA,MAAM,aAAa,kCAA+C,CAAC;AACnE,QAAA,MAAM,iBAAiB,kCAAmD,CAAC;AAE3E,QAAA,MAAM,QAAQ,6BAQb,CAAC;AAMF,wBAAgB,oBAAoB,SA4CnC;AAGD,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACT,CAAC"}
|
package/dist/example.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Example usage of the GLOST package
|
|
2
|
+
import { createThaiWord, createJapaneseWord, createSentenceFromWords, createParagraphFromSentences, createDocumentFromParagraphs, getAllWords, getWordTranscription, validateGLOSTTree, getWordText } from './index';
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// Thai Example: "สวัสดีครับ ผมชื่อสมชาย" (Hello, my name is Somchai)
|
|
5
|
+
// ============================================================================
|
|
6
|
+
const thaiWords = [
|
|
7
|
+
createThaiWord('สวัสดี', 'sà-wàt-dii', 'interjection', 2, // tone
|
|
8
|
+
['sa', 'wat', 'dii']),
|
|
9
|
+
createThaiWord('ครับ', 'khráp', 'particle', 2, ['khrap']),
|
|
10
|
+
createThaiWord('ผม', 'phǒm', 'pronoun', 3, ['phom']),
|
|
11
|
+
createThaiWord('ชื่อ', 'chûue', 'noun', 3, ['chue']),
|
|
12
|
+
createThaiWord('สมชาย', 'sǒm-chaai', 'proper noun', 3, ['som', 'chaai'])
|
|
13
|
+
];
|
|
14
|
+
const thaiSentence = createSentenceFromWords(thaiWords, 'th', 'thai', 'สวัสดีครับ ผมชื่อสมชาย');
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Japanese Example: "私の名前は田中です。" (My name is Tanaka)
|
|
17
|
+
// ============================================================================
|
|
18
|
+
const japaneseWords = [
|
|
19
|
+
createJapaneseWord('私', 'watashi', 'pronoun', 'わたし'),
|
|
20
|
+
createJapaneseWord('の', 'no', 'particle'),
|
|
21
|
+
createJapaneseWord('名前', 'namae', 'noun', 'なまえ'),
|
|
22
|
+
createJapaneseWord('は', 'wa', 'particle'),
|
|
23
|
+
createJapaneseWord('田中', 'tanaka', 'proper noun', 'たなか'),
|
|
24
|
+
createJapaneseWord('です', 'desu', 'copula')
|
|
25
|
+
];
|
|
26
|
+
const japaneseSentence = createSentenceFromWords(japaneseWords, 'ja', 'mixed', '私の名前は田中です。');
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// Create Document Structure
|
|
29
|
+
// ============================================================================
|
|
30
|
+
const thaiParagraph = createParagraphFromSentences([thaiSentence]);
|
|
31
|
+
const japaneseParagraph = createParagraphFromSentences([japaneseSentence]);
|
|
32
|
+
const document = createDocumentFromParagraphs([thaiParagraph, japaneseParagraph], 'mixed', 'mixed', {
|
|
33
|
+
title: 'Multilingual Greeting Examples',
|
|
34
|
+
description: 'Examples of greetings in Thai and Japanese with transcriptions'
|
|
35
|
+
});
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Demonstrate Utilities
|
|
38
|
+
// ============================================================================
|
|
39
|
+
export function demonstrateUtilities() {
|
|
40
|
+
console.log('=== GLOST Package Demo ===\n');
|
|
41
|
+
// Get all words from the document
|
|
42
|
+
const allWords = getAllWords(document);
|
|
43
|
+
console.log(`Total words: ${allWords.length}`);
|
|
44
|
+
// Show Thai words with RTGS transcriptions
|
|
45
|
+
const thaiWordsOnly = allWords.filter(word => word.lang === 'th');
|
|
46
|
+
console.log('\n=== Thai Words ===');
|
|
47
|
+
thaiWordsOnly.forEach(word => {
|
|
48
|
+
const rtgs = getWordTranscription(word, 'rtgs');
|
|
49
|
+
console.log(`${getWordText(word)} → ${rtgs} (${word.metadata.partOfSpeech})`);
|
|
50
|
+
});
|
|
51
|
+
// Show Japanese words with romaji
|
|
52
|
+
const japaneseWordsOnly = allWords.filter(word => word.lang === 'ja');
|
|
53
|
+
console.log('\n=== Japanese Words ===');
|
|
54
|
+
japaneseWordsOnly.forEach(word => {
|
|
55
|
+
const romaji = getWordTranscription(word, 'romaji');
|
|
56
|
+
console.log(`${getWordText(word)} → ${romaji} (${word.metadata.partOfSpeech})`);
|
|
57
|
+
});
|
|
58
|
+
// Validate the tree
|
|
59
|
+
const validationErrors = validateGLOSTTree(document);
|
|
60
|
+
if (validationErrors.length === 0) {
|
|
61
|
+
console.log('\n✅ Document is valid!');
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
console.log('\n❌ Validation errors:');
|
|
65
|
+
validationErrors.forEach((error) => console.log(` - ${error}`));
|
|
66
|
+
}
|
|
67
|
+
// Show document structure
|
|
68
|
+
console.log('\n=== Document Structure ===');
|
|
69
|
+
console.log(`Language: ${document.lang}`);
|
|
70
|
+
console.log(`Script: ${document.script}`);
|
|
71
|
+
console.log(`Paragraphs: ${document.children.length}`);
|
|
72
|
+
console.log(`Sentences: ${document.children.reduce((acc, p) => {
|
|
73
|
+
if (p.type === 'ParagraphNode') {
|
|
74
|
+
return acc + (p.children?.length || 0);
|
|
75
|
+
}
|
|
76
|
+
return acc;
|
|
77
|
+
}, 0)}`);
|
|
78
|
+
console.log(`Words: ${allWords.length}`);
|
|
79
|
+
}
|
|
80
|
+
// Export for use in other files
|
|
81
|
+
export { thaiWords, japaneseWords, thaiSentence, japaneseSentence, thaiParagraph, japaneseParagraph, document };
|
|
82
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,+EAA+E;AAC/E,qEAAqE;AACrE,+EAA+E;AAE/E,MAAM,SAAS,GAAG;IAChB,cAAc,CACZ,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,CAAC,EAAE,OAAO;IACV,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CACrB;IACD,cAAc,CACZ,MAAM,EACN,OAAO,EACP,UAAU,EACV,CAAC,EACD,CAAC,OAAO,CAAC,CACV;IACD,cAAc,CACZ,IAAI,EACJ,MAAM,EACN,SAAS,EACT,CAAC,EACD,CAAC,MAAM,CAAC,CACT;IACD,cAAc,CACZ,MAAM,EACN,OAAO,EACP,MAAM,EACN,CAAC,EACD,CAAC,MAAM,CAAC,CACT;IACD,cAAc,CACZ,OAAO,EACP,WAAW,EACX,aAAa,EACb,CAAC,EACD,CAAC,KAAK,EAAE,OAAO,CAAC,CACjB;CACF,CAAC;AAEF,MAAM,YAAY,GAAG,uBAAuB,CAC1C,SAAS,EACT,IAAI,EACJ,MAAM,EACN,wBAAwB,CACzB,CAAC;AAEF,+EAA+E;AAC/E,qDAAqD;AACrD,+EAA+E;AAE/E,MAAM,aAAa,GAAG;IACpB,kBAAkB,CAChB,GAAG,EACH,SAAS,EACT,SAAS,EACT,KAAK,CACN;IACD,kBAAkB,CAChB,GAAG,EACH,IAAI,EACJ,UAAU,CACX;I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,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,eAAe,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,CAAC,cAAc,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QAC5D,IAAI,CAAC,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YAC/B,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,GAAG,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"}
|
package/dist/guards.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { GLOSTParagraph, GLOSTPunctuation, GLOSTRoot, GLOSTSentence, GLOSTSource, GLOSTSymbol, GLOSTText, GLOSTWhiteSpace, GLOSTWord, GLOSTNode } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a node is an GLOSTWord
|
|
4
|
+
*/
|
|
5
|
+
export declare function isGLOSTWord(node: unknown): node is GLOSTWord;
|
|
6
|
+
/**
|
|
7
|
+
* Type guard to check if a node is an GLOSTSentence
|
|
8
|
+
*/
|
|
9
|
+
export declare function isGLOSTSentence(node: unknown): node is GLOSTSentence;
|
|
10
|
+
/**
|
|
11
|
+
* Type guard to check if a node is an GLOSTParagraph
|
|
12
|
+
*/
|
|
13
|
+
export declare function isGLOSTParagraph(node: unknown): node is GLOSTParagraph;
|
|
14
|
+
/**
|
|
15
|
+
* Type guard to check if a node is an GLOSTRoot
|
|
16
|
+
*/
|
|
17
|
+
export declare function isGLOSTRoot(node: unknown): node is GLOSTRoot;
|
|
18
|
+
/**
|
|
19
|
+
* Type guard to check if a node is an GLOSTText
|
|
20
|
+
*/
|
|
21
|
+
export declare function isGLOSTText(node: unknown): node is GLOSTText;
|
|
22
|
+
/**
|
|
23
|
+
* Type guard to check if a node is an GLOSTPunctuation
|
|
24
|
+
*/
|
|
25
|
+
export declare function isGLOSTPunctuation(node: unknown): node is GLOSTPunctuation;
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a node is an GLOSTSymbol
|
|
28
|
+
*/
|
|
29
|
+
export declare function isGLOSTSymbol(node: unknown): node is GLOSTSymbol;
|
|
30
|
+
/**
|
|
31
|
+
* Type guard to check if a node is an GLOSTWhiteSpace
|
|
32
|
+
*/
|
|
33
|
+
export declare function isGLOSTWhiteSpace(node: unknown): node is GLOSTWhiteSpace;
|
|
34
|
+
/**
|
|
35
|
+
* Type guard to check if a node is an GLOSTSource
|
|
36
|
+
*/
|
|
37
|
+
export declare function isGLOSTSource(node: unknown): node is GLOSTSource;
|
|
38
|
+
/**
|
|
39
|
+
* Type guard to check if a node is GLOSTNode (any GLOST node)
|
|
40
|
+
*/
|
|
41
|
+
export declare function isGLOSTNode(node: unknown): node is GLOSTNode;
|
|
42
|
+
/**
|
|
43
|
+
* Type guard to check if a node is an GLOSTDocument (Root or Content)
|
|
44
|
+
*/
|
|
45
|
+
export declare function isGLOSTDocument(node: unknown): node is GLOSTRoot;
|
|
46
|
+
/**
|
|
47
|
+
* Type guard to check if an array contains only GLOSTWord nodes
|
|
48
|
+
*/
|
|
49
|
+
export declare function isGLOSTWordArray(nodes: unknown[]): nodes is GLOSTWord[];
|
|
50
|
+
/**
|
|
51
|
+
* Type guard to check if an array contains only GLOSTSentence nodes
|
|
52
|
+
*/
|
|
53
|
+
export declare function isGLOSTSentenceArray(nodes: unknown[]): nodes is GLOSTSentence[];
|
|
54
|
+
/**
|
|
55
|
+
* Type guard to check if an array contains only GLOSTParagraph nodes
|
|
56
|
+
*/
|
|
57
|
+
export declare function isGLOSTParagraphArray(nodes: unknown[]): nodes is GLOSTParagraph[];
|
|
58
|
+
/**
|
|
59
|
+
* Type guard to check if an array contains only GLOSTContent nodes
|
|
60
|
+
*/
|
|
61
|
+
export declare function isGLOSTContentArray(nodes: unknown[]): nodes is (GLOSTWord | GLOSTSentence | GLOSTParagraph | GLOSTText | GLOSTPunctuation | GLOSTSymbol | GLOSTWhiteSpace | GLOSTSource)[];
|
|
62
|
+
/**
|
|
63
|
+
* Type guard to check if a node has children
|
|
64
|
+
*/
|
|
65
|
+
export declare function hasChildren(node: unknown): node is {
|
|
66
|
+
children: unknown[];
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Type guard to check if a node has metadata
|
|
70
|
+
*/
|
|
71
|
+
export declare function hasMetadata(node: unknown): node is {
|
|
72
|
+
metadata: Record<string, unknown>;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Type guard to check if a node has transcription
|
|
76
|
+
*/
|
|
77
|
+
export declare function hasTranscription(node: unknown): node is {
|
|
78
|
+
transcription: Record<string, unknown>;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Type guard to check if a node has extras
|
|
82
|
+
*/
|
|
83
|
+
export declare function hasExtras(node: unknown): node is {
|
|
84
|
+
extras: Record<string, unknown>;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Check if a node has valid GLOST structure (type guard based validation)
|
|
88
|
+
* For schema-based validation, use validateGLOSTNode from validators.ts
|
|
89
|
+
*/
|
|
90
|
+
export declare function isGLOSTNodeWithValidChildren(node: unknown): node is GLOSTNode;
|
|
91
|
+
/**
|
|
92
|
+
* Check if an array contains valid GLOST nodes (type guard based)
|
|
93
|
+
*/
|
|
94
|
+
export declare function isGLOSTNodeArrayValid(nodes: unknown[]): nodes is GLOSTNode[];
|
|
95
|
+
/**
|
|
96
|
+
* Check if a node is a leaf node (no children)
|
|
97
|
+
*/
|
|
98
|
+
export declare function isLeafNode(node: GLOSTNode): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Check if a node is a container node (has children)
|
|
101
|
+
*/
|
|
102
|
+
export declare function isContainerNode(node: GLOSTNode): boolean;
|
|
103
|
+
//# sourceMappingURL=guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,EACf,SAAS,EACT,SAAS,EACV,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,SAAS,CAc5D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,aAAa,CAYpE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,cAAc,CAYtE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,SAAS,CAY5D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,SAAS,CAS5D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,gBAAgB,CAS1E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,WAAW,CAShE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,eAAe,CASxE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI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AAE,OAAO,CAAC,CAAA;CAAE,CAQpF;AAMD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,SAAS,CAW7E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,SAAS,EAAE,CAE5E;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAQnD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAOxD"}
|
package/dist/guards.js
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,MAAM,IAAI,IAAI;QACd,IAAI,CAAC,IAAI,KAAK,UAAU;QACxB,UAAU,IAAI,IAAI;QAClB,MAAM,IAAI,IAAI;QACd,QAAQ,IAAI,IAAI;QAChB,OAAO,IAAI,IAAI;QACf,UAAU,IAAI,IAAI;QAClB,eAAe,IAAI,IAAI;QACvB,QAA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,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/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./nodes";
|
|
3
|
+
export * from "./utils";
|
|
4
|
+
export * from "./validators";
|
|
5
|
+
export * from "./guards";
|
|
6
|
+
export * from "./mock-data";
|
|
7
|
+
export type { ParagraphLike } from "./utils";
|
|
8
|
+
export { getAllWords, getAllSentences, getAllParagraphs, getAllClauses, getAllPhrases, getAllSyllables, getAllCharacters, getWordsFromDocument, getFirstSentence, getWordsFromSentence, getWordsFromParagraph, findNodesByType, findWordsByLanguage, findWordsByTranscriptionSystem, isGLOSTWord, isGLOSTSentence, isGLOSTParagraph, isGLOSTRoot, isGLOSTClause, isGLOSTPhrase, isGLOSTSyllable, isGLOSTCharacter, getWordText, getWordTranscription, hasWordTranscription, getWordTranslation, getWordMeaning, getWordPartOfSpeech, getWordDifficulty, getSentenceTranslation, getGLOSTWordCount, adaptParagraphLikeToGLOST, parseLanguageTag, getBaseLanguage, areLanguagesCompatible, findBestLanguageMatch, getLanguageFallback, normalizeLanguageTag, isValidLanguageTag, } from "./utils";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AAEzB,cAAc,aAAa,CAAC;AAG5B,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C,OAAO,EAEL,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EAGrB,eAAe,EACf,mBAAmB,EACnB,8BAA8B,EAG9B,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB,EAGhB,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EAGjB,sBAAsB,EAGtB,iBAAiB,EACjB,yBAAyB,EAGzB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// GLOST - Glossed Syntax Tree
|
|
2
|
+
// Extends nlcst for language learning with annotations
|
|
3
|
+
export * from "./types";
|
|
4
|
+
export * from "./nodes";
|
|
5
|
+
export * from "./utils";
|
|
6
|
+
export * from "./validators";
|
|
7
|
+
export * from "./guards";
|
|
8
|
+
// export * from './example';
|
|
9
|
+
export * from "./mock-data";
|
|
10
|
+
// Re-export key utilities for transcription components
|
|
11
|
+
export {
|
|
12
|
+
// Tree traversal
|
|
13
|
+
getAllWords, getAllSentences, getAllParagraphs, getAllClauses, getAllPhrases, getAllSyllables, getAllCharacters, getWordsFromDocument, getFirstSentence, getWordsFromSentence, getWordsFromParagraph,
|
|
14
|
+
// Node finding
|
|
15
|
+
findNodesByType, findWordsByLanguage, findWordsByTranscriptionSystem,
|
|
16
|
+
// Type guards (most are now exported via guards.ts)
|
|
17
|
+
isGLOSTWord, isGLOSTSentence, isGLOSTParagraph, isGLOSTRoot, isGLOSTClause, isGLOSTPhrase, isGLOSTSyllable, isGLOSTCharacter,
|
|
18
|
+
// Word utilities
|
|
19
|
+
getWordText, getWordTranscription, hasWordTranscription, getWordTranslation, getWordMeaning, getWordPartOfSpeech, getWordDifficulty,
|
|
20
|
+
// Sentence utilities
|
|
21
|
+
getSentenceTranslation,
|
|
22
|
+
// Content statistics utilities
|
|
23
|
+
getGLOSTWordCount, adaptParagraphLikeToGLOST,
|
|
24
|
+
// BCP-47 Language utilities
|
|
25
|
+
parseLanguageTag, getBaseLanguage, areLanguagesCompatible, findBestLanguageMatch, getLanguageFallback, normalizeLanguageTag, isValidLanguageTag, } from "./utils";
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,uDAAuD;AAEvD,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,6BAA6B;AAC7B,cAAc,aAAa,CAAC;AAK5B,uDAAuD;AACvD,OAAO;AACL,iBAAiB;AACjB,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB;AAErB,eAAe;AACf,eAAe,EACf,mBAAmB,EACnB,8BAA8B;AAE9B,oDAAoD;AACpD,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB;AAEhB,iBAAiB;AACjB,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB;AAEjB,qBAAqB;AACrB,sBAAsB;AAEtB,+BAA+B;AAC/B,iBAAiB,EACjB,yBAAyB;AAEzB,4BAA4B;AAC5B,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { GLOSTWord } from './types';
|
|
2
|
+
declare const thaiWordsWithExtras: GLOSTWord[];
|
|
3
|
+
declare const japaneseWordsWithExtras: GLOSTWord[];
|
|
4
|
+
declare const thaiSentenceWithExtras: import("./types").GLOSTSentence;
|
|
5
|
+
declare const japaneseSentenceWithExtras: import("./types").GLOSTSentence;
|
|
6
|
+
declare const thaiParagraphWithExtras: import("./types").GLOSTParagraph;
|
|
7
|
+
declare const japaneseParagraphWithExtras: import("./types").GLOSTParagraph;
|
|
8
|
+
export declare const thaiDocumentWithExtras: import("./types").GLOSTRoot;
|
|
9
|
+
export declare const japaneseDocumentWithExtras: import("./types").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
|