Dundre32

Untitled

Apr 29th, 2020
324
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Number of partition is mandatory to set, else it will get a memory exception
  2.  
  3. val groupedRDD = sc.parallelize(rdMapped.collect().flatMap{case(k, v) => v.split("\\p{Digit}|\\p{Space}|[\\p{Punct}&&[^']]|(?<![a-zA-Z])'|'(?![a-zA-Z])|\\“")
  4.                                                 .filter(word => word.length > 1)
  5.                                                 .filter(word => !stopWords.contains(word.toLowerCase()))                                            
  6.                                                 .map(x => (k + " " + x.toLowerCase(), 1))},
  7.                                                 100) //THIS IS WHAT WE NEED TO SET
  8.  
  9.  
  10. val redByKey = groupedRDD.reduceByKey((a, b) => a + b)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×