mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-26 18:27:41 +00:00
Add a test for the default wordform to key function.
This commit is contained in:
parent
3f4aa0e9d9
commit
784555b7db
3 changed files with 32 additions and 2 deletions
|
|
@ -154,7 +154,36 @@ describe('LMLayerWorker trie model for word lists', function() {
|
|||
firstResults.map(s => s.displayAs)
|
||||
);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('The default key function', function () {
|
||||
it('uses the default key function', function () {
|
||||
var model = new TrieModel(jsonFixture('tries/accented'));
|
||||
|
||||
// «nai| » [Send]
|
||||
// [ ??? ] [ naïve ] [ ??? ]
|
||||
var [suggestion] = model.predict({
|
||||
insert: 'i', deleteLeft: 0
|
||||
}, {
|
||||
left: 'na',
|
||||
startOfBuffer: false,
|
||||
endOfBuffer: true
|
||||
}).map(getSample);
|
||||
assert.strictEqual(suggestion.displayAs, 'naïve');
|
||||
|
||||
// «Let‘s get some pho| » [Send]
|
||||
// [ ??? ] [ phở ] [ ??? ]
|
||||
var [suggestion] = model.predict({
|
||||
insert: 'o', deleteLeft: 0
|
||||
}, {
|
||||
left: 'Let‘s get some ph',
|
||||
startOfBuffer: false,
|
||||
endOfBuffer: true
|
||||
}).map(getSample);
|
||||
assert.strictEqual(suggestion.displayAs, 'phở');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
it('replaces the entire typed word when a suggestion is accepted', function () {
|
||||
// Ensure that all input is lower-cased when we try to look it up.
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
{"type":"internal","weight":1,"values":["p","n"],"children":{"p":{"type":"leaf","weight":1,"entries":[{"key":"pho","weight":1,"content":"phở"}]},"n":{"type":"leaf","weight":1,"entries":[{"key":"naive","weight":1,"content":"naïve"}]}}}
|
||||
|
|
@ -429,7 +429,7 @@
|
|||
*/
|
||||
function defaultWordform2Key(wordform: string): SearchKey {
|
||||
return wordform
|
||||
.replace(/[\u0100-\u2200]/, function (c) {
|
||||
.replace(/[\u0100-\u2200]/g, function (c) {
|
||||
if (c in PARTIAL_NFD_LOOKUP) {
|
||||
return PARTIAL_NFD_LOOKUP[c];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue