Datasets:

File size: 3,119 Bytes
e7a73ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
pretty_name: CS 489 F26 A3 Constituent Labels
language:
  - en
tags:
  - constituent-labeling
  - representation-probing
  - cs489
size_categories:
  - 10K<n<100K
configs:
  - config_name: default
    data_files:
      - split: train
        path: train.parquet
      - split: dev
        path: dev.parquet
---

# A3 constituent-label data

English sentences with labeled constituent spans for CS 489 Assignment 3 at the University of Waterloo (Fall 2026).
Each example provides word tokens and gold span boundaries; the assignment predicts the constituent label of each span using frozen BERT representations.

Dataset: [compling/cs489-f26-a3](https://huggingface.co/datasets/compling/cs489-f26-a3).
Collection: [cs489-f26](https://huggingface.co/collections/compling/cs489-f26).

| Split | Sentences | Labeled spans |
| :--- | ---: | ---: |
| `train` | 39,832 | 701,738 |
| `dev` | 1,700 | 29,034 |

The label vocabulary contains 26 constituent labels.
The TA holds a separate test split for final evaluation.

## Load with Hugging Face Datasets

```python
from datasets import load_dataset

corpus = load_dataset("compling/cs489-f26-a3")
train = corpus["train"]
dev = corpus["dev"]
sentence = train[0]
tokens = sentence["tokens"]
spans = sentence["constituents"]
```

## Download the assignment files

The starter reads the original JSONL files and label list from `data/`.
Run this from the starter project root:

```python
from huggingface_hub import snapshot_download

snapshot_download(
    repo_id="compling/cs489-f26-a3",
    repo_type="dataset",
    allow_patterns=["train.jsonl", "dev.jsonl", "labels.json", "manifest.json"],
    local_dir="data",
)
```

## Sentence format

Each UTF-8 JSONL line is one sentence with three fields:

- `id`: a unique string identifier for the record.
- `tokens`: the ordered list of word tokens, preserving capitalization and punctuation.
- `constituents`: a list of objects with integer `start` and `end` fields and a string `label`.

A hand-written example:

```json
{"id":"toy-0001","tokens":["The","cat","sleeps","."],"constituents":[{"start":0,"end":2,"label":"NP"},{"start":0,"end":4,"label":"S"},{"start":2,"end":3,"label":"VP"}]}
```

Boundaries use zero-based word-token indices with an exclusive end: `tokens[start:end]`.
They satisfy `0 <= start < end <= len(tokens)`.
Each span has one label, and the spans are sorted by `(start, end)` with unique boundary pairs within each sentence.

`labels.json` is a JSON list of 26 label strings.
A label's zero-based index in this list is its class ID.
Use the supplied order for every split, probe, and saved artifact.
Use the complete train/dev files as supplied and count every listed span during training and evaluation.

## Files

| File | Contents |
| :--- | :--- |
| `train.jsonl`, `dev.jsonl` | Sentence records in the format above, one record per line |
| `labels.json` | Ordered label vocabulary |
| `manifest.json` | Dataset metadata, counts, and SHA-256 checksums for the assignment files |
| `train.parquet`, `dev.parquet` | Equivalent typed tables used by `load_dataset`, preserving every field and row |