Commits

Doug Burke committed 45b5715

Include the number of tweets that contain publisher info in the output

Comments (0)

Files changed (1)

     , Int  -- ^ number of accounts that *only* retweeted
     , Int  -- ^ number of tweets
     , Int  -- ^ number of retweets
+    , Int  -- ^ number of tweets that included the publisher information
     , Hist -- ^ retweet histogram
     , Hist -- ^ user tweet histogram
     , Hist -- ^ user retweet histogram
       convPublisher = fromJust . (`lookup` publisherInfo)
       pCount = map (fmap convPublisher) publisherCount
       
+      nPub = foldl' (\c ctr -> c + _count ctr) 0 publisherCount
+
   return ( M.size countMap
          , M.size onlyRetweetMap
-         , ntws, nrtws
+         , ntws, nrtws, nPub
          , toHistogram retweetCount
          , toHistogram userTweetCount
          , toHistogram userRetweetCount
 displayCount :: 
     QueryResponse
     -> IO ()
-displayCount (n, nrtonly, ntws, nrtws, rtwHist, utwHist, urtwHist, _, _, rtStatus, repliedUser, garrulousUser, rtUser, mUser, mHT, mURL, mPub, _, uMap, ftime, ltime) = do
+displayCount (n, nrtonly, ntws, nrtws, nPub, rtwHist, utwHist, urtwHist, _, _, rtStatus, repliedUser, garrulousUser, rtUser, mUser, mHT, mURL, mPub, _, uMap, ftime, ltime) = do
   putStrLn $ ">> Number of tweeters: " ++ show n
   putStrLn $ ">> Number of tweeters that *only* retweeted: " ++ show nrtonly
   putStrLn $ ">> First tweet: " ++ show ftime
   putStrLn $ ">> Last tweet:  " ++ show ltime
   putStrLn $ ">> Number of tweets: " ++ show ntws ++ " Number of retweets: " ++ show nrtws
+  putStrLn $ ">> Number of tweets that included a publisher: " ++ show nPub
   putStrLn "*** Most retweeted statuses"
   forM_ (fromCL rtStatus) $ \(Counter obj cnt) -> putStrLn $ show cnt ++ " status=" ++ show obj
   putStrLn "*** Most replied-to user"
 displayAsJSON ::
     QueryResponse
     -> IO ()
-displayAsJSON (n, nrtonly, ntws, nrtws, rtwHist, utwHist, urtwHist, rtwDelta10MinHist, rtwDelta6HourHist, rtStatus, repliedUser, garrulousUser, rtUser, mUser, mHT, mURL, mPub, friendCount, uMap, fTime, lTime) = do
+displayAsJSON ( n, nrtonly, ntws, nrtws, nWithPub
+              , rtwHist, utwHist, urtwHist, rtwDelta10MinHist, rtwDelta6HourHist, rtStatus, repliedUser, garrulousUser, rtUser, mUser, mHT, mURL, mPub, friendCount, uMap, fTime, lTime) = do
   let fixUser = map (replaceUserId uMap) . fromCL
 
       toF (nfr,nfoll,nt,nrt) = object [ "follow" .= nfr
                    , "uris" .= fromCL mURL
                    , "hashtag" .= fromCL mHT
                    , "publisher" .= fromCL mPub
+                   , "numWithPublisher" .= nWithPub
                    , "followerCount" .= map toF friendCount
                    ]