Created
November 30, 2021 08:43
-
-
Save uzilan/927d3e96e175022e85e382c725218360 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
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