File size: 32,827 Bytes
a42d019
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#!/usr/bin/env python3
"""Package source, rights evidence, measured documentation and a tiny local explorer."""
import argparse
import hashlib
import html
import json
import pathlib
import shutil


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--project", type=pathlib.Path, default=pathlib.Path(__file__).resolve().parents[1])
    args = parser.parse_args()
    project = args.project
    release = project / "release"
    stats = json.loads((release / "stats.json").read_text())
    baselines = json.loads((release / "reports" / "baselines.json").read_text())
    for folder in ("raw", "code"):
        shutil.copytree(project / folder, release / folder, dirs_exist_ok=True, ignore=shutil.ignore_patterns("__pycache__", "*.pyc"))
    # The two license files are maintained with the source project, outside the build output.
    shutil.copyfile(project / "LICENSE", release / "LICENSE")
    shutil.copyfile(project / "code" / "LICENSE", release / "code" / "LICENSE")
    (release / "code" / "requirements.txt").write_text("pyarrow==26.0.0\n")
    (release / "requirements.txt").write_text("pyarrow==26.0.0\n")
    counts = "\n".join(f"| `{op}` | {count:,} |" for op, count in sorted(stats["operations"].items()))
    split_rows = "\n".join(f"| {split} | {len(data['economies'])} | {data['observations']:,} | {data['questions']:,} | {data['structure_holdout_diagnostic']:,} |" for split, data in stats["per_split"].items())
    configs = "\n".join(f"- config_name: {config}\n" + ("  default: true\n" if config == "questions" else "") + "  data_files:\n" + "\n".join(f"  - split: {split}\n    path: data/{config}/{split}-*.parquet" for split in ("train", "validation", "test")) for config in ("questions", "observations", "tables"))
    first = baselines["baselines"]["first_visible_cell"]["all"]
    readme = f'''---
pretty_name: Bayanat Arabic Public Data Reasoning
language:
- ar
- en
license: cc-by-4.0
task_categories:
- question-answering
size_categories:
- 1K<n<10K
annotations_creators:
- machine-generated
language_creators:
- found
- machine-generated
tags:
- arabic
- numerical-reasoning
- table-question-answering
- world-bank
- evidence-grounding
- tabular
- synthetic-questions
configs:
{configs}
---

# Bayanat Arabic Public Data Reasoning

**{stats['question_records']:,} controlled Arabic questions over {stats['observations']:,} real World Bank observations. Exact answer programs, visible source cells, and economy-disjoint splits.**

Use this dataset to test whether an Arabic system reads a recorded statistical value, compares the right years, distinguishes percentage points from percent change, joins GDP to population, or abstains when the visible data are missing or units cannot be added. Every question has a controlled English counterpart; the primary input is Arabic. This is an original task construction over a frozen source snapshot, rather than a translation of an existing QA benchmark.

[Company release page](https://www.bayanatlabs.com/open/arabic-public-data-reasoning) · [Dataset](https://huggingface.co/datasets/Bayanat-Labs/arabic-table-reasoning) · [Versioned source](https://github.com/Bayanat-Labs/arabic-public-data-reasoning/tree/v0.1.1) · [Local sample explorer](explorer.html)

The **facts and native Arabic indicator/economy names come from World Development Indicators**. Bayanat assembled the source snapshot, selected and represented the cells, authored controlled Arabic/English question templates with AI assistance, and generated answers with software. Questions, gold answers, citation targets and table views are **machine-generated annotations**, with no native-speaker or statistician validation established. No source observations were invented. The 6,419 tasks reuse 4,328 of the 4,400 source cells; questions and views are correlated observations and must not be counted as independent real-world facts.

## Load and use

```python
from datasets import load_dataset
import json

questions = load_dataset("Bayanat-Labs/arabic-table-reasoning", "questions", split="test", revision="v0.1.0")
row = questions[0]
model_visible = {{"question_ar": row["question_ar"], "table": json.loads(row["context"])}}
# Pass only model_visible and the public answer contract to a model.
# Never pass gold_answer, gold_evidence_ids, program, operation, template_id,
# family_id, diagnostic flags, source lookup tables or the complete dataset row.
```

`code/model_input.py` implements this whitelist and provides the answer contract. The `questions` configuration includes a JSON-string context, a formal program, a JSON-string gold answer and evidence IDs. The `observations` configuration retains all 4,400 selected real cells, including 100 missing values; `tables` contains 4,141 distinct generated visible contexts. JSONL equivalents are supplied in `jsonl/`. All train, validation and test gold is public.

Return an answer object with `status`, `value`, and `unit`, plus a separate `evidence_ids` list of visible cell IDs. A numeric `value` is a decimal string; comparison returns a JSON boolean; rank returns an ascending list of year strings. For a missing cell return `{{"status":"missing","value":null,"unit":"<the cell unit_code>"}}`. Incompatible addition returns `{{"status":"incompatible_units","value":null,"unit":null}}`. These schema snippets are illustrative, not answers to a released item.

## Measured contents

The frozen cohort contains 22 selected Arab League economies, eight explicitly licensed WDI indicators and 25 requested years, 2000–2024. The cohort is a current selection, not a reconstruction of historical membership or boundaries. Source names are preserved, including the World Bank's economy naming. **4,300 cells are numeric; 100 are missing.** An API `lastupdated` value of 2026-10-08 accompanies all eight collected observation responses, retrieved on 2026-10-26. Indicator metadata and provider statements remain separately inspectable in `series.json` and `raw/`.

| Split | Economies | Source observations | Questions | Test-only structure diagnostic |
|---|---:|---:|---:|---:|
{split_rows}

| Operator | Questions |
|---|---:|
{counts}

Only 28 questions have the `missing` target and 109 have `incompatible_units`; the other 6,282 have `ok`. Report status metrics by class: an always-`ok` style method can achieve high status accuracy without computing correct values. Lookup questions are deliberately easy and form 893 records. The eight series cover population, current-dollar GDP, published current-dollar GDP per capita, annual GDP growth, life expectancy, electricity access, consumer-price inflation, and urban population share. See [SOURCES.md](SOURCES.md) for exact IDs, providers and licenses.

## Arithmetic and task boundaries

Lookup answers reproduce the exact displayed source numeric string. Arithmetic uses Python `Decimal`, with derived outputs rounded to six decimal places using `ROUND_HALF_UP`; trailing zeros can be omitted under numeric normalization. Values are never rounded before display and then secretly computed from hidden precision. Missing values stay `null`, rather than zero. Relative change requires a positive base and applies only to quantity series, not percentage rates. Rate differences use percentage points. Negative signed differences are retained.

The GDP/population task divides the two displayed source values for the same economy and year. It is explicitly a **calculated ratio**, which need not equal the separately published GDP-per-capita series. Current-dollar GDP changes are changes in recorded nominal values, not real economic growth. Comparisons of urban population shares concern recorded values; national definitions can differ. Ranking questions concern only non-missing cells actually displayed, return all ties, and do not establish a ranking over absent years or all economies. Cross-economy questions name both displayed economies and never claim to cover the full cohort.

`second_highest_years` is a test-only question-structure diagnostic over the second **distinct** highest value. Its 113 rows must be reported separately from the 6,306 rows using shared operators. Its parser is explicitly implemented in the symbolic baseline, so that baseline is not a demonstration of learning an unseen operation.

## Splits, duplication and evidence

Economies are assigned by a fixed SHA256 ordering, with 16 in train, three in validation and three in test; [splits.json](splits.json) contains the exact algorithm and allocation. All years, series, question families, joins and tables involving an economy stay in its split. Cross-economy comparisons are constructed only within a split. Source-cell and economy overlap across splits is zero under the audit. Indicator definitions, question grammar and numerical values can recur, so this is a narrow economy holdout with a separate operator diagnostic, not broad out-of-distribution evidence.

Exact context/question inputs and IDs are deduplicated. Related tasks can reuse a source cell inside a split. `family_id` identifies the operator and its ordered evidence cells; it does not make reused-source families statistically independent. For uncertainty estimates, cluster at least by economy or connected source-cell groups rather than individual question rows. Only three held-out economies are available in either validation or test, so inference beyond this cohort is limited.

Evidence IDs are the cells read by the formal answer program. They form an auditable software reference, not a human proof or a uniquely minimal explanation. **Contexts contain only the program's evidence cells**, so citing every displayed cell satisfies the evidence target. Citation scores here do not measure distractor rejection, retrieval quality, or faithful internal reasoning.

## Reproduce, verify and score

```sh
python -m pip install -r requirements.txt
python code/build.py --project . --output ../rebuilt-public-data
python code/verify.py --release . --raw raw --output reports/validation-rerun.json
python code/tests.py -v
python code/baselines.py --release .
python code/score.py --release . --split all \\
  --predictions reports/template_aware_symbolic.predictions.jsonl \\
  --output reports/symbolic-score-rerun.json
```

Rebuilding uses frozen `raw/` bytes and checks their hashes; it does not contact the API. `code/fetch.py` is the bounded acquisition recipe. Running it with `--refresh` explicitly starts a fresh mutable source collection. The original receipt URLs, retrieval times, successful HTTP status, hashes and source update fields are retained. The tested packaging environment used Python 3.14 and PyArrow 26.0.0. `code/verify.py` independently implements the algebra and source checks without importing the generator's oracle.

To score a model, write JSONL rows as `{{"id":"<question id>","answer":{{"status":"ok","value":"<answer>","unit":"<unit>"}},"evidence_ids":["<visible cell id>"]}}`. Use `--split test` for a test-only submission; default scoring includes both shared and diagnostic rows and reports each separately. A submission must use only the IDs in its selected scope. Missing predictions are wrong; duplicate, unknown or out-of-scope prediction IDs fail the submission. Nonfinite values fail numeric matching. Boolean values remain distinct from numeric 0/1; exact rank matching requires ordered string years. Nonexistent or duplicated citations fail strict joint. See [EVALUATION.md](EVALUATION.md).

## Actual validation and transparent baselines

The software auditor passed all 6,419 released tasks, all 4,400 source observations, raw snapshot hashes, source licenses, context/source equivalence, Parquet/JSONL parity, evidence sufficiency and split boundaries. Separate agent review independently recomputed every task at Decimal precision 60 and found no mismatches; this is software review, not native-speaker or domain-professional review. Exact reports are in `reports/`.

| Input-only method | Rows | Exact answer |
|---|---:|---:|
| Return first visible cell | 6,419 | {first['exact_answer']:,}/{first['rows']:,} ({100 * first['exact_answer_rate']:.2f}%) |
| Template-aware symbolic parser | 6,419 | 6,419/6,419 (100.00%) |

The symbolic parser recognizes every declared authored Arabic template, including the diagnostic operator, then applies an exact programmed calculation to visible cells. This demonstrates a controlled-format ceiling. It is not a learned-model result, unrestricted Arabic parser, or evidence of training benefit. The first-cell method has {100 * first['status_exact_rate']:.2f}% status accuracy despite only {100 * first['exact_answer_rate']:.2f}% exact answers, illustrating why status alone is insufficient. No LLM benchmark score is claimed. Frozen prediction rows and per-split/per-operator results are included.

## Rights, credits and limitations

Data and original annotations/documentation are distributed under [CC BY 4.0](LICENSE); **World Bank source data additionally retain the mandatory source terms** documented in [DATA_LICENSE.md](DATA_LICENSE.md), [ATTRIBUTION.md](ATTRIBUTION.md), and the frozen rights pages. Code is separately [Apache-2.0](code/LICENSE). Each of the eight individual series explicitly reports CC BY-4.0 in its frozen metadata. World Bank and the original data providers receive attribution; neither endorses this adaptation. No third-party benchmark examples, article prose, microdata or model responses are redistributed.

Limitations include controlled template language, limited operators, uneven source coverage and metadata quality, possible estimation/revision and cross-country definitional differences, rare missing-value targets, no distractor evidence, only three economies per held-out split, and public answers/programs that permit contamination. Software checks establish consistency with the frozen displayed source, not the truth of every economic claim or readiness for consequential decisions. This release makes no first/largest or guaranteed adoption claim.

Related resources include [Arabic WikiTableQA](https://www.mdpi.com/2079-9292/14/19/3829), [AraTable](https://github.com/rana-alshaikh/AraTable-Benchmark), [SAHM](https://mbzuai-nlp.github.io/SAHM/), and [ArabicNumBench](https://arxiv.org/abs/2602.18776). The contribution is this particular official-source snapshot, original controlled tasks, explicit rights provenance, exact executable answers and economy-held-out packaging.

```bibtex
@dataset{{bayanat_arabic_public_data_reasoning_2026,
  author = {{{{Bayanat Labs}}}},
  title = {{Bayanat Arabic Public Data Reasoning}},
  year = {{2026}},
  version = {{0.1.0}},
  url = {{https://huggingface.co/datasets/Bayanat-Labs/arabic-table-reasoning}},
  note = {{Controlled Arabic QA over real World Bank WDI observations; CC BY 4.0 with retained source terms}}
}}
```
'''
    (release / "README.md").write_text(readme)
    series = json.loads((release / "series.json").read_text())
    rights_rows = "\n".join(f"| `{s['indicator_code']}` | {s['label_en']} | {s['source_unit']} | [CC BY-4.0 metadata]({s['source_metadata_url']}) |" for s in series)
    providers = "\n\n".join(f"### `{s['indicator_code']}` — {s['label_en']}\n\n{s['source_providers']}\n\n[Indicator page]({s['indicator_url']}) · [Exact metadata]({s['source_metadata_url']})" for s in series)
    (release / "SOURCES.md").write_text(f'''# Frozen source register

World Bank: World Development Indicators (WDI), API source 2. Requested period: 2000–2024. Acquisition: 26 October 2026. Observation API update field: 8 October 2026. Exactly 550 source observations were returned for each series (22 economies × 25 years). The API observation `unit` fields are empty, so the dataset uses the explicit `Unitofmeasure` in series metadata; authored `unit_code` and Arabic unit glosses make it executable. Original status and decimal-hint fields are retained.

| Series | Official English label | Official source unit | Individual license evidence |
|---|---|---|---|
{rights_rows}

Native Arabic labels and source definitions are retained from `/v2/ar/`. Some definitions returned by that endpoint are English, and some Arabic metadata lag the current English metadata. Bayanat does not silently describe those as verified official Arabic translations. No facts are independently audited against national source systems. The [raw manifest](raw/manifest.json) supplies every exact request, retrieval time, status and SHA256. Mutable URLs alone do not reproduce the frozen release.

## Provider attributions

{providers}

## Source policy

[World Bank public licenses](https://datacatalog.worldbank.org/public-licenses) and [Summary Terms of Use](https://data.worldbank.org/summary-terms-of-use) were frozen with receipts in `raw/`. The legacy `terms-of-use-for-datasets` URL redirects to general site terms, so this release cites the operative dataset-license and summary pages directly. Only these eight individually qualified indicators are included; an open API is not a blanket clearance for every series.
''')
    (release / "ATTRIBUTION.md").write_text(f'''# Attribution and change notice

**The World Bank: World Development Indicators: source providers identified per series in [SOURCES.md](SOURCES.md) and [series.json](series.json).** Original source: https://data.worldbank.org/ ; individual data sources and metadata URLs are preserved. See https://data.worldbank.org/summary-terms-of-use and https://datacatalog.worldbank.org/public-licenses.

World Bank and its listed data providers created/compiled the underlying source observations and native indicator/economy metadata. Bayanat Labs selected 22 economies and eight series, froze the requested 2000–2024 responses, assigned exact source-cell identifiers and economy splits, added explicit unit glosses, authored controlled Arabic and English question templates with AI assistance, calculated answers with software, and packaged source-linked contexts and annotations. Original source spellings and missing numeric values are preserved.

These are adaptations and newly generated task annotations. Neither the World Bank nor a source provider has reviewed or endorsed them. No source logo or emblem is included. Follow the same World Bank/provider acknowledgment requirement when redistributing or facilitating access to these source data, and pass the acknowledgment requirement to downstream recipients. The source terms URL above may be used to meet the provider's stated attribution requirement. Cite the Bayanat release as well when referring to this task construction.
''')
    (release / "DATA_LICENSE.md").write_text('''# Data licensing and retained source terms

Original Bayanat question templates, computed annotations, visible table assembly, split manifests and documentation: Creative Commons Attribution 4.0 International (CC BY 4.0), with the legal text in `LICENSE`. Original source code: Apache License 2.0, in `code/LICENSE`. Executable programs are supplied as annotation records; code implementations have the separate code license.

Underlying World Bank WDI data and referential series metadata: the eight retained indicators each explicitly identify **CC BY-4.0** in `License_Type`, with `License_URL=https://datacatalog.worldbank.org/public-licenses#cc-by`. World Bank adds mandatory dispute-resolution terms and provider attribution conditions. This release retains those terms; its CC BY metadata does not remove them or establish rights to unrelated WDI series. Read the complete frozen pages `raw/world-bank-public-licenses.html` and `raw/world-bank-summary-terms.html`, their receipts and the current policy URLs.

## Mandatory World Bank addition

The following dataset-source addition is reproduced from the World Bank public-licenses page frozen for this release:

> Any and all disputes arising under this License that cannot be settled amicably shall be resolved in accordance with the following procedure:
>
> Pursuant to a notice of mediation communicated by reasonable means by either You or the Licensor to the other, the dispute shall be submitted to non-binding mediation conducted in accordance with rules designated by the Licensor in the copyright notice published with the Work, or if none then in accordance with those communicated in the notice of mediation. The language used in the mediation proceedings shall be English unless otherwise agreed.
>
> If any such dispute has not been settled within 45 days following the date on which the notice of mediation is provided, either You or the Licensor may, pursuant to a notice of arbitration communicated by reasonable means to the other, elect to have the dispute referred to and finally determined by arbitration.
>
> The arbitration shall be conducted in accordance with the rules designated by the Licensor in the copyright notice published with the Work, or if none then in accordance with the UNCITRAL Arbitration Rules as then in force. The arbitral tribunal shall consist of a sole arbitrator and the language of the proceedings shall be English unless otherwise agreed. The place of arbitration shall be where the Licensor has its headquarters.
>
> The arbitral proceedings shall be conducted remotely (e.g., via telephone conference or written submissions) whenever practicable.

Source: https://datacatalog.worldbank.org/public-licenses . The frozen original HTML is authoritative if punctuation/formatting differs in this readable transcription. World Bank also requires acknowledgment of World Bank and data providers, including passing that requirement to downstream recipients; prohibits implied endorsement/name/logo use in conjunction with endorsement; and disclaims warranties. See `ATTRIBUTION.md` and the complete summary terms at https://data.worldbank.org/summary-terms-of-use .

This license register covers aggregate indicator observations and permitted metadata. It does not include microdata, national-site prose, third-party benchmark content, source logos, or learned-model outputs. No permission for such excluded material is implied.
''')
    (release / "CITATION.cff").write_text('''cff-version: 1.2.0
message: "Please cite the task dataset and credit World Bank WDI and each source provider."
title: "Bayanat Arabic Public Data Reasoning"
type: dataset
version: 0.1.0
date-released: 2026-10-26
authors:
  - name: Bayanat Labs
url: "https://huggingface.co/datasets/Bayanat-Labs/arabic-table-reasoning"
repository-code: "https://github.com/Bayanat-Labs/arabic-public-data-reasoning/tree/v0.1.1"
license: CC-BY-4.0
abstract: "Controlled Arabic and English numerical QA over real frozen World Bank WDI observations, with exact programs, visible source-cell evidence and economy-disjoint splits. World Bank source data retain mandatory additional terms."
''')
    (release / "EVALUATION.md").write_text('''# Evaluation protocol

Model input consists only of `question_ar` and the parsed `context` table, plus the answer contract. `code/model_input.py` implements that boundary. Gold answer, program, operation, evidence labels, template/family IDs and diagnostic metadata are not inputs. All split gold is public, so a public test is not evidence of contamination-free evaluation. Optional `question_en` is a controlled authored counterpart; evaluate English separately with the same source cells, not as a second independent dataset.

Predict one JSON object per line: `{"id":"...","answer":{"status":"ok","value":"...","unit":"..."},"evidence_ids":["..."]}`. Use a boolean for comparisons and ascending string-year arrays for ranks. Numeric values may be decimal strings; finite JSON numbers also normalize numerically. Booleans never normalize to numeric 0/1. Lookup requires exact displayed precision; derived numeric answers are rounded to six decimals, HALF_UP. Missing source cells are null; incompatible-unit outputs have null value and unit.

`python code/score.py --release . --predictions predictions.jsonl --split test --output score.json` reports answer, status, value, unit, reference-evidence micro precision/recall and strict joint. Strict joint requires exact answer and the exact set of reference evidence IDs, with no duplicate/nonexistent citations. Missing prediction IDs are wrong; duplicate or unknown/out-of-scope IDs fail the entire submission. Use only IDs for the selected split and scope. `--scope shared` or `--scope diagnostic` changes the expected submission IDs. Nonstandard JSON NaN/Infinity values fail parsing; string forms fail numeric correctness. Extra answer keys fail its exact schema.

Report the test shared-operator population (820 questions) separately from the second-highest-distinct-value structure diagnostic (113 questions). Include per-operator results and missing/incompatible status slices. Test has only DZA, EGY and SOM; validation has DJI, KWT and SAU. Do not report 933 unrelated independent samples: questions share cells, series and templates. Cluster uncertainty at economy or connected source-cell level; three test clusters are a severe limitation. A single aggregate score can hide lookup simplicity and rare abstention targets.

Source-cell references are a software program read set. Every displayed cell is evidence for its question, so citing all displayed cells passes the evidence criterion. This does not test distractor rejection, retrieval quality, minimal human proof or internal reasoning faithfulness. No explanations/chain-of-thought text is scored or required.

The supplied first-cell baseline reads the first visible cell and returns its recorded value without understanding the question. The symbolic baseline reads only the whitelisted input, identifies one of the declared controlled Arabic templates, and runs exact arithmetic; all template/operator forms, including the test diagnostic, are explicitly implemented. It is a programmed format ceiling, not a learned-model, unknown-template or production result. Neither baseline calls a model or uses a paid API.
''')
    examples = [json.loads(line) for line in (release / "examples.jsonl").read_text().splitlines()]
    payload = json.dumps(examples, ensure_ascii=False).replace("<", "\\u003c")
    page = '''<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Arabic Public Data Reasoning — Bayanat Labs</title><style>body{font:16px/1.6 system-ui,sans-serif;max-width:1100px;margin:32px auto;padding:0 20px;color:#132a32;background:#f7faf8}h1{font-size:2rem;line-height:1.2}a{color:#106755}select,button{font:inherit;padding:9px;border:1px solid #8aa59d;border-radius:6px;background:white}section{background:white;border:1px solid #dce7e1;border-radius:12px;padding:22px;margin:20px 0}table{border-collapse:collapse;width:100%;font-size:14px}td,th{border-bottom:1px solid #dce7e1;padding:10px;text-align:start;overflow-wrap:anywhere}th{background:#f0f6f2}pre{white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px}.scroll{overflow-x:auto}.muted{color:#526a64}#question{font-size:1.2rem}</style><body><p><a href="https://www.bayanatlabs.com/open/arabic-public-data-reasoning">Bayanat Labs · Open datasets</a></p><h1>Arabic Public Data Reasoning</h1><p>Inspect actual controlled questions over real frozen World Bank observations. This tiny embedded sample is not full-corpus search. Arabic source names are preserved; navigation and explanations default to English.</p><p class="muted">6,419 generated tasks · 4,400 real source cells · 22 economies · eight indicators · 2000–2024. Questions and software labels have no human linguistic/statistical validation. No LLM score is claimed.</p><label for="sample">Example </label><select id="sample"></select><section><p class="muted" id="meta"></p><p id="question" lang="ar" dir="rtl"></p><p id="english"></p><div class="scroll"><table><thead><tr><th>Cell ID</th><th>Economy</th><th>Indicator</th><th>Year</th><th>Exact displayed value</th><th>Unit</th></tr></thead><tbody id="cells"></tbody></table></div></section><button id="reveal" aria-expanded="false">Show reference answer and program</button><section id="answer" hidden><p>Computed reference, not human annotation. Every displayed cell is evidence; this sample does not test distractor rejection.</p><pre id="gold"></pre></section><p><a href="https://huggingface.co/datasets/Bayanat-Labs/arabic-table-reasoning">Download dataset</a> · <a href="https://github.com/Bayanat-Labs/arabic-public-data-reasoning/tree/v0.1.1">Source and verification</a> · <a href="https://data.worldbank.org/summary-terms-of-use">World Bank source terms</a></p><p class="muted">Data/annotations: CC BY 4.0 with mandatory World Bank source terms; code: Apache-2.0. Credit World Bank WDI and each series provider. Neither endorses this adaptation.</p><script>const rows=PAYLOAD;const el=id=>document.getElementById(id);rows.forEach((row,i)=>{let option=document.createElement('option');option.value=i;option.textContent=`${i+1}. ${row.operation} · ${row.split}`;el('sample').append(option)});function show(){const row=rows[Number(el('sample').value)];el('meta').textContent=`${row.id} · ${row.operation} · ${row.split}${row.structure_holdout_diagnostic?' · test-only structure diagnostic':''}`;el('question').textContent=row.question_ar;el('english').textContent=row.question_en;el('cells').replaceChildren();for(const cell of JSON.parse(row.context).cells){const tr=document.createElement('tr');for(const value of [cell.cell_id,cell.economy_ar,cell.indicator_ar,cell.year,cell.value===null?'Missing (null)':cell.value,cell.unit_ar]){const td=document.createElement('td');td.dir='auto';td.textContent=value;tr.append(td)}el('cells').append(tr)}el('gold').textContent=JSON.stringify({answer:JSON.parse(row.gold_answer),evidence_ids:row.gold_evidence_ids,program:JSON.parse(row.program)},null,2);el('answer').hidden=true;el('reveal').setAttribute('aria-expanded','false');el('reveal').textContent='Show reference answer and program'}el('sample').addEventListener('change',show);el('reveal').addEventListener('click',()=>{el('answer').hidden=!el('answer').hidden;el('reveal').setAttribute('aria-expanded',String(!el('answer').hidden));el('reveal').textContent=el('answer').hidden?'Show reference answer and program':'Hide reference answer and program'});show();</script></body></html>'''.replace('PAYLOAD', payload)
    page = page.replace('<a href="https://data.worldbank.org/summary-terms-of-use">World Bank source terms</a>', '<a href="https://huggingface.co/datasets/Bayanat-Labs/arabic-table-reasoning/blob/main/SOURCES.md">Series providers and source evidence</a> · <a href="https://data.worldbank.org/summary-terms-of-use">World Bank source terms</a>')
    (release / "explorer.html").write_text(page)
    demo = project / "demo"
    demo.mkdir(exist_ok=True)
    (demo / "index.html").write_text(page)
    (demo / "README.md").write_text('''---
title: Arabic Public Data Reasoning
emoji: 📊
colorFrom: green
colorTo: blue
sdk: static
app_file: index.html
pinned: false
license: apache-2.0
---

# Bayanat Arabic Public Data Reasoning — actual sample explorer

This static sample shows 11 actual question records, source cells, computed answers and programs from the 6,419-task dataset. It is not full-corpus search. Primary navigation is English; original Arabic source names and controlled Arabic questions are preserved. Questions/annotations were generated with software and AI-assisted templates, with no human linguistic/statistical review established. No LLM score is claimed.

[Dataset and full source/provider attribution](https://huggingface.co/datasets/Bayanat-Labs/arabic-table-reasoning) · [Bayanat release page](https://www.bayanatlabs.com/open/arabic-public-data-reasoning) · [Source code](https://github.com/Bayanat-Labs/arabic-public-data-reasoning/tree/v0.1.1)

HTML/JavaScript code: Apache-2.0 (`LICENSE`). Embedded observations: World Bank WDI, CC BY 4.0 with mandatory additional World Bank source terms. Original templates/annotations/documentation: CC BY 4.0. See `DATA_LICENSE.md`, `ATTRIBUTION.md`, and the full dataset's `SOURCES.md` for individual providers and license evidence. World Bank and providers do not endorse this adaptation. No remote scripts, models, API keys or network data fetches are required by this explorer.
''')
    for name in ("DATA_LICENSE.md", "ATTRIBUTION.md"):
        shutil.copyfile(release / name, demo / name)
    shutil.copyfile(project / "code" / "LICENSE", demo / "LICENSE")
    (demo / ".gitattributes").write_text("*.parquet filter=lfs diff=lfs merge=lfs -text\n")
    (release / ".gitattributes").write_text("*.parquet filter=lfs diff=lfs merge=lfs -text\n")
    print(json.dumps({"readme_bytes": len(readme.encode()), "explorer_examples": len(examples), "release": str(release)}))


if __name__ == "__main__":
    main()