@@ -128,22 +128,25 @@ describe('ContextToken', function() {
128128
129129 token1 . addInput ( {
130130 trueTransform : srcTransform ,
131- inputStartIndex : 0
131+ inputStartIndex : 0 ,
132+ bestProbFromSet : 1
132133 } , [ { sample : { insert : 'can' , deleteLeft : 0 , deleteRight : 0 , id : 1 } , p : 1 } ] ) ;
133134
134135 token2 . addInput ( {
135136 trueTransform : srcTransform ,
136- inputStartIndex : 3
137+ inputStartIndex : 3 ,
138+ bestProbFromSet : 1
137139 } , [ { sample : { insert : "'" , deleteLeft : 0 , deleteRight : 0 , id : 1 } , p : 1 } ] ) ;
138140
139141 token3 . addInput ( {
140142 trueTransform : srcTransform ,
141- inputStartIndex : 4
143+ inputStartIndex : 4 ,
144+ bestProbFromSet : 1
142145 } , [ { sample : { insert : 't' , deleteLeft : 0 , deleteRight : 0 , id : 1 } , p : 1 } ] ) ;
143146
144147 const merged = ContextToken . merge ( [ token1 , token2 , token3 ] , plainModel ) ;
145148 assert . equal ( merged . exampleInput , "can't" ) ;
146- assert . deepEqual ( merged . inputRange , [ { trueTransform : srcTransform , inputStartIndex : 0 } ] ) ;
149+ assert . deepEqual ( merged . inputRange , [ { trueTransform : srcTransform , inputStartIndex : 0 , bestProbFromSet : 1 } ] ) ;
147150 assert . deepEqual ( merged . searchSpace . inputSequence , [ [ { sample : srcTransform , p : 1 } ] ] ) ;
148151 } ) ;
149152
@@ -168,35 +171,41 @@ describe('ContextToken', function() {
168171
169172 token1 . addInput ( {
170173 trueTransform : srcTransform1 ,
171- inputStartIndex : 0
174+ inputStartIndex : 0 ,
175+ bestProbFromSet : 1
172176 } , [ { sample : srcTransform1 , p : 1 } ] ) ;
173177 token1 . addInput ( {
174178 trueTransform : srcTransform2 ,
175- inputStartIndex : 0
179+ inputStartIndex : 0 ,
180+ bestProbFromSet : 1
176181 } , [ { sample : { insert : 's' , deleteLeft : 0 , deleteRight : 0 , id : 2 } , p : 1 } ] ) ;
177182
178183 token2 . addInput ( {
179184 trueTransform : srcTransform2 ,
180- inputStartIndex : 1
185+ inputStartIndex : 1 ,
186+ bestProbFromSet : 1
181187 } , [ { sample : { insert : "and" , deleteLeft : 0 , deleteRight : 0 , id : 2 } , p : 1 } ] ) ;
182188
183189 token3 . addInput ( {
184190 trueTransform : srcTransform2 ,
185- inputStartIndex : 4
191+ inputStartIndex : 4 ,
192+ bestProbFromSet : 1
186193 } , [ { sample : { insert : 's' , deleteLeft : 0 , deleteRight : 0 , id : 2 } , p : 1 } ] ) ;
187194 token3 . addInput ( {
188195 trueTransform : srcTransform3 ,
189- inputStartIndex : 0
196+ inputStartIndex : 0 ,
197+ bestProbFromSet : 1
190198 } , [ { sample : srcTransform3 , p : 1 } ] ) ;
191199
192200 token4 . addInput ( {
193201 trueTransform : srcTransform4 ,
194- inputStartIndex : 0
202+ inputStartIndex : 0 ,
203+ bestProbFromSet : 1
195204 } , [ { sample : srcTransform4 , p : 1 } ] ) ;
196205
197206 const merged = ContextToken . merge ( tokensToMerge , plainModel ) ;
198207 assert . equal ( merged . exampleInput , "applesandsourgrapes" ) ;
199- assert . deepEqual ( merged . inputRange , srcTransforms . map ( ( t ) => ( { trueTransform : t , inputStartIndex : 0 } ) ) ) ;
208+ assert . deepEqual ( merged . inputRange , srcTransforms . map ( ( t ) => ( { trueTransform : t , inputStartIndex : 0 , bestProbFromSet : 1 } ) ) ) ;
200209 assert . deepEqual ( merged . searchSpace . inputSequence , srcTransforms . map ( ( t ) => [ { sample : t , p : 1 } ] ) ) ;
201210 } ) ;
202211
@@ -221,35 +230,41 @@ describe('ContextToken', function() {
221230
222231 token1 . addInput ( {
223232 trueTransform : srcTransform1 ,
224- inputStartIndex : 0
233+ inputStartIndex : 0 ,
234+ bestProbFromSet : 1
225235 } , [ { sample : srcTransform1 , p : 1 } ] ) ;
226236 token1 . addInput ( {
227237 trueTransform : srcTransform2 ,
228- inputStartIndex : 0
238+ inputStartIndex : 0 ,
239+ bestProbFromSet : 1
229240 } , [ { sample : { insert : toMathematicalSMP ( 's' ) , deleteLeft : 0 , deleteRight : 0 , id : 2 } , p : 1 } ] ) ;
230241
231242 token2 . addInput ( {
232243 trueTransform : srcTransform2 ,
233- inputStartIndex : 1
244+ inputStartIndex : 1 ,
245+ bestProbFromSet : 1
234246 } , [ { sample : { insert : toMathematicalSMP ( "and" ) , deleteLeft : 0 , deleteRight : 0 , id : 2 } , p : 1 } ] ) ;
235247
236248 token3 . addInput ( {
237249 trueTransform : srcTransform2 ,
238- inputStartIndex : 4
250+ inputStartIndex : 4 ,
251+ bestProbFromSet : 1
239252 } , [ { sample : { insert : toMathematicalSMP ( 's' ) , deleteLeft : 0 , deleteRight : 0 , id : 2 } , p : 1 } ] ) ;
240253 token3 . addInput ( {
241254 trueTransform : srcTransform3 ,
242- inputStartIndex : 0
255+ inputStartIndex : 0 ,
256+ bestProbFromSet : 1
243257 } , [ { sample : srcTransform3 , p : 1 } ] ) ;
244258
245259 token4 . addInput ( {
246260 trueTransform : srcTransform4 ,
247- inputStartIndex : 0
261+ inputStartIndex : 0 ,
262+ bestProbFromSet : 1
248263 } , [ { sample : srcTransform4 , p : 1 } ] ) ;
249264
250265 const merged = ContextToken . merge ( tokensToMerge , plainModel ) ;
251266 assert . equal ( merged . exampleInput , toMathematicalSMP ( "applesandsourgrapes" ) ) ;
252- assert . deepEqual ( merged . inputRange , srcTransforms . map ( ( t ) => ( { trueTransform : t , inputStartIndex : 0 } ) ) ) ;
267+ assert . deepEqual ( merged . inputRange , srcTransforms . map ( ( t ) => ( { trueTransform : t , inputStartIndex : 0 , bestProbFromSet : 1 } ) ) ) ;
253268 assert . deepEqual ( merged . searchSpace . inputSequence , srcTransforms . map ( ( t ) => [ { sample : t , p : 1 } ] ) ) ;
254269 } ) ;
255270 } ) ;
@@ -278,7 +293,7 @@ describe('ContextToken', function() {
278293
279294 const tokenToSplit = new ContextToken ( plainModel ) ;
280295 for ( let i = 0 ; i < keystrokeDistributions . length ; i ++ ) {
281- tokenToSplit . addInput ( { trueTransform : keystrokeDistributions [ i ] [ 0 ] . sample , inputStartIndex : 0 } , keystrokeDistributions [ i ] ) ;
296+ tokenToSplit . addInput ( { trueTransform : keystrokeDistributions [ i ] [ 0 ] . sample , inputStartIndex : 0 , bestProbFromSet : .75 } , keystrokeDistributions [ i ] ) ;
282297 } ;
283298
284299 assert . equal ( tokenToSplit . sourceText , 'can\'' ) ;
@@ -316,7 +331,7 @@ describe('ContextToken', function() {
316331
317332 const tokenToSplit = new ContextToken ( plainModel ) ;
318333 for ( let i = 0 ; i < keystrokeDistributions . length ; i ++ ) {
319- tokenToSplit . addInput ( { trueTransform : keystrokeDistributions [ i ] [ 0 ] . sample , inputStartIndex : 0 } , keystrokeDistributions [ i ] ) ;
334+ tokenToSplit . addInput ( { trueTransform : keystrokeDistributions [ i ] [ 0 ] . sample , inputStartIndex : 0 , bestProbFromSet : 1 } , keystrokeDistributions [ i ] ) ;
320335 } ;
321336
322337 assert . equal ( tokenToSplit . sourceText , 'biglargetransform' ) ;
@@ -343,7 +358,9 @@ describe('ContextToken', function() {
343358 insert : 'biglargetransform' ,
344359 deleteLeft : 0 ,
345360 deleteRight : 0
346- } , inputStartIndex : i
361+ } ,
362+ inputStartIndex : i ,
363+ bestProbFromSet : 1
347364 } ) ) ) ;
348365 assert . sameDeepOrderedMembers ( resultsOfSplit . map ( t => t . searchSpace . inputSequence [ 0 ] ) , splitTextArray . map ( t => [ {
349366 sample : { insert : t , deleteLeft : 0 , deleteRight : 0 } , p : 1
@@ -365,7 +382,7 @@ describe('ContextToken', function() {
365382
366383 const tokenToSplit = new ContextToken ( plainModel ) ;
367384 for ( let i = 0 ; i < keystrokeDistributions . length ; i ++ ) {
368- tokenToSplit . addInput ( { trueTransform : keystrokeDistributions [ i ] [ 0 ] . sample , inputStartIndex : 0 } , keystrokeDistributions [ i ] ) ;
385+ tokenToSplit . addInput ( { trueTransform : keystrokeDistributions [ i ] [ 0 ] . sample , inputStartIndex : 0 , bestProbFromSet : 1 } , keystrokeDistributions [ i ] ) ;
369386 } ;
370387
371388 assert . equal ( tokenToSplit . exampleInput , 'largelongtransforms' ) ;
@@ -388,15 +405,15 @@ describe('ContextToken', function() {
388405 assert . equal ( resultsOfSplit . length , 3 ) ;
389406 assert . sameOrderedMembers ( resultsOfSplit . map ( t => t . exampleInput ) , splitTextArray ) ;
390407 assert . deepEqual ( resultsOfSplit [ 0 ] . inputRange , [
391- { trueTransform : keystrokeDistributions [ 0 ] [ 0 ] . sample , inputStartIndex : 0 } ,
392- { trueTransform : keystrokeDistributions [ 1 ] [ 0 ] . sample , inputStartIndex : 0 } ,
408+ { trueTransform : keystrokeDistributions [ 0 ] [ 0 ] . sample , inputStartIndex : 0 , bestProbFromSet : 1 } ,
409+ { trueTransform : keystrokeDistributions [ 1 ] [ 0 ] . sample , inputStartIndex : 0 , bestProbFromSet : 1 } ,
393410 ] ) ;
394411 assert . deepEqual ( resultsOfSplit [ 1 ] . inputRange , [
395- { trueTransform : keystrokeDistributions [ 1 ] [ 0 ] . sample , inputStartIndex : 'arge' . length } ,
396- { trueTransform : keystrokeDistributions [ 2 ] [ 0 ] . sample , inputStartIndex : 0 } ,
412+ { trueTransform : keystrokeDistributions [ 1 ] [ 0 ] . sample , inputStartIndex : 'arge' . length , bestProbFromSet : 1 } ,
413+ { trueTransform : keystrokeDistributions [ 2 ] [ 0 ] . sample , inputStartIndex : 0 , bestProbFromSet : 1 } ,
397414 ] ) ;
398415 assert . deepEqual ( resultsOfSplit [ 2 ] . inputRange , [
399- { trueTransform : keystrokeDistributions [ 2 ] [ 0 ] . sample , inputStartIndex : 'ng' . length }
416+ { trueTransform : keystrokeDistributions [ 2 ] [ 0 ] . sample , inputStartIndex : 'ng' . length , bestProbFromSet : 1 }
400417 ] ) ;
401418
402419 assert . deepEqual ( resultsOfSplit [ 0 ] . searchSpace . inputSequence , [
@@ -459,7 +476,7 @@ describe('ContextToken', function() {
459476
460477 const tokenToSplit = new ContextToken ( plainModel ) ;
461478 for ( let i = 0 ; i < keystrokeDistributions . length ; i ++ ) {
462- tokenToSplit . addInput ( { trueTransform : keystrokeDistributions [ i ] [ 0 ] . sample , inputStartIndex : 0 } , keystrokeDistributions [ i ] ) ;
479+ tokenToSplit . addInput ( { trueTransform : keystrokeDistributions [ i ] [ 0 ] . sample , inputStartIndex : 0 , bestProbFromSet : 1 } , keystrokeDistributions [ i ] ) ;
463480 } ;
464481
465482 assert . equal ( tokenToSplit . exampleInput , toMathematicalSMP ( 'largelongtransforms' ) ) ;
@@ -482,15 +499,15 @@ describe('ContextToken', function() {
482499 assert . equal ( resultsOfSplit . length , 3 ) ;
483500 assert . sameOrderedMembers ( resultsOfSplit . map ( t => t . exampleInput ) , splitTextArray ) ;
484501 assert . deepEqual ( resultsOfSplit [ 0 ] . inputRange , [
485- { trueTransform : keystrokeDistributions [ 0 ] [ 0 ] . sample , inputStartIndex : 0 } ,
486- { trueTransform : keystrokeDistributions [ 1 ] [ 0 ] . sample , inputStartIndex : 0 } ,
502+ { trueTransform : keystrokeDistributions [ 0 ] [ 0 ] . sample , inputStartIndex : 0 , bestProbFromSet : 1 } ,
503+ { trueTransform : keystrokeDistributions [ 1 ] [ 0 ] . sample , inputStartIndex : 0 , bestProbFromSet : 1 } ,
487504 ] ) ;
488505 assert . deepEqual ( resultsOfSplit [ 1 ] . inputRange , [
489- { trueTransform : keystrokeDistributions [ 1 ] [ 0 ] . sample , inputStartIndex : 'arge' . length } ,
490- { trueTransform : keystrokeDistributions [ 2 ] [ 0 ] . sample , inputStartIndex : 0 } ,
506+ { trueTransform : keystrokeDistributions [ 1 ] [ 0 ] . sample , inputStartIndex : 'arge' . length , bestProbFromSet : 1 } ,
507+ { trueTransform : keystrokeDistributions [ 2 ] [ 0 ] . sample , inputStartIndex : 0 , bestProbFromSet : 1 } ,
491508 ] ) ;
492509 assert . deepEqual ( resultsOfSplit [ 2 ] . inputRange , [
493- { trueTransform : keystrokeDistributions [ 2 ] [ 0 ] . sample , inputStartIndex : 'ng' . length }
510+ { trueTransform : keystrokeDistributions [ 2 ] [ 0 ] . sample , inputStartIndex : 'ng' . length , bestProbFromSet : 1 }
494511 ] ) ;
495512
496513 assert . deepEqual ( resultsOfSplit [ 0 ] . searchSpace . inputSequence , [
@@ -550,7 +567,8 @@ describe('preprocessInputSources', () => {
550567
551568 const results = preprocessInputSources ( transforms . map ( ( t ) => ( {
552569 trueTransform : t ,
553- inputStartIndex : 0
570+ inputStartIndex : 0 ,
571+ bestProbFromSet : 1
554572 } ) ) ) ;
555573
556574 assert . equal ( results . length , transforms . length ) ;
0 commit comments