glost
v0.5.0
Published
GLOST - Glossed Syntax Tree for language learning and multilingual text processing
Maintainers
Readme
GLOST - Glossed Syntax Tree
GLOST (Glossed Syntax Tree) is a powerful framework for processing multilingual text with language learning annotations using a unified/remark-style plugin system.
Quick Start
npm install glostimport { 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
🚀 Unified-Style Processor
Fluent API for plugin composition:
const processor = glost()
.use(transcription, { scheme: "ipa" })
.use(translation, { target: "en" })
.use(frequency)
.freeze();
const result = await processor.process(document);🔍 Plugin Discovery
Find and validate plugins:
import { pluginRegistry } from "glost";
const plugins = pluginRegistry.search({ language: "th" });
const report = pluginRegistry.checkConflicts(["plugin1", "plugin2"]);📦 Presets
Quick setup with common configurations:
import { languageLearningPreset } from "glost/presets";
const processor = glost()
.use(languageLearningPreset);Available presets:
languageLearningPreset- Full language learning stackreadingAppPreset- Interactive reading featuresvocabularyBuilderPreset- Word frequency and difficultygrammarAnalyzerPreset- POS and clause analysisminimalPreset- Just the essentials
🎯 Multi-Language Support
Built-in support for:
- Thai (
glost-th) - Japanese (
glost-ja) - Korean (
glost-ko) - English (
glost-en)
🔧 Extensible
Create custom plugins or use community plugins:
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 toolsInstallation Options
All-in-One (Recommended)
npm install glostGranular Installation
# Just the core
npm install glost-core
# Core + processor
npm install glost-core glost-processor
# Core + specific language
npm install glost-core glost-thUsage Examples
Basic Document Creation
import { createSimpleDocument, getAllWords } from "glost";
const document = createSimpleDocument(words, "th", "thai");
const allWords = getAllWords(document);With Processor
import { glost } from "glost";
const processor = glost()
.use("transcription")
.use("translation")
.use("frequency");
const result = await processor.process(document);With Hooks
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);With Registry
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:
npm install -g glost-cli# List plugins
glost plugins list
# Search
glost plugins search transcription
# Show info
glost plugins info transcription
# Validate
glost plugins validate transcription translation frequencyDocumentation
- 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
Before (v0.4)
import { processGLOSTWithExtensions } from "glost-extensions";
const result = processGLOSTWithExtensions(doc, [ext1, ext2, ext3]);After (v1.0)
import { glost } from "glost";
const result = await glost()
.use(ext1)
.use(ext2)
.use(ext3)
.process(doc);See the Migration Guide for details.
Contributing
Contributions are welcome! See CONTRIBUTING.md for guidelines.
License
MIT © fustilio
Related Projects
- nlcst - Natural Language Concrete Syntax Tree
- unist - Universal Syntax Tree
- unified - Interface for parsing, inspecting, transforming, and serializing content
