Created
August 25, 2015 21:56
-
-
Save juanpampliega/178fa08ed6c7a3e91cbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val docs = sc.textFile("/opt/dataset/don-quijote.txt.gz") | |
val lower = docs.map(line => line.toLowerCase) | |
val words = lower.flatMap(line => line.split("\\s+")) | |
val counts = words.map(word => (word, 1)) | |
val freq = counts.reduceByKey(_ + _) | |
val invFreq = freq.map(_.swap) | |
invFreq.top(20).foreach(println) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment