Datasets:
File size: 5,423 Bytes
6a78daf 4fa90e3 6a78daf dd5c1b9 6a78daf 4fa90e3 6a78daf 4fa90e3 f43db24 4fa90e3 | 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 | ---
pretty_name: Wikimedia Enterprise Structured Contents — cywiki_namespace_0
language:
- cy
license: cc-by-sa-4.0
task_categories:
- text-generation
- question-answering
- text-retrieval
tags:
- wikipedia
- wikimedia-enterprise
- structured-contents
size_categories:
- 1M<n<10M
configs:
- config_name: default
data_files:
- split: train
path: data/*.parquet
---
# cywiki_namespace_0
Structured Contents snapshot of `cywiki_namespace_0` from the
[Wikimedia Enterprise API](https://enterprise.wikimedia.com/docs/snapshot/),
repackaged as Parquet with a pinned schema.
The upstream Wikimedia Foundation dataset
([`wikimedia/structured-wikipedia`](https://huggingface.co/datasets/wikimedia/structured-wikipedia))
ships NDJSON which has known issues loading via
`datasets.load_dataset()` — see discussions
[#5](https://huggingface.co/datasets/wikimedia/structured-wikipedia/discussions/5),
[#15](https://huggingface.co/datasets/wikimedia/structured-wikipedia/discussions/15),
[#16](https://huggingface.co/datasets/wikimedia/structured-wikipedia/discussions/16).
This dataset is the same upstream content, normalised so
`load_dataset(...)` works without specifying a `Features` override.
## Source
- Upstream: [Wikimedia Enterprise Structured Contents API](https://enterprise.wikimedia.com/docs/snapshot/#structured-contents-snapshot-download-beta)
- Snapshot identifier: `cywiki_namespace_0`
- Format at source: `.tar.gz` containing sharded `.ndjson`
- Shards in this release: 1
## File layout
```
README.md ← this file
schema.json ← pinned Arrow schema (IPC + field-name index)
data/
cywiki_namespace_0_0.parquet
cywiki_namespace_0_1.parquet
... (1 files total)
```
One Parquet file per upstream NDJSON shard. Files are independently
downloadable, so consumers can parallelise downloads or pull only the
subset they need rather than the whole dataset.
## Loading the dataset
Every shard has a byte-identical embedded schema (alphabetised
recursively so struct field order is stable across shards). All of
these load without extra config:
```python
# Hugging Face datasets
from datasets import load_dataset
ds = load_dataset("VoeTheDon/testing-wiki-structured", split="train", streaming=True)
# Polars
import polars as pl
df = pl.read_parquet("hf://datasets/VoeTheDon/testing-wiki-structured/data/*.parquet")
# DuckDB
import duckdb
duckdb.sql(
"SELECT name, url FROM 'hf://datasets/VoeTheDon/testing-wiki-structured/data/*.parquet' LIMIT 10"
)
# pyarrow
import pyarrow.dataset as pads
table = pads.dataset("hf://datasets/VoeTheDon/testing-wiki-structured/data/", format="parquet").to_table()
```
Four columns are stored as JSON-encoded strings (see *Schema notes*
below). Decode on read:
```python
import json
row = next(iter(ds))
sections = json.loads(row["sections"]) # list[dict]
infoboxes = json.loads(row["infoboxes"]) # list[dict]
tables = json.loads(row["tables"]) # list[dict]
for ref in row["references"]:
ref_meta = json.loads(ref["metadata"]) # dict
```
If you need the canonical Arrow schema explicitly (e.g. for a
validation step in a downstream pipeline), it's published as
`schema.json` at the repo root in Arrow IPC format:
```python
import json, pyarrow as pa
payload = json.loads(open("schema.json").read())
schema = pa.ipc.read_schema(pa.py_buffer(bytes.fromhex(payload["arrow_ipc_hex"])))
```
## Schema notes
Four fields are JSON-encoded rather than stored as native Arrow structs:
| Field | Why |
|---|---|
| `sections` | Recursive `has_parts[].has_parts[]…` nesting reaches depth ~100 in real articles. Apache Arrow's C Data Interface caps struct recursion at 64 levels; `datasets.load_dataset()` round-trips schemas through that interface and rejects deeper structures. |
| `infoboxes` | Same recursive shape as `sections`. |
| `tables` | Shallower today but the same recursive structure — pre-emptively encoded so future upstream changes don't break the schema. |
| `references[].metadata` | Open dict of Wikipedia citation-template parameters (`rft.jtitle`, `chapter-url`, `first1`, positional `"1"`, …). Hundreds of ad-hoc keys appear across articles, producing a different inferred Arrow `struct` per shard, which breaks cross-shard schema unification. |
All other fields (`name`, `url`, `abstract`, `event`, `license[]`,
`version`, `image`, `main_entity`, `references[]` excluding metadata,
etc.) retain native Arrow struct/list types and are queryable without
decoding.
Struct field order is alphabetised recursively so every shard has a
byte-identical embedded schema — pyarrow's JSON inference otherwise
captures keys in encounter order, which makes Arrow treat
`struct<a, b>` and `struct<b, a>` as different types.
## Known limitations
- **Article categories are not included.** The upstream Structured
Contents snapshot does not expose categories. If you need them,
query the regular [WME Snapshots API](https://enterprise.wikimedia.com/docs/snapshot/)
or the [MediaWiki API:Categories](https://www.mediawiki.org/wiki/API:Categories)
endpoint.
- License passes through the upstream Wikipedia license
(CC-BY-SA-4.0) for article text.
- This is a Beta-tier upstream snapshot — schema can change between
WME releases. Each version of this dataset re-pins `schema.json`;
consumers who want a stable contract should pin to a specific
dataset revision.
|