@predictive-text-studio/lexical-model-compiler
Version:
Keyman Developer lexical model compiler
39 lines • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Re-export the good bits from in the lexical-model-compiler submodule!
*/
const lexical_model_compiler_1 = require("./lexical-model-compiler");
exports.DefaultLexicalModelCompiler = lexical_model_compiler_1.DefaultLexicalModelCompiler;
exports.ModelSourceError = lexical_model_compiler_1.ModelSourceError;
/**
* Given a {@link LexicalModelSource}, this returns the compiled JavaScript
* model that can be packaged into a .kmp file.
*
* @returns {string} the generated model code
*/
function compileModelFromLexicalModelSource(source) {
return (new lexical_model_compiler_1.DefaultLexicalModelCompiler).compile(source, () => {
throw new Error("Not implemented: provide sources via filename");
});
}
exports.compileModelFromLexicalModelSource = compileModelFromLexicalModelSource;
/**
* A {@link WordListSource} with the data given as an array of [word, count]
* pairs. Useful if you have already parsed out all of the lines in advanced.
*/
class WordListFromArray {
constructor(name, data) {
this.name = name;
this._data = data;
}
*lines() {
let lineno = 1;
for (let [word, count] of this._data) {
yield [lineno, `${word}\t${count}`];
lineno++;
}
}
}
exports.WordListFromArray = WordListFromArray;
//# sourceMappingURL=index.js.map