Paper: https://press.amu.edu.pl/pl/nie-rownosci-w-statutach-szkolnych-raport-z-badan.html
DOI: 10.14746/amup.9788323244325
A research-grade toolkit for analysing Polish school bylaws/statutes at scale - combining document processing, NLP-style keyword pipelines, and generative AI to turn dense PDFs into structured datasets ready for rigorous qualitative and quantitative work.
This repository supports an end-to-end workflow:
- PDF → structured JSON using OpenAI Assistants
- PDF → sentences CSV → keyword hits CSV for downstream qualitative analysis
- Context-code enrichment (optional) using OpenAI (questionnaire-style coding)
The codebase has been refactored into importable modules under src/research_code/ with thin CLI entrypoints.
This project accompanies research on (nie)równość / (in)equality in the content of Polish school statutes (bylaws). A statute is a key document regulating everyday life in a given institution; it shapes the experience of students and the wider school community - often even when that influence is not consciously noticed.
The research presents the course and results of an academic, intersectional analysis of school statutes in the light of:
- equality law and equality values,
- principles of anti-discrimination and inclusive education,
- respect for human rights and children’s rights.
Through quantitative and qualitative critical document analysis of norms present in statutes, the research team sought to answer:
To what extent do provisions in school statutes address equal treatment and social inclusion?
This repository operationalizes that research workflow using reproducible data processing and generative AI assistance to scale analysis across many documents while keeping outputs auditable (CSV/JSON artifacts).
All reusable code lives in src/research_code/:
config/settings.py– centralized config (env vars + defaults)logging.py– shared logging setup
io/file_utils.py– file discovery, path helpersprompts.py– prompt loader forsrc/prompts/**
nlp/citations.py– citation expansion (context around keyword)keywords.py– keyword/lexicon matching and CSV helpers
openai/client.py– OpenAI client creation + API key checks
pipelines/chunky_runner.py– Assistants PDF→JSON pipelinekeyword_scan.py– sentences.csv → keyword_hits.csvdedup.py– keyword hits CSV de-duplicationcontext_codes.py– enrich keyword hits with context codes (OpenAI)
cli/– thin entrypoints runnable viapython -m ...
Legacy scripts have been moved into src/legacy/ to keep the root src/ clean.
Create a virtual environment (recommended) and install dependencies:
python -m pip install -r .\requirements.txtNote:
src/scrapSentences.pyuses Apache Tika (tikaPython package), which is currently treated as a legacy/optional tool and is not part ofrequirements.txt.
Required for OpenAI-based pipelines:
OPENAI_API_KEY
Optional:
OPENAI_MODEL(default:gpt-4o-mini)OPENAI_TEMPERATURE(default:0.2)
Optional path overrides:
PB_DATA_DIRPB_OUTPUT_DIRPB_KEYWORDS_DIRPB_PROMPTS_DIR
Defaults are computed relative to the repository root.
python -m research_code.cli.chunky .\data\examples\BPOMMPB_1.pdf .\output\BPOMMPB_1.json .\data\template.jsonpython -m research_code.cli.supervisor .\data\examples .\output .\data\template.jsonpython .\src\scrapSentences.py .\data\examples .\output\sentences.csvpython -m research_code.cli.find_keywords .\output\sentences.csv --keywords-dir .\data\keywords .\output\keyword_hits.csvpython -m research_code.cli.dedup .\output\keyword_hits.csv .\output\keyword_hits_dedup.csvThis step takes (deduped) keyword hits and evaluates each citation against a set of questions (context codes).
python -m research_code.cli.context_codes .\output\keyword_hits_dedup.csv .\output\keyword_hits_context.csv --questions-csv .\data\contextcodes\contextcodesquestions.csv --prompt contextcodes/v2_0.txtThe prompt file is loaded from src/prompts/ and should contain placeholders:
[SENTENCE][QUESTION]
Maintained (recommended):
research_code.cli.*+research_code.pipelines.*
Legacy (kept for reference):
- moved into
src/legacy/(including old script-style OpenAI + keyword pipelines)