Skip to content

Instantly share code, notes, and snippets.

@alaz
Forked from jorgeortiz85/showWordCloud.scala
Created September 15, 2009 11:28
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 alaz/187235 to your computer and use it in GitHub Desktop.
Save alaz/187235 to your computer and use it in GitHub Desktop.
case class Word(word: String, count: Long) {
override def toString = word + ": " + count
def +(n: Long): Word = Word(word, count + n)
}
private def showWordCloud {
val words = statusTableModel.filteredStatuses.flatMap(_.text.split("\\s"))
val emptyMap = immutable.Map.empty[String, Word].withDefault(w => Word(w, 0))
val counts = words.foldLeft(emptyMap)((map, word) => map(word) += 1)
val countList = counts.values.toList.sort(_.count > _.count)
log.info(countList)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment