Search form


Ahead of the Senegalese Presidential Elections : Taking the Temperature from Twitter Mining

Ihssane Guennoun , Zainab Adel | February 22, 2019

As Senegalese population are due to join the polls on Sunday February 24th, 2019 to elect their next president, several voters are turning to social networks to express their thoughts. While social networks penetration rates are not public information in Senegal, looking at the interactions online can be interesting. For this paper, our focus will be on Twitter where most of the action happens ahead of the elections. Our analysis will put the emphasis on two candidates: Ousmane Sonko and Macky Sall. The reason for us restraining our analysis to these two candidates finds its justification in a few elements. First, we obviously had to consider the outgoing president who has the advantage of his current position. He is also present on Twitter, which provided us with an interesting amount of data to analyze. Second, we chose to focus on Ousmane Sonko as the recent political newborn in Senegal. He surprised many observers during the last legislative elections. In addition, he breaks away from traditional rules by importing the political debate on Twitter, which is not common in Senegal.

Based on data mining conducted from November 24, 2018 to February 14, 2019, we tried to draw the main tendencies from how candidates tweet about themselves and how others tweet about them. Given the time range of the data collection, all numbers are exact at the end of the collection date. As Senegal is a democratic country when it comes to freedom of speech, the tweets we have used in our analysis are not censored. Our objective is not to say which of the two candidates is the most influential but rather, to analyze their interactions with the other users. We will essentially use two models to conduct our analysis. The first one is a sentiment analysis while the second one is a word cloud.

We will start by presenting the two candidate’s profiles on Twitter, which will, in turn, help us understand how they compare.

Ousmane Sonko has been on Twitter for less than a year (341 days) and has 20,006 Followers while Macky Sall has 8.83 years of Twitter presence with 843,782 Followers. When it comes to their tweets, Macky Sall has 2,116 and Ousmane Sonko has 356 tweets. Based on those numbers, there is indeed an initial difference between both candidates. Later on, we will see how this difference translates into perceptions from Twitter users. When it comes to the number of tweets analyzed about every candidate, we used 7707 tweets mentioning “Ousmane Sonko” and 35,264 mentioning “Macky Sall.” Hence, the percentages obtained in the following analysis are based on these last numbers of tweets. In other words, 1% of tweets mentioning “Ousmane Sonko” is equal to 77,07 tweets, while 1% of tweets mentioning “Macky Sall” account for 352,64 tweets.

  I. Emotions and Words: a general perspective

A) Sentiment Analysis

This tool helps us look at the various emotions conveyed in different tweets. The library in R1 that we are using has ten different emotions: Anger, Anticipation, Trust, Positive, Negative, Fear, Joy, Sadness, Surprise and Disgust. In the first part, we will analyze the emotions that come out of every candidate’s tweets. In the second part, we will contrast it with emotions that come out from Twitter users speaking about both candidates.


 As table 1 shows, the predominant emotion that comes out both candidate’s own tweets is a positive emotion. It does not come to us as a surprise when we know that both of them are eager to communicate positive emotions to the public. We also notice that Ousmane Sonko’s negative emotions come second in all of his tweets (14.98%). One of the reasons behind this is that he uses lots of criticism, especially towards his main rival. In addition, Ousmane Sonko has recently been accused of misappropriating of 94 Billion FCFA2. However, Ousmane Sonko strongly denies such accusations that he believes are meant to destabilizing his candidacy. In opposition to that, the outgoing candidate has trust as the second emotion conveyed from his own tweets. It is indeed significant given his comfortable position as current president. His current position provides him with a number of benefits. The emotion of trust in most of Macky Sall’s tweets makes sense, as he personally trusts several people surrounding him. This same emotion scores 14.55% within Ousmane Sonko’s personal tweets, which is quite interesting as well.

It would be interesting to look at emotions conveyed from users tweeting about both candidates. There is no doubt that positive emotions prevail for both candidates as users tweet about them. However, looking at negative emotions, we notice that there are less negative emotions in tweets about Ousmane Sonko than from his own tweets. On the opposite, there are more negative emotions in tweets about Macky Sall than there are from his own tweets. Keeping in mind that we analyze emotions based on percentages and not based on the number of tweets. As for trust, there are fewer tweets about Macky Sall conveying this emotion than in his own tweets. While for Ousmane Sonko, we perceived more trust in tweets about him than in his own tweets.

  B) Word Clouds

Both candidates rank on Social Authority, which is a tool providing the virtual influence of a Twitter user. It essentially looks at the latest two months of activity of an account to assess its weight on a scale of 100. Surprisingly, both candidates rank pretty above average and are only 11 points away from each other. Macky Sall’s account ranks 72/100 while Ousmane Sonko’s account stands at 61/100. Given their comfortable ranking, we believe their actual tweets could be interesting to analyze from a wording perspective. Beyond looking at emotions conveyed, we wanted to see which kind of words they use in their tweets and which ones users talking about them use. For this purpose, we generated four world clouds to get a better sense of the frequent words. The bigger the word, the more it is used for tweets. We removed mentions to “Ousmane Sonko” and “Macky Sall” in their own tweets to avoid distortions of the word cloud.


The previous word cloud show some interesting trends. “Senegal” obviously appears in the four word clouds. Yet, the next section will come up with explanations on how the country’s name actually ranks differently in both candidates’ word cloud. Interestingly, we notice that the word “Presidentielle” is present in three out of four word clouds. In fact, the word almost never appears in Macky Sall’s own tweets as if it is not an important word to highlight. When we correlate the absence of “Presidentielle” from his own tweets with the “anticipation” emotion ranking 9.94% in the sentiment analysis (Table 1), we may have the feeling that he is quite confident about his reelection. In addition, the use of “J’ai”3 in figure 2 adds to this confidence. When it comes to Ousmane Sonko’s word cloud, both of them have mentioned “Macky Sall”, which reveals that the outgoing president is very much present in Sonko’s discourse. It is particularly the case since Ousmane Sonko has been criticizing the tenant of the 'Palais de la République' mainly about his management of the country’s oil resources. The fact that the word “cartes sur table”4 comes often from Sonko’s tweet reflect his several calls for a live debate between the five presidential candidates. However, the initiative failed shortly after the National Council for Audiovisual Regulation disapproved the initiative5.

   II. Analysis of most powerful words and most influential users

A) Top twenty words used by and about every candidate

Based on the previous word cloud, we wanted to look at the top 20 words used by every candidate and about every candidate. Looking at these tables below (Table 2 and Table 3) provides us with interesting insights. The first one, the name of the country is the top one word in tweets about “Macky Sall” and tweets by the outgoing president. Whereas for Ousmane Sonko, the country’s name comes in the second place after two other words.

If we compare the two candidates’ original tweets, we can say that, on the one hand, Macky Sall’s predominant words refer to action words such as “publie”, “visite”, “meeting”, “sommet” . On the other hand, words relating to the elections themselves dominate Ousmane Sonko’s original tweets. He often uses words such as “sonkopresident”, “jotna” , “presidentielle”, “senegalais”. It is quite surprising to see, however, that during the time range of our data mining, Ousmane Sonko did not refer to oil issues in his tweets while being aware that it is an essential component of Senegal’s future.

When we look at tweets about both candidates, there are a few differences to take into consideration. Twitter users mentioning “Ousmane Sonko” speak about “Sall” at the first place, followed by “Senegal” then by “Macky”. It is only at the fifth and sixth rank that “Presidentielle” and “candidat” comes in, which could reveal that speaking about Ousmane Sonko has to be done in opposition to his main rival. However, users mentioning “Macky Sall” use “Senegal,” “President,” “Presidentielle” and “Candidat” as their top words. It is worth noting that “Sonko” ranks fifth amongst the words used when mentioning “Macky Sall”.

Both Tables 2 and 3 provide us with additional information that we can compare. The word cloud provides us with interesting trends to better understand the stakes of Sunday 24 February’s elections.

B) Top thirty followers of each candidate

Yet, our work would not be complete without answering the following questions: Who are the Twitter users mentioning both candidates? Based on their number of followers, can we say that they are influential? Where do they tweet? How many tweets or re-tweets did they have with mentions to one of the two candidates? Which main emotions do they convey from their tweets about our candidates? While we did have access to their public profiles, we will preserve their anonymity and use numbers to refer to them. Our purpose is to assess the influence of the users speaking about both Macky Sall and Ousmane Sonko. In fact, a very influential account can only tweet once and have more impact than a less influential account who could be tweeting more.

We classified users based on two types: press and individual accounts. What we can see is that, out of the 30 most influential accounts, five of them are individual accounts following APR's candidate. On the opposite, ten individual accounts follow Ousmane Sonko out of the 30 most influential accounts. It is not surprising to see the important place of Press on Twitter since freedom of the press in Senegal is not an illusion. Looking at emotions conveyed by those influential accounts is interesting. In fact, even if an influential user tweets only once about one of the two candidates, his tweet can have an impact given the big number of followers. In other words, if an influential account tweets one positive tweet about one of the candidates, it will have a strong impact in comparison with a less influential user who would be tweeting more with, for example, negative emotions.

Both Tables 4 and 5 provide us with the emotions that come out the most from the various tweets by every user. There are in fact mixed emotions for both candidates and it would not be relevant to come up with a specific analysis. We leave it to the appreciation of the reader to compare how most influential users speak about every candidate.


As much as we try to bring in trends ahead of the Senegalese presidential elections, there are some limitations to our data-mining and analysis model. The first limitation relates to the Twitter penetration rate in Senegal. Twitter does not actually publish official statistics about the use of this social network. Hence, it is difficult to compare the number of Twitter users to the ones engaged in the virtual debate about both candidates. The information that we have is that there are 9.6 Million people with internet access in Senegal6. We do not believe all of those people have Twitter and even if they do, a few of them actually interact on Twitter to express their thoughts about “Ousmane Sonko” and “Macky Sall”. In addition to that, most of the Senegalese electorate resides in rural areas with maybe less internet access than the urban electorate.

The second one relates to sentiment analysis. In fact, the library of emotion that we use does not recognize sarcasm that can be misleading. In addition, it does not recognize the Wolof language. Consequently, we were not able to carry out an emotion analysis based on Wolof words.

The last limitation lies in the fact that the number of tweets analyzed for every candidate is different. Furthermore, depending on the reader’s lenses, he can interpret the data in different ways. Hence, our aim is not to come up with a prediction about the outcome of the presidential election but to provide the reader with the temperature on Twitter ahead of the elections.


As a conclusion, it is interesting to see that Twitter can be a metaphor for Election Day. In fact, one of the key indicators where a question mark hangs is the expected participation rate. Indeed, since Abdoulaye Wade came back to Dakar on February 7, 2019, he has been actively calling on voters to boycott the elections7. He believes the elections should not take place since his son, Karim Wade, was not able to run for the presidency. It is true that Abdoulaye Wade, former Senegalese president, does have some influence in the country, especially, amongst the Mouridiya religious community. However, the participation rate will reveal whether his influence still holds strongly or not. It is unlikely that his call for boycotting will have a major influence. Nonetheless, the participation rate will be a major indicator to assess the next president’s weight amongst the population. If the next president is elected with a high percentage but with a low participation rate, it could question his legitimacy as few people actually voted for him. In opposition to that, if the polls elect the next president with an average percentage but with a reasonable participation rate (around 50%), it would give him more legitimacy during his mandate.

To conclude on a final thought, there is an interesting parallel to draw between Twitter and the real-life of the Senegalese electorate. Let us take as a starting point the number of people with internet access and consider that they refer to the people who registered to vote for the elections. The second element is the number of people who actually participate in the political debate about both candidates on Twitter who refers to the people who will effectively go to the polls to vote. The participation rate in real-life equals to the percentage of those who registered to vote and who will join the polls on Sunday. While the participation rate on Twitter is the percentage of those who have internet access and who speak about one of the two candidates on Twitter. In both cases, we will see that there is a gap in the participation in the political life whether in real or online. The number of tweets that we were able to analyze reveals how little people engage online compared to the number of people who have internet access in the country. As we recall from the last presidential elections in 2012, the participation rate was at 55% for the second round, which is slightly above half of the electorate. For this year’s election, there is a chance that the participation rate could be similar to that of the previous election.