score ( full fuzzy -- n )
Fuzzy completion
Prev:runs ( seq -- newseq )
Next:complete ( full short -- score )


Vocabulary
tools.completion

Inputs and outputs
fulla string
fuzzya sequence of sequences of integers
nan integer


Word description
Ranks fuzzy by how closely it approximates the sequence { { 0 ... n-1 } } where n is the length of full.

Definition
USING: kernel math math.order sequences
tools.completion.private ;

IN: tools.completion

: score ( full fuzzy -- n )
dup [
[ [ length ] bi@ - 15 swap [-] 3 /f ] 2keep runs [
[ 0 [ pick score-1 max ] reduce nip ] keep length *
+
] with each
] [ 2drop 0 ] if ;