Re-add words-matching, and add new vocabs-matching words, for use by new listener completion

db4
Slava Pestov 2009-01-09 17:58:13 -06:00
parent 50a4e018e1
commit fe0c636ffe
1 changed files with 9 additions and 8 deletions

View File

@ -1,8 +1,8 @@
! Copyright (C) 2005, 2008 Slava Pestov. ! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel arrays sequences math namespaces strings io fry USING: accessors kernel arrays sequences math namespaces
vectors words assocs combinators sorting unicode.case strings io fry vectors words assocs combinators sorting
unicode.categories math.order ; unicode.case unicode.categories math.order vocabs ;
IN: tools.completion IN: tools.completion
: (fuzzy) ( accum ch i full -- accum i ? ) : (fuzzy) ( accum ch i full -- accum i ? )
@ -68,7 +68,8 @@ IN: tools.completion
[ '[ >lower _ [ completion ] with map rank-completions ] ] bi [ '[ >lower _ [ completion ] with map rank-completions ] ] bi
if-empty ; if-empty ;
: limited-completions ( short candidates -- seq ) : words-matching ( str -- seq )
[ completions ] [ drop ] 2bi all-words [ dup name>> ] { } map>assoc completions ;
2dup [ length 50 > ] [ empty? ] bi* and
[ 2drop f ] [ drop 50 short head ] if ; : vocabs-matching ( str -- seq )
vocabs [ dup name>> ] { } map>assoc completions ;