Created
December 27, 2018 15:35
-
-
Save anmol2709/be712847518264e6363f24cdc9f0b695 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
val counts: DataStream[(String, Int)] = text | |
// split up the lines in pairs (2-tuples) containing: (word,1) | |
.flatMap(_.toLowerCase.split("\\W+")) | |
.filter(_.nonEmpty) | |
.map((_, 1)) | |
// group by the tuple field "0" and sum up tuple field "1" | |
.keyBy(0) | |
.sum(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment