# Prompt 4 — Structured extraction with the codebook

## Context
You are one of several independent AI coders for a dataset extraction. Work only from the codebook and the articles given here. The codebook is `codebook_nk_enterprises_v2.xlsx` (also `codebook.json`). The articles to code are in `batch_<b>.json` (the 946-article corpus from Step 1, split into 19 batches of about 50 articles): a list of objects with `doc_id`, `article_date`, `article_category`, `article_long_title`, `article_cleaned_body`. Read the codebook completely before coding, including Decision_Rules.

## Task
Code every article. Produce one row per **instance** (one named enterprise in one article). Where the article names no specific enterprise, produce one row with `relevance = 0` and all other coded fields empty.

For every row supply exactly these fields:

| field | rule |
|---|---|
| `doc_id` | copy from input |
| `instance_id` | `<doc_id>-<n>`, numbering enterprises in order of first appearance |
| `relevance` | 1 or 0 per the codebook |
| `enterprise_name` | the name exactly as written in the article |
| `sector`, `event_type`, `leader_visit`, `province` | one allowed code each; no new codes, no blanks on relevant rows |
| `evidence_text` | a verbatim excerpt (one or two sentences) copied from `article_cleaned_body` that justifies sector and event_type |
| `coder_confidence` | 3, 2 or 1 per the codebook |
| `notes` | optional: the boundary case you faced and the rule you applied |

Constraints:
- Never invent an enterprise, a visit or a location that the text does not support. If province cannot be determined from the text or the enterprise's name, code `unknown` and lower confidence.
- Apply the event precedence order in Decision_Rules only when two events receive comparable attention.
- Quotations of the leader's instructions are not a visit.
- Check at the end that every `evidence_text` is an exact substring of the article body and that every `doc_id` in the input appears at least once.

## Output
Write the rows to `coded_batch_<b>.json` (a JSON array); the batches are assembled afterwards into `dataset_ai_coded.xlsx` with the Coding_Template columns. Code every batch the same way, in a fresh conversation, without seeing any other coder's output. Reply with only: the row count, the number of relevance-0 rows, and a bullet list of codebook ambiguities you met (doc_ids and the rule you wished existed). These ambiguities feed the next codebook revision.
