Last active
December 26, 2015 00:08
-
-
Save mcohen01/7061517 to your computer and use it in GitHub Desktop.
top letters
This file contains hidden or 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
import scala.util.matching.Regex | |
import sys.process._ | |
val str = "curl http://www.giwersworld.org/computers/linux/common-words.phtml" !! | |
val pattern = "<pre>[A-Z\n]*</pre>".r | |
val words = pattern findFirstIn str | |
words.mkString | |
.replace("\n", "") | |
.groupBy(_.toChar) | |
.mapValues(_.size) | |
.toList | |
.sortBy { _._2 } | |
.reverse | |
.take(10) | |
.map { _._1 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment