Skip to content

Repository files navigation

Computational Stylistics of Post-Junta Greek Parliamentary Questions

DOI License: MIT

Code accompanying:

Mikros, G., and Fitsilis, F. (forthcoming) "Computational Stylistics of Post-Junta Greek Parliamentary Questions: Katharevousa, Party Style, and Democratic Reconstruction (1976–1977)." Digital Scholarship in the Humanities.

This repository contains the analysis pipeline used in the paper, including the hybrid spaCy / Stanza grc PROIEL feature extractor, the Kruskal–Wallis party-level tests, the BERTopic topic-modelling configuration, the GPT-4o sentiment-and-emotion classifier, the human validation tool, and all appendix builders.

Corpus availability

The OCR-derived corpus of 1,009 written parliamentary questions analysed in the paper is held by the Historical Archive of the Hellenic Parliament. It is not redistributed here because institutional permissions for the OCR text and the MP-level metadata have not yet been confirmed. Researchers wishing to reproduce the analysis on the original corpus should contact the corresponding author and the Hellenic Parliament's Scientific Service.

The repository is set up so that placing any Excel file at data/Data.xlsx with the column schema described below allows the entire pipeline to run end-to-end on alternative corpora. A small synthetic example file showing the expected schema is in docs/data_schema.md.

Repository layout

katharevousa-parliament-stylometry/
├── feature_extraction/
│   ├── stylometrics_extractor.py     # spaCy-based stylometric features (167 attributes)
│   ├── stanza_extractor.py           # Stanza grc PROIEL features (POS, case, tense)
│   ├── hybrid_pipeline.py            # combine spaCy + Stanza per the paper's hybrid
│   └── update_kv_index.py            # recompute the 14-marker Katharevousa index
├── analysis/
│   ├── kruskal_wallis_tests.py       # Kruskal–Wallis + Dunn (Appendix A)
│   ├── kw_compare_pipelines.py       # spaCy vs Stanza KW robustness check
│   ├── three_pipeline_validation.py  # spaCy vs Stanza PROIEL vs Stanza Perseus
│   └── hybrid_corpus_stats.py        # corpus-wide stats under the hybrid pipeline
├── topic_modeling/
│   └── bertopic_pipeline.py          # BERTopic configuration with GPT-4o-mini labels
├── sentiment/
│   └── sentiment_validation_tool.py  # Tkinter blind-annotation tool for human validation
├── appendices/
│   ├── build_appendix_b.py           # BERTopic reproducibility appendix
│   └── build_appendix_c.py           # cross-pipeline + hybrid pipeline appendix
├── prompts/                          # verbatim LLM prompts used in the paper
├── docs/                             # data schema, pipeline diagram, kv_index inventory
├── requirements.txt
├── LICENSE
└── README.md

Installation

Tested on Python 3.12 (Windows 11 and Linux). The pipeline requires three non-trivial language resources (spaCy Greek model, Stanza Ancient Greek PROIEL, and a paraphrase-multilingual-mpnet-base-v2 sentence encoder for BERTopic), which are downloaded separately from the Python packages.

# 1. Python packages
python -m pip install -r requirements.txt

# 2. spaCy Modern Greek model
python -m spacy download el_core_news_lg

# 3. Stanza Ancient Greek PROIEL (tokenize + POS + lemma + depparse)
python -c "import stanza; stanza.download('grc', package='proiel', verbose=False)"
python -c "import stanza; stanza.download('grc', processors={'depparse':'proiel_nocharlm'}, verbose=False)"

# (optional) Stanza Ancient Greek Perseus, used only by three_pipeline_validation.py
python -c "import stanza; stanza.download('grc', package='perseus', verbose=False)"

Configuration

The LLM-based steps require an OpenAI API key. The repository never contains a key; set the standard environment variable before running:

# Linux / macOS
export OPENAI_API_KEY="sk-..."

# Windows (PowerShell)
$env:OPENAI_API_KEY = "sk-..."

The OpenAI key is used by:

  • feature_extraction/stylometrics_extractor.py (sentiment + emotion analysis)
  • topic_modeling/bertopic_pipeline.py (Greek topic-label generation)

If the key is not set, those steps emit a warning and skip the LLM calls; the rest of the pipeline still runs.

Reproducing the paper's analyses

The pipeline is organised so that each script consumes the output of the previous one and writes to a stable location. Running them in order reproduces every table, figure, and appendix in the paper. Output paths default to outputs/... under the repository root.

Step Script Produces
1 feature_extraction/stylometrics_extractor.py All spaCy-derived stylometric features in data/Data.xlsx
2 feature_extraction/stanza_extractor.py outputs/ancient_greek_validation/Data_stanza_features.csv
3 feature_extraction/hybrid_pipeline.py outputs/ancient_greek_validation/Data_hybrid_features.csv
4 feature_extraction/update_kv_index.py (One-time) recomputes kv_index in data/Data.xlsx with the 14-marker definition reported in Table 1
5 topic_modeling/bertopic_pipeline.py BERTopic model + figures + topic labels in outputs/topic_modeling/
6 analysis/kruskal_wallis_tests.py Appendix A statistical tables (Tables A1–A5)
7 analysis/three_pipeline_validation.py Appendix C cross-pipeline correlation data
8 analysis/kw_compare_pipelines.py Appendix C robustness Table C3
9 analysis/hybrid_corpus_stats.py Appendix C.5 hybrid corpus statistics
10 appendices/build_appendix_b.py Word-format Appendix B (BERTopic reproducibility)
11 appendices/build_appendix_c.py Word-format Appendix C (cross-pipeline + hybrid)
12 sentiment/sentiment_validation_tool.py Tkinter GUI for human sentiment validation; produces κ vs GPT-4o

Most scripts have a CONFIG block at the top with input/output paths; adjust those if your Data.xlsx lives somewhere other than data/Data.xlsx.

The hybrid NLP pipeline

The paper's main methodological contribution is a small targeted hybrid of two NLP pipelines that addresses the partial mismatch between Modern Greek tooling and Katharevousa input:

  • spaCy el_core_news_lg provides the part-of-speech tags, dependency parse, lemmatisation, and lexical features — operating on lexical material the Modern Greek tagger has the strongest familiarity with.
  • Stanza grc PROIEL provides the case features and the tense features — operating on morphological categories that Modern Greek has lost or simplified (notably the dative case and the archaic past-tense paradigm) but that Katharevousa preserves.
  • All other features (aspect, mood, sentiment, lexical diversity, the Katharevousa register index, BERTopic clustering) are tagger-independent and run end-to-end through feature_extraction/stylometrics_extractor.py plus topic_modeling/bertopic_pipeline.py.

The hybrid is implemented in feature_extraction/hybrid_pipeline.py as a purely declarative routing of feature columns; no per-token alignment is required. See docs/pipeline_overview.md and Appendix C of the paper for the full justification and the cross-pipeline robustness check.

Katharevousa register index (kv_index)

The kv_index is the unweighted mean of fourteen surface markers diagnostic of Katharevousa relative to Demotic Greek (Mackridge 2009; Horrocks 2010). The inventory and per-marker matching regular expressions are documented in docs/kv_index_markers.md and reproduced in Table 1 of the paper. The index is computed directly from the raw text (pre-monotonisation, case-insensitive regular expressions) so that it is independent of either tagger and immune to the domain-mismatch concerns that motivate the hybrid pipeline.

LLM components and AI Disclosure

Two LLM components are used in the pipeline, both as constrained annotation aids inside a human-validated workflow rather than as autonomous interpreters:

  1. Sentiment + emotion analysis with OpenAI GPT-4o. A single prompt is submitted per document with the full sentence inventory; the model returns one document-level JSON object with sentiment label, sentiment score, probability distribution, eight Plutchik-style emotion intensities, and a self-reported confidence value. Validated against a 100-document blind human annotation at Cohen's κ = 0.51 (4-way) and weighted κ = 0.64 (3-way polarity); see Appendix C of the paper. Verbatim prompt in prompts/sentiment_emotion_prompt.md.
  2. Topic-label generation with OpenAI gpt-4o-mini for BERTopic. Greek prompt with the top ten c-TF-IDF keywords per topic; output reviewed by the authors against keyword lists, high-probability documents, and the wider sub-corpus before being accepted or edited. Verbatim prompt (Greek and English) in prompts/topic_label_prompt.md.

GPT-4o is also used for party-affiliation metadata enrichment (matching MP names to historical party registers) at 99.7% accuracy against known cases, with manual review of uncertain matches. See the AI Disclosure Statement of the paper.

Citing this software

This repository ships with a CITATION.cff file. GitHub uses it to render a "Cite this repository" widget at the top right of the project page; many reference managers also read the file directly.

If you cite this work in a paper, we ask that you cite both the software (this repository, via its Zenodo DOI) and the manuscript itself.

Mikros, G., and Fitsilis, F. (2026). Computational Stylistics of Post-Junta
Greek Parliamentary Questions: Analysis Pipeline (v0.1.0). Zenodo.
https://doi.org/10.5281/zenodo.19827528

Mikros, G., and Fitsilis, F. (forthcoming). Computational Stylistics of
Post-Junta Greek Parliamentary Questions: Katharevousa, Party Style, and
Democratic Reconstruction (1976-1977). Digital Scholarship in the Humanities.

The DOI above is the concept DOI issued by Zenodo when this repository was first archived. It always resolves to the most recent archived version, so the citation snippets remain valid as new versions are released. Each individual release additionally has its own version-specific DOI, listed on the corresponding Zenodo record.

Releases and versioning

The repository is archived on Zenodo via its GitHub integration; each GitHub release triggers a new Zenodo deposit with a per-version DOI and updates the concept DOI to point at the latest archive.

Current releases:

Version Date Status Notes
v0.1.0 2026-04-27 Latest Initial public release accompanying the DSH submission. See CHANGELOG.md.

Future versions (e.g., v1.0.0 on paper acceptance) follow the same workflow:

  1. Update the version and date-released fields in CITATION.cff.
  2. Add a corresponding entry to CHANGELOG.md.
  3. Commit, push, and create a GitHub release with the matching tag.

Zenodo archives the release within roughly a minute and mints the new version-specific DOI automatically. The badge above and the Cite this repository widget on GitHub continue to resolve correctly without further intervention.

License

This code is released under the MIT License (see LICENSE). The licence applies only to the analysis code in this repository, not to the underlying parliamentary-questions corpus, which remains subject to the institutional terms of the Historical Archive of the Hellenic Parliament.

Acknowledgements

The OCR-derived corpus was produced by a pilot project led by the Hellenic Parliament's Scientific Service in collaboration with the Parliamentary History Department, the Parliamentary Control Directorate, and the Document Image Analysis Team of the Institute of Informatics and Telecommunications at the National Centre for Scientific Research "Demokritos" (Fitsilis et al. 2024). The hybrid Modern–Ancient Greek pipeline was developed for this paper.

About

Computational stylistics of post-junta Greek parliamentary questions in Katharevousa (1976–1977). Code accompanying our DSH paper.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages