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 ;