@predictive-text-studio/lexical-model-compiler
Version:
Keyman Developer lexical model compiler
40 lines • 2.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const with_node_fs_1 = require("./build-trie/with-node-fs");
const lexical_model_compiler_1 = require("./lexical-model-compiler");
class LegacyLexicalModelCompiler extends lexical_model_compiler_1.DefaultLexicalModelCompiler {
/**
* 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.
*
* @deprecated
* @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
*/
generateLexicalModelCode(model_id, modelSource, sourcePath) {
return this.compile(modelSource, (filename) => {
// Convert all relative path names to paths relative to the enclosing
// directory. This way, we'll read the files relative to the model.ts
// file, rather than the current working directory.
let adjustedFileName = path.join(sourcePath, filename);
return new with_node_fs_1.WordListFromFilename(adjustedFileName);
});
}
/**
* 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
*/
static compileUsingLegacyInterface(model_id, modelSource, sourcePath) {
return (new LegacyLexicalModelCompiler).generateLexicalModelCode(model_id, modelSource, sourcePath);
}
}
exports.LegacyLexicalModelCompiler = LegacyLexicalModelCompiler;
//# sourceMappingURL=legacy-lexical-model-compiler.js.map