Skip to content

Instantly share code, notes, and snippets.

@uzilan
Created November 30, 2021 08:43
Show Gist options
  • Save uzilan/927d3e96e175022e85e382c725218360 to your computer and use it in GitHub Desktop.
Save uzilan/927d3e96e175022e85e382c725218360 to your computer and use it in GitHub Desktop.
package zer.ubba.bel
import scala.io.Source.fromResource
class ScalaBible {
private val boringWords = ("the,and,of,to,that,for,in,i,his,a,with,it,be,is,not,they,thou")
.split(",")
def readTheBible(): Map[String, Int] = {
val source = fromResource("bible.txt")
source
.getLines
.flatMap(_ split " ")
.filter(_ matches """^\w+""")
.map(_.toLowerCase)
.filter(!boringWords.contains(_))
.toList
.groupBy(identity)
.mapValues(_.size)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment