Paste: deploy-helper

Author: randy7
Mode: factor
Date: Tue, 12 May 2009 23:18:52
Plain Text |
USING: accessors arrays fry kernel quotations sequences
sequences.deep sets sorting vocabs words splitting ;
IN: deploy-helper

: word-home-vocab ( word/quot -- vocab/f )
    dup quotation? not [ vocabulary>> ] [ drop f ] if ;

: rec-word-home-vocab ( word/quot -- vocab/f )
    dup [ word? ] [ quotation? ] bi or
    [
    dup quotation? not [ vocabulary>> ] [ >array [ rec-word-home-vocab ] map ] if 
    ] [ drop f ] if ; inline recursive

: rec-word-get ( word/quot -- word/f )
    dup [ word? ] [ quotation? ] bi or
    [
    dup quotation? not [ ] [ >array [ rec-word-get ] map ] if 
    ] [ drop f ] if ; inline recursive

: actually-using ( vocab -- vocabs )
    words [ def>> >array [ rec-word-home-vocab ] map ] map flatten sift prune >array ;

: used-words ( vocab -- words )
    words [ def>> >array [ rec-word-get ] map ] map flatten sift prune >array ;

: vocab+words ( vocabs-seq -- vocab-words-seq ) 
    [ dup words 2array ] map ;

: intersect-words ( vocab+words current-used-words -- vocab+words' )
    '[ first2 _ intersect 2array ] map ;

! this is the main word, to give you the actual info.
! takes a vocab, and generates a list of vocabs and the words used from them (in the given vocab).
: real-word-usage ( vocab -- vocab-words-seq ) 
    dup load-vocab drop
    [ actually-using vocab+words ] [ used-words ] bi intersect-words sort-keys ;

Annotation: note

Author: me
Mode: factor
Date: Tue, 12 May 2009 23:21:30
Plain Text |
oh, just realized it doesn't handle qualifieds.

Annotation: note2

Author: me
Mode: factor
Date: Tue, 12 May 2009 23:23:38
Plain Text |
also, if you re-define a word in your own vocab, it would show you both vocabs that have that word.

Anyway, hope it's still helpful

New Annotation

Summary:
Author:
Mode:
Body: