Natural Language Processing

Natural Language Processing#

These tutorials provide a hands-on introduction to analyzing text data for research, covering the full spectrum from deterministic rule-based methods to modern LLMs.

The Research Reproducibility Triad#

Before diving in, keep these principles in mind for all text analysis work:

  1. Automate — transition from interactive notebooks to scripts designed for batch processing

  2. Test — embed sanity checks and unit tests at every step to validate extraction accuracy

  3. Abstract — separate core logic (your functions) from specific parameters (model versions, file paths)

Tutorial Overview#

Tutorial

Methods Covered

When to Use

1. Deterministic Extraction

Regex, tokenization, stemming, POS tagging

Pattern-based extraction; maximum reproducibility

2. Quantifying Features

Dictionary methods, TF-IDF

Measuring known constructs; regression inputs

3. Paid LLMs

OpenAI, Anthropic, Google APIs

Nuanced classification; when context matters

4. Open-Source LLMs

Ollama on KLC

Sensitive data; cost at scale; reproducibility

5. Validation and Rigor

Cohen’s Kappa, cross-validation, Gold Standard

Validating results for academic publication

For interpretive coding with rubrics and adjudication, see Qualitative Coding with LLMs (separate walkthrough).