French elections viewed through Twitter: a semantic analysis

[This article was first published on Enhance Data Science, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The French presidential election has been over for a week with the win of Emmanuel Macron. During the weeks between the two rounds, Twitter has been really active on French election. In this post, we will see how the French campaign was perceived on Twitter through three events and using semantic analysis.

  • MacronLeaks: En Marche the political party behind Marcon was hacked just before the election weekend. Around 9GB of data allegedly from En Marche were released online.
  • Presidential debate: on the evening of 05/03 the presidential debate of the second round was held between Macron and Le Pen. The debate was widely seen and followed in France and a lot of tweets dealt with it.
  • Election day: Logically during the election evening and night, twitter was crowded with tweet concerning the French election.

Some technicalities

The data were collected from the Twitter streaming API during the french campaign. All analysis are run on between 100 000 and 300 000 tweets, retweets are weighted to count far less than real tweets.
Once the data were collected, tweets were cleaned and a dictionary of words with a frequency between 0.01% and 50% was created.
Then a word embedding was created with the text2vect R library and a 2D representation of the word was build using T-SNE and the R-TNSE library. All plot are done with ggplot and plotly.

Presidential debate

The presidential debate was closer to a fight between Le Pen and Macron than to a real debate with some argumentation. Le Pen was perceived as aggressive and the debate led to 3 to 5 points lost in the polls of the end of the week and hence was not the winner of the debate. On the other hand, Macron performed well and managed to stay calm and to answer Le Pen attacks easily.

Here is the perception map of the debate on Twitter. Words perceived closer to Le Pen are in red and the one in blue closer to Macron. Words in the same cluster/cloud are perceived to be similar to the twitter users, the size a word is proportional to the number of apparitions.

Several clusters appear on the plot, they are homogeneous, clusters on the left tend to be closer to Le Pen while clusters on the other side are closer to Macron.

Let’s explore the main cloud associated to Le Pen.

Main word cloud for Le Pen

Since it is in French, let’s do some translation. This cloud is very negative and contains, for instance, the words: Shame, hate, rubbish, unworthy, robbery, ridiculous, lies … well, these words are biased and negative. However, some words are more objective and linked to Le Pen political agenda such as immigration, french, leave (meaning Frexit).

Now let’s take a look at the main word cloud associated with Macron.

Word cloud concerning Macron

This is far more positive, for instance, it contains the words: win, professional, thanks, congratulation, deserve, support, … He is also seen as close with the medias (TV, BFM TV) , is associated to banking.

Something else worth noticing is that while Le Pen is associated with abstention, Macron is associated to vote. You can easily guess the nature of the tweets with this association: “Abstention will elect Le Pen”, “Vote for Macron to avoid a far-right president”

To conclude, this part: Le Pen debate was perceived very negatively on Twitter while Macron was very positive. Factual opinions are less represented and closely linked to what you would think of each candidate:

  • Le Pen is perceived as more protective, is linked to the change of currency and more conservatism.
  • On the other hand, Macron is perceived as being more open, closer to the media and to Europe.

Macron Leaks

Macron leaks may have a been a last-minute game changer in the French campaign. Just two days before the election, En Marche internal emails and document were leaked (with some fakes added in). The leaks had not much impact on the vote since documents credibility was questionable.Furthermore, they contained tags that let thinks the leak was orchestrated by some Russian hackers.

Here is the perceptual map of the hashtag #MacronLeaks:

First, let zoom on the cloud in the center of the map:

Main Cloud Macron Leak

The Cloud is mainly pro-Le Pen with words like IVoteLePen, chooseYourFrance, patriots, anyoneButMacron, NeverMacron … By these people perceives Macron Leaks as an expression of freedom of speech and of press. They also mention the Bahamas as a reference to the so-called fiscal fraud Le Pen mentioned in the debate.
Furthermore, they seem to consider the leak contains real proof and may compromise Macron election. In this cloud, the proximity of Russian and hackers show that people are aware the leak may come from Russia.

Other are areas of the map are less informative. Still, some conclusions can be made from the overall map:

  • A large part of tweets on Macron Leaks considered them as righteous and a way to fight against the political and economic system embodied by Macron.
  • Some tweets warn that some parts of the leak are fake and call to vote for Macron. They perceived the leaks as the only way for Le Pen to win the election and made a link between Le Pen, Russia and hence Poutine.

Election Day

Data from Election Day were collected from 18 to 23 in the evening.

The tweets from election day are less rich than the other ones. Mostly, Macron is congratulated for his victory which is often perceived positively while Le Pen defeat seems to be positively perceived too.



The post French elections viewed through Twitter: a semantic analysis appeared first on Enhance Data Science.

To leave a comment for the author, please follow the link and comment on their blog: Enhance Data Science. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)