Skip to content
W. Marañon
  1. Home
  2. Projects
  3. Analysis

Python · NLP · BERTopic · RoBERTa

Semantic Analysis of Donald Trump's Posts

Temporal, textual and thematic patterns in Donald Trump's posts on X/Twitter and Truth Social from 2009 to 2026, with a topic model chosen by metrics and a validated sentiment score for every post.

Tool
Python
Data
X · Truth Social · CNN's Truth Social archive
Period
4 May 2009 – 29 Oct 2026

Summary

This analysis studies Donald Trump’s vocabulary, topics and tone based on 97,219 posts published on X/Twitter and Truth Social between 4 May 2009 and 29 October 2026, of which 52,570 contain his own text in English and are not duplicates.

His activity peaked at 12,233 posts in 2020 and intensified on Truth Social, where he posts 165 times per week on average, compared with 96 during his Twitter years, in increasingly long messages.

A topic model, chosen among 108 runs for its coherence, diversity and stability, distinguishes 55 themes, led by rallies and get-out-the-vote calls, endorsements of candidates and thank-you messages.

Sentiment, measured post by post with a model validated against a hand-labeled sample, is slightly positive on average, more negative in 2022 and 2023 and more positive from the November 2024 election onward.

Data and cleaning

The database combines an archive of X/Twitter posts from 2009 and Truth Social posts through 8 January 2026, with CNN’s public Truth Social archive, which extends the series through 29 October 2026, and in the period they share the first prevails because it keeps 731 deleted posts that CNN no longer records. By contrast, no free source was found for posts on X after January 2026, which are left out of the analysis (he published 603 on that network between 2023 and 2025).

Each post is identified by the number in its URL and dated with the time that number encodes, converted to US Eastern time, which corrects about 630 tweets recorded in UTC.

Cleaning removes links (including those that Truth Social splits with spaces), image and video markers, garbled characters and the “President DJT” signature that closes many recent posts. Manual quotes of fans, frequent between 2012 and 2015, are reduced to Trump’s comment and treated as reposts when there is no comment or it cannot be separated reliably.

As a result, the 97,219 posts break down into 52,659 originals, 4,931 quotes with his own comment, 24,510 reposts and 15,119 with only a link, an image or a video, and of the 57,590 with his own text, 5,007 exact duplicates and 13 written in other languages are discarded, leaving 52,570 posts for the analysis.

When and how much he posts

The volume of his posts grew with his political career, from 871 in 2011 and 8,363 in 2013 to a peak of 12,233 in 2020, the year of the pandemic and the election, when he published 502 posts in a single week, from June 1 to 7.

The suspension of his Twitter account on 8 January 2021 interrupted the series until his first Truth Social post in February 2022, and since then he has posted more than before, with 165 posts per week on average compared with 96. The mix also changed, as reposts fell from 30% of his posts on Twitter to 18% on Truth Social, a platform where posts with only a link, an image or a video are common.

Posts per year, by whether they have his own text, only a link, image or video, or are reposts.
Posts per year, by whether they have his own text, only a link, image or video, or are reposts. Full size
Posts per week from 2009 to 2026, with their 13-week moving average and some milestones.
Posts per week from 2009 to 2026, with their 13-week moving average and some milestones. Full size

As for timing, he posts mostly on weekdays, with Tuesday as his most active day on both platforms, although his busiest hour moved from 8 in the morning on Twitter to 11 on Truth Social. The share of night-time posts, between 10 at night and 6 in the morning, stayed between 17% and 18%, while the share posted on weekends rose from 23% to 26%.

Distribution of posts by day of the week and hour of the day, in US Eastern time.
Distribution of posts by day of the week and hour of the day, in US Eastern time. Full size

How he writes

The length of his messages followed each platform’s limits: the median went from 16 words under the 140-character limit to 33 when Twitter doubled it in November 2017, and on Truth Social it stayed at about 30 words until 2024 before rising to 46 in 2025 and 48 in 2026.

Words per post with his own text: quarterly median and middle half of posts.
Words per post with his own text: quarterly median and middle half of posts. Full size

His vocabulary has a stable core in “great,” the most frequent word in both periods (15% of his Twitter posts and 26% of his Truth Social posts), while on Truth Social “America,” “country,” “election” and “Biden” gain weight, as do “complete” and “total,” which come from the formula he uses to endorse candidates (“Complete and Total Endorsement”).

The 15 most frequent terms on each platform, as a share of the posts that use them.
The 15 most frequent terms on each platform, as a share of the posts that use them. Full size

Mentions of his rivals mark each period: Barack Obama appears in 24.6% of his posts in 2012, Hillary Clinton in 16.5% of those in 2016, Joe Biden in 18.1% of those in 2023 and Kamala Harris in 12.7% of those in 2024.

Share of each year’s posts that mention Obama, Clinton, Biden or Harris.
Share of each year’s posts that mention Obama, Clinton, Biden or Harris. Full size

What he talks about: topic model

The themes were identified with BERTopic in the 48,139 posts with at least five words, since shorter ones are reactions such as “Thanks!” without a defined topic. The method turns each post into a vector with a language model (embedding), reduces its dimensions with UMAP, groups similar posts with HDBSCAN and describes each group with the words that best distinguish it (c-TF-IDF, refined with KeyBERT and MMR).

The configuration was chosen based on topic coherence (NPMI), word diversity, the share of posts without a topic and stability across seeds, among 108 runs that combine three embedding models (MiniLM, MPNet and BGE) with 12 HDBSCAN settings and three seeds. Among configurations with 30 to 80 topics, the three models were practically tied, with a quality (coherence times diversity) between 0.173 and 0.176, and MiniLM with clusters of at least 200 posts scored highest.

Coherence and diversity of the 36 configurations compared, averaged over three seeds; the ring marks the chosen one.
Coherence and diversity of the 36 configurations compared, averaged over three seeds; the ring marks the chosen one. Full size

The final model distinguishes 55 topics and, as is common with short texts, initially left 30% of the posts without a topic, a share that fell to 5.8% when a post was moved to its closest topic only if it resembled that topic as much as 90% of the posts already assigned did. Rallies and get-out-the-vote calls form the largest topic (6.8% of posts), followed by endorsements of candidates (4.3%) and thank-you messages (4.0%).

The 15 topics with the most posts, with their share of all modeled posts.
The 15 topics with the most posts, with their share of all modeled posts. Full size

Each theme has its peak year: Obama in 2012 (15.9% of his posts that year), thank-you messages to fans in 2013 (16.3%), business advice in 2014 (15.9%), rallies in 2016 (25%), Russia and the Mueller probe in 2018 (10.3%), trials and prosecutors in 2023 (14.8%) and endorsements of candidates in 2026 (17.3%).

Share of each year’s modeled posts in each of the 15 main topics.
Share of each year’s modeled posts in each of the 15 main topics. Full size

The topic map and the similarity matrix group these themes into families: attacks on the press, the trials and the Mueller probe form a very close block (similarity of 0.67 to 0.77); polls, Democrats and Republicans, Biden and Obama, another; and thank-you messages, interviews and rallies, a third.

Map of the 55 topics: nearby topics have similar content and size shows how many posts they have.
Map of the 55 topics: nearby topics have similar content and size shows how many posts they have. Full size
Similarity among the 15 main topics, ordered by related groups.
Similarity among the 15 main topics, ordered by related groups. Full size

What tone he uses: sentiment

Sentiment was measured with Cardiff NLP’s RoBERTa model trained on tweets (twitter-roberta-base-sentiment-latest), which, applied to the text with its capital letters, punctuation and emojis, assigns each post its most likely class and a score between −1 and 1, equal to the probability that it is positive minus the probability that it is negative.

To measure its accuracy, a random sample of 200 posts was labeled by hand without seeing the model’s answer, and the model agrees with the manual label in 63% of the 191 that keep the same text in the corpus (95% confidence interval between 57% and 70%, macro F1 of 0.61). Its most frequent error is reading enthusiastic announcements as positive when the manual label considers them neutral.

Neither a larger model (j-hartmann’s RoBERTa-large), nor the average of both, nor thresholds tuned to the sample improved F1 by two points or more, the criterion set in advance, so the Cardiff model, which is useful for comparing periods and topics rather than for judging individual posts, was kept.

Overall, 43.5% of posts are positive, 37.2% negative and 19.4% neutral, with a mean score of 0.095, somewhat higher on Twitter (0.109) than on Truth Social (0.061).

The most negative years were 2022 and 2023 (in 2023, more than half of his posts were negative, when trials and prosecutors took up 14.8% of what he posted) and the most positive were 2025 and 2026, with 54% and 50% positive posts. The most positive month in the whole series is December 2024, after the election, and the most negative is November 2011.

Mean sentiment score per month, with its 95% confidence interval.
Mean sentiment score per month, with its 95% confidence interval. Full size
Share of positive, neutral and negative posts in each year.
Share of positive, neutral and negative posts in each year. Full size

Tone depends above all on the topic: endorsements of candidates (0.73), rallies (0.71) and TV interviews (0.64) are the most positive topics, and the “fake news” media (−0.62), the Mueller probe (−0.59) and trials and prosecutors (−0.58) the most negative. Among his rivals, posts about Biden (−0.50) are more negative than those about Obama (−0.42).

By contrast, there is no relationship between how much he posts and his tone, since over 734 weeks the correlation between the number of posts and their mean score is 0.06 and is not significant (p = 0.10).

Mean sentiment score of the 15 main topics, with its 95% confidence interval.
Mean sentiment score of the 15 main topics, with its 95% confidence interval. Full size