mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-14 04:39:23 +00:00
Enable word list model in the top-level API.
This commit is contained in:
parent
a042a18858
commit
82ba375fb5
3 changed files with 13 additions and 3 deletions
12
common/predictive-text/message.d.ts
vendored
12
common/predictive-text/message.d.ts
vendored
|
|
@ -100,12 +100,20 @@ interface Capabilities {
|
|||
}
|
||||
|
||||
/**
|
||||
* TODO: discriminated union of different model types.
|
||||
* Describes what kind of model to instantiate.
|
||||
*/
|
||||
interface ModelDescription {
|
||||
type ModelDescription = DummyModelDescription | WordListModelDescription;
|
||||
interface DummyModelDescription {
|
||||
type: 'dummy';
|
||||
futureSuggestions?: Suggestion[][];
|
||||
}
|
||||
interface WordListModelDescription {
|
||||
type: 'wordlist';
|
||||
/**
|
||||
* Words to predict, one word per entry in the array.
|
||||
*/
|
||||
wordlist: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration of the LMLayer, sent back to the keyboard.
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ describe('LMLayer using the word list model', function () {
|
|||
}).then(function (suggestions) {
|
||||
// TODO: not super sure what to assert here!
|
||||
assert.isAtLeast(suggestions.length, EXPECTED_SUGGESTIONS);
|
||||
return lmLayer.predict(type('t'), emptyContext());
|
||||
return lmLayer.predict(type('t'), atEndOfBuffer(''));
|
||||
}).then(function (suggestions) {
|
||||
assert.isAtLeast(suggestions.length, EXPECTED_SUGGESTIONS);
|
||||
return lmLayer.predict(type('h'), atEndOfBuffer('t'));
|
||||
|
|
|
|||
|
|
@ -145,6 +145,8 @@ class LMLayerWorker {
|
|||
model = new LMLayerWorker.models.DummyModel(capabilities, {
|
||||
futureSuggestions: desc.futureSuggestions
|
||||
});
|
||||
} else if (desc.type === 'wordlist') {
|
||||
model = new LMLayerWorker.models.WordListModel(capabilities, desc.wordlist);
|
||||
} else {
|
||||
throw new Error('Invalid model');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue