Skip to content

Instantly share code, notes, and snippets.

@tatesuke
Created May 16, 2016 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatesuke/ee415c57221e8e6cafd34d10aa0ecf55 to your computer and use it in GitHub Desktop.
Save tatesuke/ee415c57221e8e6cafd34d10aa0ecf55 to your computer and use it in GitHub Desktop.
javadoc_words groovy
def words = []
def input = new File("org.txt")
input.eachLine {
it.split(" ").each {it2 ->
it2 = it2.toLowerCase()
.replaceFirst(/^\(/, "")
.replaceFirst(/\)$/, "")
.replaceFirst(/^\"/, "")
.replaceFirst(/\"$/, "")
.replaceFirst(/,$/, "")
.replaceFirst(/\.$/, "")
.replaceFirst(/:$/, "")
.replaceFirst(/;$/, "")
.replaceFirst(/\?$/, "")
words.push(it2)
}
}
words.sort()
def wordCount = [:]
def current = "";
words.each {
if (it != "" && it == current) {
wordCount[current]++
} else if (it != ""){
current = it
wordCount.put(current, 1);
}
}
wordCount.sort({kv1, kv2->kv2.value-kv1.value}).each { key, value ->
println "${key}\t${value}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment