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
| Code | Hebrew | English |
|---|---|---|
| 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
| Code | Hebrew | English |
|---|---|---|
| 200 | כללי | General |
| 201 | תקשורת | Media |
| 202 | עמותות | NGOs/Civil Society |
| 203 | חינוך ואקדמיה | Education & Academia |
| 204 | מוסדות תרבות | Cultural Institutions |
3. Rights (זכויות) - Codes 300-308
| Code | Hebrew | English |
|---|---|---|
| 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
- Navigate to the "קידוד הצעות חוק" section in the app
- Enter the password configured in
secrets.toml - You'll see a confirmation with your researcher name
Coding Bills
- Select a Bill: Browse the uncoded bills queue
- Review the Bill: Click the link to view the full bill on the Knesset website
- Choose Category: Select the major and minor category
- Add Submission Date: Date when the bill was first submitted
- 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 namesMinorCode: Minor category code (101-306)MinorTopic_HE/EN: Minor category namesDescription_HE: Detailed descriptionExamples_HE: Example classifications
UserBillCAP
Stores bill annotations:
BillID: Reference to KNS_BillCAPMinorCode: Selected minor categoryResearcherID: Reference to UserResearchersAssignedDate: TimestampConfidence: High/Medium/LowNotes: Optional researcher notesSubmissionDate: 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:
- Each bill is coded to ONE category only
- Code by the means (institution/right mentioned) not ultimate target
- If a bill affects both an institution and a right, code by the institution
- Increasing oversight of an authority = reducing its powers
- Bills combining equality issues with other rights → code under "Equality" with sub-code: Women (1), Arabs (2), LGBTQ (3), Ultra-Orthodox (4)
- Bills with Jewish/national identity elements → add secondary "Jewish-National Identity" coding
Troubleshooting
"Annotation System Not Enabled"
- Check that
[cap_annotation]section exists insecrets.toml - Ensure
enabled = trueis 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.csvexists - 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.