Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.34 KB | None | 0 0
  1. def flip(k:Any,v:Any):(Any,Any) = (v,k)
  2.  
  3. val word_count = words map {sentWords => sentWords map (w => (w.toLowerCase,1))} flatMap {ws => ws} reduceByKey (_ + _) map { case (k,v) => (v,k) } //works ok
  4.  
  5. val word_count = words map {sentWords => sentWords map (w => (w.toLowerCase,1))} flatMap {ws => ws} reduceByKey (_ + _) map flip //doesnt work
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement