Skip to content

Instantly share code, notes, and snippets.

@gclaramunt
Last active December 19, 2015 15:48
Show Gist options
  • Save gclaramunt/5978455 to your computer and use it in GitHub Desktop.
Save gclaramunt/5978455 to your computer and use it in GitHub Desktop.
top ten words for a text s
def topN(s:String,n:Int)=s.split(' ').groupBy(identity).map({case (w,ls)=>w->ls.length }).toSeq.sortBy(_._2).reverse.take(n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment