CAP Bill Annotation System

January 29, 2026 · View on GitHub

Democratic Erosion Bill Classification (קידוד הצעות חוק: דעיכה דמוקרטית)

This module provides a research annotation system for classifying Knesset bills according to the Democratic Erosion codebook. It allows authorized researchers to systematically code legislation based on its potential impact on democratic institutions and rights.

Overview

The system enables researchers to:

  • Browse uncoded bills from the Knesset database
  • Classify bills using a structured taxonomy
  • Export annotations for analysis
  • Monitor progress through a statistics dashboard

Codebook Structure

The Democratic Erosion codebook has three major categories:

1. Government Institutions (מוסדות שלטון) - Codes 100-109

CodeHebrewEnglish
100כלליGeneral
101כנסתKnesset (Parliament)
102ממשלהGovernment/Executive
103מערכת המשפטJudicial System
104יועמ"ש / פרקליטותAttorney General / Prosecution
105שירות המדינהCivil Service
106כוחות הביטחוןSecurity Forces
107רשויות מקומיותLocal Authorities
108מפלגותPolitical Parties
109נשיא המדינהPresident

2. Civil Institutions (מוסדות אזרחיים) - Codes 200-204

CodeHebrewEnglish
200כלליGeneral
201תקשורתMedia
202עמותותNGOs/Civil Society
203חינוך ואקדמיהEducation & Academia
204מוסדות תרבותCultural Institutions

3. Rights (זכויות) - Codes 300-308

CodeHebrewEnglish
300כלליGeneral
301זכות לבחור ולהיבחרRight to Vote/Be Elected
302חופש הביטוי והמחאהFreedom of Expression/Protest
303חופש הדתFreedom of Religion
304שוויוןEquality
305זכות לחירות ופרטיותRight to Liberty & Privacy
306אזרחות, תושבות וכניסהCitizenship/Residency/Entry
307זכות לקנייןRight to Property
308זכות לחייםRight to Life

Setup Instructions

1. Enable the Feature

Add the following to your .streamlit/secrets.toml file:

[cap_annotation]
enabled = true
password = "your-secure-password"
researcher_name = "Dr. Your Name"

2. Configure Multiple Researchers (Optional)

For multiple researchers, each needs their own secrets configuration. On Streamlit Cloud, you can update the secrets through the dashboard. For local development, each researcher can have their own secrets.toml.

3. Cloud Sync

Annotations are stored in the DuckDB database and automatically sync to Google Cloud Storage (if configured). This means:

  • Annotations persist between sessions
  • Data is backed up to the cloud
  • Multiple researchers can share annotations (with appropriate coordination)

Usage

Logging In

  1. Navigate to the "קידוד הצעות חוק" section in the app
  2. Enter the password configured in secrets.toml
  3. You'll see a confirmation with your researcher name

Coding Bills

  1. Select a Bill: Browse the uncoded bills queue
  2. Review the Bill: Click the link to view the full bill on the Knesset website
  3. Choose Category: Select the major and minor category
  4. Add Submission Date: Date when the bill was first submitted
  5. Save: Click save to record the annotation

Viewing Coded Bills

The "Coded Bills" tab shows all previously coded bills with:

  • Filter by Knesset number
  • Filter by CAP code
  • Export to CSV functionality

Statistics Dashboard

The statistics tab provides:

  • Total bills coded vs. total available
  • Coding percentage
  • Breakdown by category
  • Progress by Knesset

Database Schema

UserCAPTaxonomy

Stores the codebook taxonomy:

  • MajorCode: Major category (1, 2, or 3)
  • MajorTopic_HE/EN: Major category names
  • MinorCode: Minor category code (101-306)
  • MinorTopic_HE/EN: Minor category names
  • Description_HE: Detailed description
  • Examples_HE: Example classifications

UserBillCAP

Stores bill annotations:

  • BillID: Reference to KNS_Bill
  • CAPMinorCode: Selected minor category
  • ResearcherID: Reference to UserResearchers
  • AssignedDate: Timestamp
  • Confidence: High/Medium/Low
  • Notes: Optional researcher notes
  • SubmissionDate: Bill submission date

Files

src/
├── ui/
│   ├── services/
│   │   └── cap_service.py           # Backend service for CAP operations
│   └── renderers/
│       └── cap_annotation_page.py   # Streamlit UI for annotation
data/
└── taxonomies/
    └── democratic_erosion_codebook.csv  # Editable codebook CSV

Coding Guidelines (from original codebook)

Key rules for coding:

  1. Each bill is coded to ONE category only
  2. Code by the means (institution/right mentioned) not ultimate target
  3. If a bill affects both an institution and a right, code by the institution
  4. Increasing oversight of an authority = reducing its powers
  5. Bills combining equality issues with other rights → code under "Equality" with sub-code: Women (1), Arabs (2), LGBTQ (3), Ultra-Orthodox (4)
  6. Bills with Jewish/national identity elements → add secondary "Jewish-National Identity" coding

Troubleshooting

"Annotation System Not Enabled"

  • Check that [cap_annotation] section exists in secrets.toml
  • Ensure enabled = true is set

"Incorrect Password"

  • Verify the password in secrets.toml
  • Check for trailing spaces in the password

"Error loading taxonomy"

  • The taxonomy CSV may not be loaded
  • Check that data/taxonomies/democratic_erosion_codebook.csv exists
  • Restart the app to reinitialize

Annotations Not Saving

  • Check database write permissions
  • Verify the database path is correct
  • Check the logs for specific errors

Export Format

The CSV export includes:

  • Bill information (ID, name, Knesset number, type)
  • CAP classification (major code, minor code, category names)
  • Metadata (researcher, date, confidence, notes)
  • Submission date

This format is compatible with statistical analysis tools and can be imported into Excel, R, Python, etc.