]> gitweb.factorcode.org Git - factor.git/blob - extra/did-you-mean/did-you-mean.factor
did-you-mean: prototype of a spelling corrector word search
[factor.git] / extra / did-you-mean / did-you-mean.factor
1 ! Copyright (C) 2022 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
3
4 USING: accessors assocs continuations kernel math
5 math.statistics parser sequences spelling vocabs vocabs.parser ;
6
7 IN: did-you-mean
8
9 : did-you-mean ( name -- words )
10     dup all-words [ [ name>> ] histogram-by corrections ] keep
11     [ name>> swap member? ] with filter
12     <no-word-error> throw-restarts no-word-restarted ;