Code for a research project analyzing online discussion of avian flu (H5N1). It collects Reddit comments and Google News articles about bird flu, runs an NLP analysis of that discussion (sentiment, toxicity, topic modeling, n-grams), and models weekly Reddit comment volume over time against external signals such as news activity, egg prices, and animal-case data.
This repository contains the code accompanying:
Dalla Pria, L., Nelson, A. L., Koebel, K. J., & Ivanek, R. (2026). Mammalian spillover events predict the volume and emotion of online discourse during the US H5N1 outbreak. Manuscript submitted to Nature Communications.
Zenodo DOI 10.5281/zenodo.23070435
Reddit-NLP-ARIMAX-Project/
├── README.md
├── LICENSE
├── .gitignore
├── requirements.txt # All dependencies (collection + analysis)
├── src/ # Data collection scripts
│ ├── reddit_collection.py
│ ├── google_news_collection.py
│ └── .env.example
├── notebooks/ # Analysis and modeling
│ ├── Luizza_Reddit_NLP_Data_Analysis_2026.ipynb
│ └── Luizza_ARIMAX_Modeling_2026.ipynb
└──
pip install -r requirements.txt
python -m nltk.downloader stopwords punkt punkt_tab wordnet vader_lexiconPulls the raw data from the Reddit and Google News (SerpApi) APIs. You need your own API keys:
- Reddit: create an app at https://www.reddit.com/prefs/apps
- SerpApi: get a key at https://serpapi.com
Copy src/.env.example to src/.env and fill in your keys, then run:
python src/reddit_collection.py # -> df_birdflu.csv, df_h5n1.csv, df_birdflupreps.csv
python src/google_news_collection.py # -> serpapi_birdflu_news.csvCollection can take a while and may pause for API rate limits — this is normal.
Open the notebooks in VS Code or Jupyter:
Luizza_Reddit_NLP_Data_Analysis_2026.ipynb— data cleaning, EDA, n-grams, sentiment, toxicity, and topic modeling.Luizza_ARIMAX_Modeling_2026.ipynb— ARIMA / ARIMAX time-series modeling of weekly comment volume.
The notebooks read CSVs produced by the collection scripts plus a few external sources (egg prices, poultry / cattle / mammal / wild-bird cases). Place these files where the notebooks expect them (paths are set near the top of each notebook). Because Reddit and Google News API results change over time (deleted posts, updated indexing), re-running the collection scripts will produce a dataset that differs from the one analyzed in the paper. Exact numerical reproduction of the published findings is therefore not possible from raw collection alone; the code and methodology are provided so that the analysis can be re-executed on newly collected data or on comparable datasets.
- API keys are loaded from a local
.envfile and are never committed. .gitignoreexcludes.env, data files (*.csv), and Python caches.
If you use this code, please cite:
Dalla Pria, L. et al. (2026). Mammalian spillover events predict the volume and emotion of online discourse during the US H5N1 outbreak. Manuscript submitted to Nature Communications. Code: https://doi.org/10.5281/zenodo.23070435
This project is licensed under the terms of the LICENSE file in this repository.
For questions, contact Luizza Dalla Pria (ln326@cornell.edu).