Function frequency: Difference between revisions

J: supply some missing code and count more thoroughly (previously comments would "eat almost everything")
(J: supply some missing code and count more thoroughly (previously comments would "eat almost everything"))
Line 912:
 
<lang j>
IGNORE=: ;:'y(0)1',CR
PRIMITIVES=: ;:'! !. !: " ". ": # #. #: $ $. $: % %. %: & &. &.: &: * *. *: + +. +: , ,. ,: - -. -: . .. .: / /. /: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: : :. :: ; ;. ;: < <. <: = =. =: > >. >: ? ?. ...'
 
Filter=: (#~`)(`:6)
 
NB. monadextract top10tokens .from a ylarge isbody anewline character vectorterminated of much j source codetext
roughparse=: ;@(<@;: ::(''"_);._2)
top10=: 10 {. \:~@:((#;{.)/.~@:(e.&PRIMITIVES Filter@:;:))
 
NB. count frequencies and get the top x
top10 JSOURCE NB. JSOURCE are the j Zeckendorf verbs.
top10top=: 10top=: {. \:~@:((#;{.)/.~@:(e.&PRIMITIVES Filter@:;:))
┌─┬──┐
 
│6│=.│
NB. read all installed script (.ijs) files and concatenate them
├─┼──┤
JSOURCE=: ;fread each 1&e.@('.ijs'&E.)@>Filter {."1 dirtree jpath '~install'
│5│=:│
 
├─┼──┤
10 top (roughparse JSOURCE)-.IGNORE
│4│@:│
┌─────┬──┐
├─┼──┤
│3│~│49591│,
├─────┼──┤
├─┼──┤
│3││40473│=:
├─────┼──┤
├─┼──┤
│3│+│35593│;
├─────┼──┤
├─┼──┤
│34096│=.│
│3│$ │
├─────┼──┤
├─┼──┤
│24757│+ │
│2│|.│
├─────┼──┤
├─┼──┤
│18726│" │
│2│i.│
├─────┼──┤
├─┼──┤
│2│/│18564│<
├─────┼──┤
└─┴──┘
│18446│/ │
├─────┼──┤
│16984│> │
├─────┼──┤
│14655│@ │
└─────┴──┘
</lang>
 
6,962

edits