@willwade/core
v1.0.0
Published
This package contains a runtime toggle and a Worker scaffold for integrating an HFST WebAssembly runtime.
Readme
HFST runtime scaffold
This package contains a runtime toggle and a Worker scaffold for integrating an HFST WebAssembly runtime.
configureMorphRuntime('hfst')switches the core to use the HFST path (currently a stub that still delegates to rules).configureMorphHfst({ wasmUrl })lets you override the default WASM URL (./wasm/hfst.wasm).- The Worker code lives in
src/worker.ts; it is compiled withnpm run build:workertodist-worker/worker.js. - A minimal Worker client is in
src/workerClient.ts.
Building the Worker
npm run -w @morphgrid/core build:workerProviding the WASM
Place a WebAssembly binary (e.g., hfst.wasm) in packages/core/public/wasm/ (or override the URL at runtime).
You can scaffold the build steps with:
./tools/build-wasm/build.sh(That script is currently a placeholder—fill in Emscripten commands and sources.)
Using in a browser app (example)
import { morph, configureMorphRuntime, configureMorphHfst } from '@morphgrid/core';
configureMorphRuntime('hfst');
configureMorphHfst({ wasmUrl: '/wasm/hfst.wasm' });
await morph.load('fr-FR');
const analyses = await morph.analyse('aime', 'fr-FR');Until the WASM is wired, the API will behave like the rules runtime.
