! Copyright (C) 2012 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
-USING: arrays assocs combinators combinators.short-circuit fry
-help help.apropos help.markup help.stylesheet help.topics io
-io.streams.string io.styles kernel math memoize namespaces
-sequences sequences.deep sorting splitting strings unicode
-words ;
+USING: arrays combinators combinators.short-circuit help
+help.apropos help.markup help.stylesheet help.topics io
+io.styles kernel math namespaces sequences sorting splitting
+strings unicode words ;
IN: help.search
{ \ $vocab-link [ second ] }
{ \ $emphasis [ second ] }
{ \ $subsection [ second article-name ] }
- { \ $subsections [ rest [ article-name ] map " " join ] }
- { \ $description [ rest [ element-value ] map " " join ] }
- { \ $notes [ rest [ element-value ] map " " join ] }
- { \ $snippet [ rest [ element-value ] map " " join ] }
+ { \ $subsections [ rest [ article-name ] map join-words ] }
+ { \ $description [ rest [ element-value ] map join-words ] }
+ { \ $notes [ rest [ element-value ] map join-words ] }
+ { \ $snippet [ rest [ element-value ] map join-words ] }
[ 2drop f ]
} case
] [ dup string? [ drop f ] unless ] if ;
MEMO: article-words ( name -- words )
- article-content [ element-value ] map " " join search-words
+ article-content [ element-value ] map join-words search-words
[ [ digit? ] all? ] reject
[ [ { [ letter? ] [ digit? ] } 1|| not ] trim ] map! harvest ;
search-words [ { } ] [
[ all-articles ] dip
dup length 1 > [
- '[ article-words _ swap subseq? ] filter
+ '[ article-words _ subseq-of? ] filter
] [
first '[ article-words [ _ head? ] any? ] filter
] if