Quick Start¶
We're going to build a simple text processing pipeline. By the end, you'll understand how pipelines work and be able to create your own.
What We're Building¶
A pipeline that takes text, reverses it, and converts to uppercase. Simple, but it shows how commands chain together.
Create the Project¶
You now have pipeline.ts and a .divvun-rt/ directory with TypeScript types.
What Just Happened¶
Open pipeline.ts and you'll see:
import { Command, StringEntry } from './.divvun-rt/mod.ts';
import * as example from './.divvun-rt/example.ts';
export default function examplePipeline(entry: StringEntry): Command {
let x = example.reverse(entry);
x = example.upper(x);
return x;
}
Breaking this down:
- StringEntry is your input type (a string)
- entry is the actual input text
- example.reverse(entry) reverses the string
- example.upper(x) uppercases it
- The function returns the result
The example module is just for learning. Real pipelines use hfst, cg3, divvun, and speech.
Run It¶
Output:
The text flows through: input → reverse → uppercase → output.
Modify It¶
Change the pipeline to just uppercase:
Run it again - now it just uppercases without reversing.
Use Real Modules¶
The example module is for learning. Real pipelines look like this:
import { StringEntry, Command } from './.divvun-rt/mod.ts';
import * as hfst from './.divvun-rt/hfst.ts';
import * as cg3 from './.divvun-rt/cg3.ts';
import * as divvun from './.divvun-rt/divvun.ts';
export default function grammarCheck(entry: StringEntry): Command {
let x = hfst.tokenize(entry, { model_path: "tokeniser.pmhfst" });
x = cg3.vislcg3(x, { model_path: "grammar.bin" });
return divvun.suggest(x, { model_path: "generator.hfstol" });
}
This tokenizes text, applies grammar rules, and generates error suggestions. You'd need to add the model files to assets/ for this to work.
What You Learned¶
- Pipelines are TypeScript functions
- Commands chain together: one's output becomes the next's input
divvun-runtime runexecutes your pipeline.divvun-rt/contains generated types for all available commands
See Pipelines for more details, or jump to Grammar Checking or Text-to-Speech to build something real.