Skip to content

About

Codes to analyize language bubbles in social networks.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

LANGUAGE BUBBLES ANALYSIS FOR TWITTER DATA

(by Alessandro Bellina, Gabriele Di Bona, and Emanuele Brugnoli)

This repository analyzes Twitter data to detect language bubbles in social networks. The scripts build the retweet network of users on Twitter and then partition them into communities using hSBM and Louvain algorithms. The content of the tweets is then analyzed to compute lexical metrics for each user and community. Finally, a sampling analysis is performed to obtain the final results. In addition, code for testing the lexical metrics and for computing the null models is provided.

DATASET

Our analysis is based on Italian tweets from politicians and news outlets, spanning from 2018 to 2022. In the tweets_id folder, we report the IDs of all the tweets used in the analysis, organized by year.
To replicate the analysis, one should reconstruct the dataset of tweets starting from these tweet IDs. It is also necessary to create two files: retweets.csv (each row is a retweet), and twitter_users.csv (each row is a user), corresponding to the same tweets whose IDs are reported in the folder.

CREATE TOPICS

create_topics.ipynb extracts tweets for each specific topic, starting from the general dataset described above.

RETWEET NETWORK

retweet_analysis.ipynb creates the bipartite retweet network, projects it, computes the clustering partition with Louvain, and computes the inverse distance matrix on the retweet network.

LEXICAL METRICS

lexical_metrics.ipynb lemmatizes and removes stopwords from tweets, removes the kernel lexicon, computes the validated projection, the Jensen-Shannon distance matrix, and the lexical metrics (entropy, vocabulary size, completeness).

HSBM CLUSTERING

hsbm_clustering.ipynb computes the community partitioning via the hSBM algorithm.

SUBSAMPLING ANALYSIS

sampling_analysis.ipynb performs the final subsampling analysis and generates the files for the figures.

FIGURES

figures.ipynb and fig_network.ipynb generate the final figures shown in the paper.

NULL MODELS

The null_model folder contains all scripts for performing the null model analysis.

TEST METRICS

The test_metrics folder provides code for testing the lexical metrics on texts of varying complexity (from Gutenberg).

Reference

If you use any of the material provided here, please cite our work using the following BibTeX entry:

@article{TODO,
  title={Language bubbles in online social networks},
  author={Bellina, Alessandro and Lo Sardo, Ruggiero and Brugnoli, Emanuele and Saracco, Fabio and Gravino, Pietro and Loreto, Vittorio and Di Bona, Gabriele},
  journal={TODO},
  year={2025},
  doi={TODO}
}

About

Codes to analyize language bubbles in social networks.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages