diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-04-15 14:41:32 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-11-10 18:03:23 +0100 |
commit | 5843d3d60332e52fec2977cfcff6735ba0b8c76e (patch) | |
tree | 2cc3df0cb2ea3b0a7c032350943c6bf94e1dd1e5 /Scala | |
parent | 022c591d1ff008041f712e65149670f568404c1a (diff) | |
download | coursera-5843d3d60332e52fec2977cfcff6735ba0b8c76e.zip coursera-5843d3d60332e52fec2977cfcff6735ba0b8c76e.tar.gz |
Scala : TweetSet: implement google and apple tweets trending
Diffstat (limited to 'Scala')
-rw-r--r-- | Scala/objsets/src/main/scala/objsets/TweetSet.scala | 8 |
1 files 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 { |