Skip to content

Instantly share code, notes, and snippets.

@uzilan
Created November 30, 2021 09:52
Show Gist options
  • Save uzilan/e934ca9c8bc01053999dd087f99fa991 to your computer and use it in GitHub Desktop.
Save uzilan/e934ca9c8bc01053999dd087f99fa991 to your computer and use it in GitHub Desktop.
package zer.ubba.bel
class GroovyBible {
private final def boringWords = "the,and,of,to,that,for,in,i,his,a,with,it,be,is,not,they,thou"
.split(",");
def readTheBible() {
def resource = ClassLoader.getSystemResource("bible.txt")
return resource
.readLines()
.collect { it.split(" ") }
.flatten()
.collect { it.toString() }
.findAll { it.matches("^\\w+") }
.collect { it.toLowerCase() }
.findAll { !boringWords.contains(it) }
.countBy { it }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment