@predictive-text-studio/lexical-model-compiler
Version:
Keyman Developer lexical model compiler
38 lines (37 loc) • 1.69 kB
TypeScript
/// <reference path="model-info-file.d.ts" />
import { WordListSource } from "./wordlist";
import { LexicalModelSource } from "./lexical-model-source";
/**
* A callback that fetches a wordlist with the given name.
*/
export declare type GetWordListByName = (name: string) => WordListSource;
export default interface LexicalModelCompiler {
/**
* Returns the generated code for the model that will ultimately be loaded by
* the LMLayer worker. This code contains all model parameters, and specifies
* word breakers and auxilary functions that may be required.
*
* @param model_id The model ID. TODO: not sure if this is actually required!
* @param modelSource A specification of the model to compile
* @param sourcePath Where to find auxilary sources files
*/
compile(modelSource: LexicalModelSource, getWordList: GetWordListByName): string;
}
export declare class DefaultLexicalModelCompiler implements LexicalModelCompiler {
private snippets;
private emit;
private emitLine;
private get func();
/**
* Returns the generated code for the model that will ultimately be loaded by
* the LMLayer worker. This code contains all model parameters, and specifies
* word breakers and auxilary functions that may be required.
*
* @param model_id The model ID. TODO: not sure if this is actually required!
* @param modelSource A specification of the model to compile
* @param sourcePath Where to find auxilary sources files
*/
compile(modelSource: LexicalModelSource, getWordList: GetWordListByName): string;
}
export declare class ModelSourceError extends Error {
}