File size: 4,216 Bytes
5f0f37c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Dataset Preparation and Representation Scripts

This folder contains the official, verified dataset preparation, validation, and representation-building scripts for:

> **"Beyond Chunking: Node Integrity and Field Structure in Bengali Retrieval-Augmented Agent Memory"**

---

## 1. Directory Structure

```text
reproducibility/scripts/
├── README.md                           # This guide
├── data_ingestion/
│   ├── 00_fetch_external_data.py       # Validates external provenance and local file presence
│   ├── 01_prepare_corpora.py           # Standardizes knowledge corpora across Agri, Legal, and Edu
│   └── 02_prepare_queries.py           # Standardizes benchmark queries and evaluation subsets
├── validation/
│   └── 03_validate_data.py             # Independent reproducibility audit gate
├── representations/
│   ├── 04_build_l1_chunks.py           # L1 Chunked Unstructured builder (500-char window)
│   ├── 05_build_l2_full_nodes.py       # L2 Full-Node Unstructured builder (intact concatenated text)
│   └── 06_build_l3_fields.py           # L3 Structured BM25F schema builder (dedicated search slots)
├── 00_fetch_external_data.py           # Top-level entry point runner
├── 01_prepare_corpora.py               # Top-level entry point runner
├── 02_prepare_queries.py               # Top-level entry point runner
├── 03_validate_data.py                 # Top-level entry point runner
├── 04_build_l1_chunks.py               # Top-level entry point runner
├── 05_build_l2_full_nodes.py           # Top-level entry point runner
└── 06_build_l3_fields.py               # Top-level entry point runner
```

---

## 2. Script Execution Guide

### Script 00: Check External Data Sources and Provenance
Validates external data repositories (HuggingFace datasets, NCTB curriculum textbooks, AIS/DAE handbooks):
```bash
python reproducibility/scripts/00_fetch_external_data.py
```

### Script 01: Ingest and Standardize Corpora
Standardizes raw nodes into canonical JSON schema (`structured_nodes.json`) and exports `selected_act_ids.json` (735 legal acts) and `nctb_provenance.json` (190 secondary experiments):
```bash
python reproducibility/scripts/01_prepare_corpora.py
```

### Script 02: Prepare Benchmark Queries and Evaluation Subsets
Standardizes 3,670 queries (`queries.jsonl`) and generates the 900-query agent sample, the 872-query common evaluated subset, the 28 timeout exclusions, and the 300-query perturbation sample:
```bash
python reproducibility/scripts/02_prepare_queries.py
```

### Script 03: Execute Independent Data Validation Audit Gate
Executes the cryptographic and census audit verifying 100% hash integrity against `manifest.json`, node counts, query counts, chunk counts, and referential integrity:
```bash
python reproducibility/scripts/03_validate_data.py
```
*Expected Output:* `DATA VALIDATION AUDIT: PASS`

---

## 3. Representation Builders ($L_1$, $L_2$, $L_3$)

### Script 04: Build / Verify $L_1$ (Chunked Unstructured)
Splits knowledge records into 500-character recursive windows with overlap (4,526 agri, 4,202 legal, 892 edu chunks):
```bash
python reproducibility/scripts/04_build_l1_chunks.py
```

### Script 05: Build / Verify $L_2$ (Full-Node Unstructured)
Concatenates all active schema fields with newline delimiters into an intact document per record (1,028 agri, 735 legal, 190 edu intact documents):
```bash
python reproducibility/scripts/05_build_l2_full_nodes.py
```

### Script 06: Build / Verify $L_3$ (Structured BM25F)
Extracts records into dedicated indexed field slots according to the official schema (Appendix Table 7), tagging designated query-aligned anchor fields:
```bash
python reproducibility/scripts/06_build_l3_fields.py
```

---

## 4. Design Principles
- **Standard Library Only**: All scripts run in standard Python 3.8+ without external dependencies.
- **Console Encoding Safe**: Automatic UTF-8 console reconfiguring prevents Windows cp1252 character errors.
- **Relocatable Execution**: Scripts automatically detect project root from `__file__` or accept explicit `--data_dir` and `--output_dir` arguments.