Word frequency count FIXED by hoozie

m=[:];s="";p={if(s){m[s]=(m[s]?:0)+1;s=""}};System.in.each{c=it<91?it+32:it;if(c>96&&c<123)s+=c as char;if(it==32)p();};p();m.entrySet().sort{it.key}.any{println it.value+" "+it.key}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page