From 5843d3d60332e52fec2977cfcff6735ba0b8c76e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 15 Apr 2013 14:41:32 +0200 Subject: Scala : TweetSet: implement google and apple tweets trending --- Scala/objsets/src/main/scala/objsets/TweetSet.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Scala/objsets/src/main/scala/objsets/TweetSet.scala b/Scala/objsets/src/main/scala/objsets/TweetSet.scala index f558e48..9e350be 100644 --- a/Scala/objsets/src/main/scala/objsets/TweetSet.scala +++ b/Scala/objsets/src/main/scala/objsets/TweetSet.scala @@ -211,14 +211,16 @@ object GoogleVsApple { val google = List("android", "Android", "galaxy", "Galaxy", "nexus", "Nexus") val apple = List("ios", "iOS", "iphone", "iPhone", "ipad", "iPad") - lazy val googleTweets: TweetSet = ??? - lazy val appleTweets: TweetSet = ??? + lazy val googleTweets: TweetSet = + TweetReader.allTweets.filter(tweet => (google.foldLeft(false)( _ || tweet.text.contains(_) )) ) + lazy val appleTweets: TweetSet = + TweetReader.allTweets.filter(tweet => (apple.foldLeft(false)( _ || tweet.text.contains(_) )) ) /** * A list of all tweets mentioning a keyword from either apple or google, * sorted by the number of retweets. */ - lazy val trending: TweetList = ??? + lazy val trending: TweetList = (googleTweets union appleTweets).descendingByRetweet } object Main extends App { -- cgit v1.1-2-g2b99