otm:the_matching_of_causal_sequences:example1

This is an old revision of the document!


A kind of W2As are social networks applications like Twitter and Facebook. Nowadays, these applications are widely used, thereby, the analysis the flow of information is an interesting research topic. This flow of information is analyzed trough messages sent and retrieved between users of these applications. This analysis is complex because it is necessary to reason about the distributed computations of a social networks application. Next, we present the analysis of popularity of a tweet (a publication of a small post) in Twitter.

 Tweets & Retweets

The analysis of popularity of user tweets is a novel topic in Twitter. This analysis allows a user to know the popularity of every tweet published by him, which is measured by the number of retweets (republications of a tweet) that its followers do of his tweet. For example, the figure shows above four Tweeter users: Toti, Peter, Kuky, and Paul. Toti follows Peter and Peter follows Paul; Kuky follows nobody and vice versa. On the one hand, the figure also shows that Paul publishes a tweet and Peter receives this tweet and retweets it. On the other hand, the figure also shows that Kuky publishes a tweet and nobody receives it. Based on the popularity measurement, the popularity of the Paul’s tweet is one and the Kuky’s tweet is zero. Although Kuky and Paul would have published the same tweet (the same string), the popularity of Kuky is zero because the Kuky’s tweet does not cause any retweet. Commonly, this kind of analysis is carried out through dynamic graphs. Sadly, this analysis is not at real-time and is complex when social networks contains a big amount of users. An alternative way is the use of the vector clock algorithm. We use WeCa to analyze the popularity of every tweets of a user when the midnight event happens.

Toggle between the code and example

The popularity of a tweet is carried out by the following sequence:

var countRetweet = causalSeq(callTweet, repeatUntil(eventRetweet, event("midnight")))

This sequence matches and counts all retweets of a tweet until the midnight event happens. The retweets that are considered must be caused by a tweet received. This sequence begins the matching process when the callTweet pointcut matches:

var callTweet = call(tweet).and(function(jp, env){
    return env.bind("idT", jp.args[0]).bind("counter", 0);
});

This pointcut matches the call of the tweet function and returns an environment that contains the id of the tweet and a counter initialized to zero. This counter is used to count the retweets of a tweet. Whenever callTweet matches, the callRetweet pointcut could match several times:

var eventRetweet = function (jp, env){
    return jp.isCustom("retweet") && geTweet(jp) == env.tweet ? 
             env.bind("counter", env.counter + 1) : false;
};    

This pointcut matches the retweet event. This event is the notification of a call to the retweet function that happened in another machine/application. The retweet of this event must be the same (ie the same string) that the environment contains. If this pointcut matches, it returns an environment that contains the counter incremented by one. This pointcut matches retweet events until the midnight event happens, meaning that the sequence matches.

A user commonly publishes several tweets, then it is necessary to have several sequences that matches, ie. one sequence by every different tweet. For example, if a user publishes the tweet m1 twice and m2 once, we only need a sequence for m1 and a sequence for m2 to analyze the popularity of all tweets of the user. To achieve this goal, it is necessary to spawn a new sequence by every different tweet. WeCa, through OTM , allows us to spawn sequence when a different tweet is published:

var newPosts = function(steps, index, env, jp){
    var currentEnvs = this.getCurrentEnvs(index);
 
    return !currentEnvs.some(function(currentEnv){ //returns true if some condition is not satisfied
        return getTweet(currentEnv.idT) == getTweet(env.idT);
    });
};

Finally, the definition and deployment of the tm that analyzes the popularity of posts is:

var tm = {
    kind: AFTER,
    seqExp: countRetweet,
    advice: function(jp, env){
        addPopularity(env.idT, env.counter);
    },
    spawn: newPosts
};
deploy(tm);

Go the parent Web page.

  • otm/the_matching_of_causal_sequences/example1.1297091192.txt.gz
  • Last modified: 2011/02/07 11:06
  • by aspectscript