glost-inkle
Ink/Inkle interactive fiction integration for GLOST.
Installation
pnpm add @glotblocks/glost-inkleOverview
This package provides integration with Ink , the narrative scripting language by Inkle Studios. It allows you to parse Ink story JSON and convert it to GLOST documents for language learning applications.
Usage
parseInkJSON
Parse Ink JSON output to a GLOST document.
import { parseInkJSON } from '@glotblocks/glost-inkle';
const inkStory = {
root: [/* ink JSON structure */],
// ...
};
const document = parseInkJSON(inkStory, {
language: "en",
script: "latin"
});Options
interface ParseInkOptions {
language: GlostLanguage;
script?: string;
sections?: string[]; // Specific sections to parse
}Use Cases
Multilingual Interactive Fiction
Create language learning games using Ink stories:
=== greeting ===
สวัสดีครับ #thai #translation:Hello
คุณสบายดีไหม #thai #translation:How are you?
* [สบายดี] -> good_response
* [ไม่สบาย] -> bad_responseAnnotated Stories
Parse Ink stories and enrich them with GLOST extensions:
import { processGLOSTWithExtensionsAsync } from '@glotblocks/glost-plugins';
import { parseInkJSON } from '@glotblocks/glost-inkle';
import { createFrequencyExtension } from '@glotblocks/glost-frequency';
import { createDifficultyExtension } from '@glotblocks/glost-difficulty';
// Parse Ink story
const document = parseInkJSON(inkStory, { language: 'th' });
// Create extensions
const [freqGen, freqEnh] = createFrequencyExtension({
targetLanguage: 'th',
provider: myFrequencyProvider
});
const [diffGen, diffEnh] = createDifficultyExtension({
targetLanguage: 'th',
provider: myDifficultyProvider
});
// Enrich with language learning metadata
const result = await processGLOSTWithExtensionsAsync(document, [
freqGen, freqEnh,
diffGen, diffEnh
]);Story-Based Learning
Build applications that:
- Show word-by-word translations
- Highlight vocabulary by difficulty
- Track learned words through story progression
- Provide pronunciation guides
Integration with Ink
Getting Ink JSON
Compile your Ink story to JSON:
# Using inklecate
inklecate -j story.ink > story.jsonLoading in JavaScript
import storyJson from './story.json';
import { parseInkJSON } from '@glotblocks/glost-inkle';
const document = parseInkJSON(storyJson, {
language: "th",
script: "thai"
});Example
Input (Ink JSON)
{
"root": [
["^Hello, world!", "\n", "done", null]
],
"listDefs": {}
}Output (GLOST Document)
{
type: "root",
lang: "en",
script: "latin",
children: [
{
type: "ParagraphNode",
children: [
{
type: "SentenceNode",
children: [
{ type: "WordNode", children: [{ type: "TextNode", value: "Hello" }] },
{ type: "PunctuationNode", value: "," },
{ type: "WhiteSpaceNode", value: " " },
{ type: "WordNode", children: [{ type: "TextNode", value: "world" }] },
{ type: "PunctuationNode", value: "!" }
]
}
]
}
]
}Last updated on