17. [Activity] Counting Word Occurences using Flatmap()
MAP VS. FLATMAP
And the Word Count example
Map() Transform Each Element Of An RDD Into One New Element
Map transform each line into one new element
FlatMap() Can Create Many New Elements From Each One
FlatMap can create many new elements from each line
Code Sample: Count The Words In A Book
Activity
Copy the book.txt from the resource folder into the SparkScala folder
Open up Eclipse-Scala IDE and import WordCount.scala into SparkScalaCourse project
Open up the scala code for WordCount.scala
The function countByValue() is used to count the occurences of each word inside book.txt
When you run the configuration as the specified class and class name, you should see the output displaying the count for each word
The output never account for different capitalizatios and different uni-codes which will be addressed by our scripts for the coming lectures
Previous16. [Activity] Running the Minimum Temperature Example, and Modifying it for MaximumNext18. [Activity] Improving the Word Count Script with Regular Expressions
Last updated