Merge pull request #2079 from keymanapp/developer-remove-class-based-wordbreaker

[Developer] Remove class based word breaker
This commit is contained in:
Eddie Antonio Santos 2019-09-11 21:39:54 -06:00 • committed by GitHub
commit 5a6eaf2ba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 26 deletions

View file

@ -22,8 +22,6 @@ export default class LexicalModelCompiler {
* @param sourcePath Where to find auxilary sources files
*/
generateLexicalModelCode(model_id: string, modelSource: LexicalModelSource, sourcePath: string) {
let compiler = this;
// TODO: add metadata in comment
const filePrefix: string = `(function() {\n'use strict';\n`;
const fileSuffix: string = `})();`;
@ -42,13 +40,6 @@ export default class LexicalModelCompiler {
// Note: the .toString() might just be the property name, but we want a
// plain function:
.replace(/^wordBreak(ing|er)\b/, 'function');
} else if (wordBreakerSpec.sources) {
compiler.logError('class-based word breaker is not officially supported :/');
let wordBreakerSources: string[] = wordBreakerSpec.sources.map(function(source) {
return fs.readFileSync(path.join(sourcePath, source), 'utf8');
});
wordBreakerSourceCode = this.transpileSources(wordBreakerSources).join('\n');
}
}

View file

@ -4,22 +4,6 @@
*/
/// <reference path="../../../../common/predictive-text/worker/worker-compiler-interfaces.d.ts" />
/**
* ****** TODO: DELETE ME******
*
* This form of specifying word breakers is not implemented.
*
*/
interface ClassBasedWordBreaker {
allowedCharacters?: { initials?: string, medials?: string, finals?: string } | string,
defaultBreakCharacter?: string
sources?: Array<string>;
/**
* The name of the type to instantiate (without parameters) as the base object for a custom word-breaking model.
*/
rootClass?: string
}
interface LexicalModel {
readonly format: 'trie-1.0'|'fst-foma-1.0'|'custom-1.0',
//... metadata ...
@ -41,7 +25,7 @@ interface LexicalModelSource extends LexicalModel {
* - word breaking function -- provide your own function that breaks words.
* - class-based word-breaker - may be supported in the future.
*/
readonly wordBreaker?: 'default' | 'ascii' | WordBreakingFunction | ClassBasedWordBreaker;
readonly wordBreaker?: 'default' | 'ascii' | WordBreakingFunction;
/**
* How to simplify words, to convert them into simplifired search keys