<commit_before>! Copyright (C) 2005, 2010 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes classes.error
classes.tuple combinators combinators.short-circuit
continuations debugger effects generic help.crossref help.markup
help.stylesheet help.topics io io.styles kernel locals make
namespaces prettyprint sequences sets sorting vocabs words
words.symbol ;
IN: help

GENERIC: word-help* ( word -- content )

: word-help ( word -- content )
    dup "help" word-prop [ ] [ word-help* ] ?if ;

: $predicate ( element -- )
    { { "object" object } { "?" boolean } } $values
    [
        "Tests if the object is an instance of the " ,
        first "predicating" word-prop <$link> ,
        " class." ,
    ] { } make $description ;

M: word word-help*
    stack-effect [ in>> ] [ out>> ] bi [
        [
            dup pair? [
                first2 dup effect? [ \ $quotation swap 2array ] when
            ] [
                object
            ] if
        ] { } map>assoc
    ] bi@ append members \ $values prefix 1array ;

M: class word-help* drop f ;

M: predicate word-help* \ $predicate prefix 1array ;

: all-articles ( -- seq )
    articles get keys
    all-words [ word-help ] filter append ;
<commit_msg>help: small fix because I forgot to test predicates still worked.<commit_after>! Copyright (C) 2005, 2010 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes classes.error
classes.tuple combinators combinators.short-circuit
continuations debugger effects generic help.crossref help.markup
help.stylesheet help.topics io io.styles kernel locals make
namespaces prettyprint sequences sets sorting vocabs words
words.symbol ;
IN: help

GENERIC: word-help* ( word -- content )

: word-help ( word -- content )
    dup "help" word-prop [ ] [
        dup word-help* dup
       [ swap 2array 1array ] [ 2drop f ] if
    ] ?if ;

: $predicate ( element -- )
    { { "object" object } { "?" boolean } } $values
    [
        "Tests if the object is an instance of the " ,
        first "predicating" word-prop <$link> ,
        " class." ,
    ] { } make $description ;

: $default ( element -- )
    first stack-effect [ in>> ] [ out>> ] bi [
        [
            dup pair? [
                first2 dup effect? [ \ $quotation swap 2array ] when
            ] [
                object
            ] if
        ] { } map>assoc
    ] bi@ append members $values ;

M: word word-help* drop \ $default ;

M: class word-help* drop f ;

M: predicate word-help* drop \ $predicate ;

: all-articles ( -- seq )
    articles get keys
    all-words [ word-help ] filter append ;

{'fraction_non_alphanumeric': 0.11496827174318776, 'fraction_numerical': 0.00933184023889511, 'mean_word_length': 2.3458177278402, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3789786', 'n_tokens_mistral': 828, 'n_tokens_neox': 790, 'n_words': 264}