GLOST - Glossed Syntax Tree for language learning and multilingual text processing
npm install glostbash
npm install glost
`
`typescript
import { glost, createSimpleDocument, getAllWords } from "glost";
import { languageLearningPreset } from "glost/presets";
// Create a document
const words = [
{ type: "WordNode", value: "สวัสดี" },
{ type: "WordNode", value: "ครับ" }
];
const document = createSimpleDocument(words, "th", "thai", {
sentenceText: "สวัสดีครับ"
});
// Process with plugins
const result = await glost()
.use(languageLearningPreset)
.process(document);
// Access processed data
const allWords = getAllWords(result);
`
What's Included
The glost package is a convenient meta-package that includes:
- glost-core - Core types, nodes, and utilities
- glost-processor - Unified-style processor with fluent API
- glost-registry - Plugin discovery and validation
- glost-presets - Pre-configured plugin combinations
Features
$3
Fluent API for plugin composition:
`typescript
const processor = glost()
.use(transcription, { scheme: "ipa" })
.use(translation, { target: "en" })
.use(frequency)
.freeze();
const result = await processor.process(document);
`
$3
Find and validate plugins:
`typescript
import { pluginRegistry } from "glost";
const plugins = pluginRegistry.search({ language: "th" });
const report = pluginRegistry.checkConflicts(["plugin1", "plugin2"]);
`
$3
Quick setup with common configurations:
`typescript
import { languageLearningPreset } from "glost/presets";
const processor = glost()
.use(languageLearningPreset);
`
Available presets:
- languageLearningPreset - Full language learning stack
- readingAppPreset - Interactive reading features
- vocabularyBuilderPreset - Word frequency and difficulty
- grammarAnalyzerPreset - POS and clause analysis
- minimalPreset - Just the essentials
$3
Built-in support for:
- Thai (glost-th)
- Japanese (glost-ja)
- Korean (glost-ko)
- English (glost-en)
$3
Create custom plugins or use community plugins:
`typescript
const myPlugin = {
id: "my-plugin",
name: "My Custom Plugin",
transform: (tree) => {
// Your custom logic
return tree;
}
};
processor.use(myPlugin);
`
Package Structure
GLOST is organized as a monorepo:
`
glost/
├── glost # Main package (this one)
├── glost-core # Core types and nodes
├── glost-processor # Processor API
├── glost-registry # Plugin registry
├── glost-presets # Preset configurations
├── glost-common # Language utilities
├── glost-extensions # Extension system
├── glost-th # Thai language support
├── glost-ja # Japanese language support
└── glost-cli # CLI tools
`
Installation Options
$3
`bash
npm install glost
`
$3
`bash
Just the core
npm install glost-core
Core + processor
npm install glost-core glost-processor
Core + specific language
npm install glost-core glost-th
`
Usage Examples
$3
`typescript
import { createSimpleDocument, getAllWords } from "glost";
const document = createSimpleDocument(words, "th", "thai");
const allWords = getAllWords(document);
`
$3
`typescript
import { glost } from "glost";
const processor = glost()
.use("transcription")
.use("translation")
.use("frequency");
const result = await processor.process(document);
`
$3
`typescript
import { glost } from "glost";
const processor = glost()
.use("transcription")
.before("transcription", (doc) => {
console.log("Starting transcription");
})
.after("transcription", (doc) => {
console.log("Transcription complete");
})
.onProgress((stats) => {
console.log(Progress: ${stats.completed}/${stats.total});
});
await processor.process(document);
`
$3
`typescript
import { pluginRegistry } from "glost";
// Search for plugins
const thaiPlugins = pluginRegistry.search({
language: "th",
category: "enhancer"
});
// Validate combinations
const report = pluginRegistry.checkConflicts([
"transcription",
"translation",
"frequency"
]);
if (!report.hasConflicts) {
// Safe to use together
processor.use("transcription").use("translation").use("frequency");
}
`
CLI Tools
Install CLI tools globally:
`bash
npm install -g glost-cli
`
`bash
List plugins
glost plugins list
Search
glost plugins search transcription
Show info
glost plugins info transcription
Validate
glost plugins validate transcription translation frequency
`
Documentation
- Getting Started - Installation and first steps
- Processor API - Complete processor guide
- Registry - Plugin discovery and validation
- Migration Guide - Upgrading from v0.4
- API Reference - Complete API documentation
Examples
See the examples directory for complete examples:
- Language learning app
- Large document processing
- Custom plugin development
- Multi-language support
Use Cases
GLOST is used for:
- Language Learning Apps - Interactive reading with annotations
- Dictionary Systems - Multiple transcription schemes
- Graded Readers - Content adapted to learner level
- Educational Tools - Vocabulary and grammar practice
- Text Analysis - Linguistic annotation and processing
Comparison with v0.4
$3
`typescript
import { processGLOSTWithExtensions } from "glost-extensions";
const result = processGLOSTWithExtensions(doc, [ext1, ext2, ext3]);
`
$3
`typescript
import { glost } from "glost";
const result = await glost()
.use(ext1)
.use(ext2)
.use(ext3)
.process(doc);
``