...
/Feature #5: Drawing a Global Profile of Viral Tweets
Feature #5: Drawing a Global Profile of Viral Tweets
Implementing the "Drawing a Global Profile of Viral Tweets" feature for our "Twitter" project.
We'll cover the following...
Description
For our Twitter application, we want to keep track of the globally viral tweets on a particular day. For this reason, we must keep track of the duration in which a particular hashtag was trending along with its peak number of mentions. We have already collected the data of these top trending hashtags. We have stored the tweets information in the tweets list where
each element in the list i.e., tweet[i]
contains the following:
- starti: The time at which the hashtag started trending.
- endi: The time at which the hashtag stopped trending.
- peak_mentionsi: The number of peak mentions of that hashtag.
For example, in the following illustration, the tweet with the red block started trending at time 2
, stopped trending at 9
and its peak number of mentions was 10
.
You have to draw a global profile of these viral tweets. To understand what a global profile is, let’s have a look at the illustration below. If we replace all different colors of the rectangles with the same color, then the outline we get is the global profile. You can also think about the global profile as the union of two individual rectangles.
It is also possible that at a particular hour, no hashtag is trending because of some interval server problem in data collection.
The global profile should consist of a list of coordinates, sorted by time. It should be in the form of [[x1,y1],[x2 ,y2],…,[xn ,yn]]. Each point in the global profile is the left coordinate of a segment, except the last point, whose y
coordinate will always be 0
...