hsilvosa commited on
Commit
f46a612
·
verified ·
1 Parent(s): 842aae5

Replace project README with dedicated dataset card

Browse files
Files changed (1) hide show
  1. README.md +37 -105
README.md CHANGED
@@ -27,140 +27,72 @@ configs:
27
 
28
  # BNE Linked Data
29
 
30
- **Published dataset:** [hsilvosa/bne-linked-data on Hugging Face](https://huggingface.co/datasets/hsilvosa/bne-linked-data)
31
 
32
- This directory contains a reproducible pipeline for downloading, normalizing, profiling, and publishing the Linked Open Data dumps from the Biblioteca Nacional de España (BNE). The source represents bibliographic resources, authority records, and subject headings as an RDF knowledge graph.
33
 
34
- The dataset is observational and relational. It has no target label, predefined classes, or official train, validation, and test split. Each collection is published as a `train` split so downstream users can build graph, retrieval, entity-linking, or recommendation tasks without an arbitrary split imposed upstream.
35
 
36
  ## Source and licence
37
 
38
- - BNE Linked Data portal: <https://datos.bne.es/>
39
- - Official documentation and downloads: <https://www.bne.es/es/catalogos/datos-enlazados-bne/datos-enlazados>
40
- - Publisher: Biblioteca Nacional de España
41
- - Data licence: [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/)
42
- - Released source snapshot: 6 September 2023, preserved by Internet Archive on 20 September 2023
43
 
44
- The BNE documentation page describes an older 21 January 2021 extraction with more than four million bibliographic records, more than four million authority records, and approximately thirty million RDF triples. The reproducible release in this directory uses the later September 2023 official files preserved by Internet Archive. Direct source metadata identifies 6 September 2023 as the last-modified date for all three files.
45
 
46
- As checked on 12 August 2026, the live BNE download URLs and SPARQL endpoint return HTTP 403 to automated requests from the current execution network because of a Cloudflare rule. `configs/default.json` therefore points to byte-for-byte captures of the official BZip2 responses in Internet Archive. Downloads remain resumable, and `configs/archive-2023.json` records the same immutable sources explicitly.
47
 
48
- ## Dataset contents
49
-
50
- The release is designed around three Hugging Face configurations:
51
-
52
- | Configuration | Source content | Compressed source | RDF triples | Parquet |
53
  |---|---|---:|---:|---:|
54
- | `bibliographic` | Bibliographic resources covering books, manuscripts, serials, maps, photographs, music, sound, and audiovisual material | 1,212,541,852 bytes | 208,059,171 | 1,772,292,848 bytes |
55
- | `authorities` | People, organisations, conferences, works, expressions, geographic names, and other authority entities | 359,784,392 bytes | 46,107,241 | 493,978,094 bytes |
56
- | `subjects` | Subject headings represented in SKOS | 33,805,185 bytes | 6,122,512 | 51,987,039 bytes |
 
 
57
 
58
- Each RDF statement becomes one Parquet row. No triples are inferred, discarded, or enriched. The normalized columns are:
59
 
60
- | Column | Meaning |
61
  |---|---|
62
- | `record_id` | Stable identifier formed from collection and decompressed source-line number |
63
  | `subject` | Subject IRI or blank-node identifier |
64
  | `predicate` | Predicate IRI |
65
  | `object` | Object IRI, blank-node identifier, or decoded literal value |
66
  | `object_kind` | `iri`, `literal`, or `blank_node` |
67
  | `language` | Language tag attached to a literal, when present |
68
  | `datatype` | Datatype IRI attached to a literal, when present |
69
- | `collection` | Source collection name |
70
- | `source_line` | One-based line number in the decompressed dump |
71
- | `snapshot_date` | Date assigned by the source to the dump |
72
-
73
- The statement representation preserves the complete graph while remaining easy to query with DuckDB, Polars, Spark, or Hugging Face Datasets. Subjects and objects can be joined directly to reconstruct authorship, subject, work, expression, manifestation, and external authority relationships.
74
-
75
- ## Capacity and duration
76
-
77
- The verified download is 1,606,131,429 bytes (1.50 GiB) and took 10 minutes 46 seconds on the measured connection. Normalization took 1 hour 39 minutes, the full DuckDB profile took 49 seconds, and the resulting 1,043 Parquet shards occupy 2,318,257,981 bytes (2.16 GiB). Allow at least 10 GiB free when both processed data and a staging copy are retained. The pipeline streams BZip2 input and does not create a decompressed N-Triples copy.
78
 
79
  ## Exploratory profile
80
 
81
- The September 2023 snapshot contains 260,288,924 triples. Authorities have 5,624,909 distinct subjects and 96 predicates; bibliographic data has 17,850,587 distinct subjects and 105 predicates; subjects have 706,951 distinct subjects and 21 predicates. Objects are split between 85,517,669 IRIs and 174,771,255 literals. No blank-node objects occur in the snapshot.
82
-
83
- Subject labels contain 1,604,451 language-tagged literals: 1,527,636 Spanish, 32,508 English, 20,530 French, 15,982 Catalan, 5,186 Basque, and 2,609 Galician. Frequent relations include `rdf:type`, BNE identifiers and labels, bibliographic manifestation/work links, SKOS semantic relations, and 1,353,732 `owl:sameAs` authority links. Complete counts and the thirty most frequent predicates per collection are in `artifacts/profile.json`.
84
-
85
- Run the estimate before every download:
86
-
87
- ```powershell
88
- bne-pipeline estimate --config configs/default.json
89
- ```
90
-
91
- ## Installation
92
-
93
- Python 3.11 or newer is recommended.
94
-
95
- ```powershell
96
- python -m venv .venv
97
- .\.venv\Scripts\python.exe -m pip install -e ".[dev]"
98
- ```
99
-
100
- ## Pipeline
101
-
102
- Run each stage independently:
103
-
104
- ```powershell
105
- bne-pipeline download --config configs/default.json
106
- bne-pipeline normalize --config configs/default.json
107
- bne-pipeline analyze --config configs/default.json
108
- bne-pipeline stage --config configs/default.json
109
- ```
110
-
111
- Or execute the complete workflow:
112
-
113
- ```powershell
114
- bne-pipeline run --config configs/default.json
115
- ```
116
-
117
- Interrupted downloads are retained as `.part` files and resumed with an HTTP range request when the server supports it. A file is promoted to the raw source path only after its byte size matches the length announced by the server. The sizes recorded in configuration are rounded planning estimates published by BNE.
118
-
119
- If Cloudflare permits the files in a normal browser but blocks the pipeline, download them from the official documentation and place them at these exact paths:
120
-
121
- ```text
122
- data/raw/autoridades.nt.bz2
123
- data/raw/materias.nt.bz2
124
- data/raw/bibliograficos.nt.bz2
125
- ```
126
-
127
- Then start at `normalize`. Existing sources are checked for a non-empty BZip2 header, so an HTML block page cannot be mistaken for an RDF dump. Full BZip2 integrity and UTF-8/N-Triples validity are checked while the files are streamed during normalization.
128
-
129
- The September 2023 subjects dump contains a small number of external BnF IRIs split immediately before the closing `>` and continued on the next physical line. The normalizer rejoins only this identifiable two-line pattern, preserves the first physical line in `source_line`, and reports the number of repaired statements. It does not apply general-purpose cleanup or alter IRI text.
130
-
131
- ## Small real-data validation
132
 
133
- `configs/sample.json` uses the smallest archived official 2023 dump, subject headings, and stops normalization after 10,000 valid triples. Its purpose is to validate the real RDF structure without producing a complete release. The 33.8 MB BZip2 file still has to be downloaded in full because BZip2 cannot be decoded safely from an arbitrary byte range.
134
 
135
- ```powershell
136
- bne-pipeline estimate --config configs/sample.json
137
- bne-pipeline run --config configs/sample.json
138
- ```
139
 
140
- The complete September 2023 snapshot uses `configs/default.json`; sample outputs are not mixed into a final release.
141
 
142
- When the source returns HTTP 403, `configs/fixture.json` provides an offline integration check using five real `owl:sameAs` statements for the BNE authority record of Miguel de Cervantes (`XX1718747`). These links to DNB, VIAF, DBpedia, IdRef, and Libris are reproduced from the [MARiMbA project documentation](https://oeg.fi.upm.es/index.php/es/technologies/228-marimba/index.html) and the [BNE/OEG project presentation](https://datos.gob.es/sites/default/files/blog/file/01_2_introduccion_ii.pdf). The fixture proves the complete transformation and publication path, but it is not a replacement for either the 10,000-row sample or the full dump.
143
 
144
- ```powershell
145
- bne-pipeline run --config configs/fixture.json
146
- ```
147
 
148
- ## Quality and provenance
 
 
 
 
149
 
150
- The analysis stage writes the same publication artefacts used by the other projects in this repository:
151
 
152
- - `artifacts/profile.json`: rows, distinct graph terms, object kinds, languages, and common predicates.
153
- - `artifacts/normalization.json`: parsed, repaired, rejected, and output counts from normalization.
154
- - `artifacts/schema.json`: physical schema and field semantics.
155
- - `artifacts/quality.json`: non-empty tables, graph accounting, normalization row agreement, and invalid-line checks.
156
- - `artifacts/provenance.json`: source, licence, snapshot, files, and transformations.
157
- - `artifacts/checksums.json`: SHA-256 and size of every published Parquet shard.
158
 
159
- Raw BZip2 dumps, partial downloads, local environments, and caches are excluded from Git and Hugging Face staging.
160
 
161
- ## Tests
162
 
163
- ```powershell
164
- .\.venv\Scripts\python.exe -m pytest
165
- .\.venv\Scripts\ruff.exe check .
166
- ```
 
27
 
28
  # BNE Linked Data
29
 
30
+ ## Dataset description
31
 
32
+ BNE Linked Data is a normalized Parquet release of the Linked Open Data dumps published by the Biblioteca Nacional de España. It represents bibliographic resources, authority records, subject headings, and the relationships among them as RDF statements.
33
 
34
+ The released snapshot contains 260,288,924 triples from official BNE files last modified on 6 September 2023. The files were preserved by Internet Archive on 20 September 2023. Each RDF statement is represented by one row; no relationships are inferred and no enrichment is added.
35
 
36
  ## Source and licence
37
 
38
+ - Publisher: [Biblioteca Nacional de España](https://datos.bne.es/)
39
+ - Documentation: [BNE Linked Data](https://www.bne.es/es/catalogos/datos-enlazados-bne/datos-enlazados)
40
+ - Snapshot date: 6 September 2023
41
+ - Licence: [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/)
 
42
 
43
+ The live BNE download service returned HTTP 403 to automated requests when this release was built. The data files therefore come from preserved copies of the original BNE BZip2 responses in Internet Archive. Source URLs, dates, and transformations are recorded in `artifacts/provenance.json`.
44
 
45
+ ## Configurations
46
 
47
+ | Configuration | Content | Rows | Parquet files | Parquet size |
 
 
 
 
48
  |---|---|---:|---:|---:|
49
+ | `bibliographic` | Bibliographic resources, manifestations, works, and their relationships | 208,059,171 | 833 | 1,772,292,848 bytes |
50
+ | `authorities` | People, organisations, conferences, works, expressions, and other authority entities | 46,107,241 | 185 | 493,978,094 bytes |
51
+ | `subjects` | Subject headings and SKOS relationships | 6,122,512 | 25 | 51,987,039 bytes |
52
+
53
+ Each configuration has a single `train` split containing the complete graph collection. The source does not define a supervised prediction target or official train, validation, and test partitions.
54
 
55
+ ## Fields
56
 
57
+ | Field | Description |
58
  |---|---|
59
+ | `record_id` | Stable identifier formed from the collection and source-line number |
60
  | `subject` | Subject IRI or blank-node identifier |
61
  | `predicate` | Predicate IRI |
62
  | `object` | Object IRI, blank-node identifier, or decoded literal value |
63
  | `object_kind` | `iri`, `literal`, or `blank_node` |
64
  | `language` | Language tag attached to a literal, when present |
65
  | `datatype` | Datatype IRI attached to a literal, when present |
66
+ | `collection` | Source graph collection |
67
+ | `source_line` | One-based physical line number in the decompressed source |
68
+ | `snapshot_date` | Source snapshot date |
 
 
 
 
 
 
69
 
70
  ## Exploratory profile
71
 
72
+ The authority collection contains 5,624,909 distinct subjects and 96 predicates. The bibliographic collection contains 17,850,587 distinct subjects and 105 predicates. The subject collection contains 706,951 distinct subjects and 21 predicates.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
+ Across all configurations there are 85,517,669 IRI objects and 174,771,255 literal objects. No blank-node objects occur. Subject data contains 1,604,451 language-tagged literals: 1,527,636 Spanish, 32,508 English, 20,530 French, 15,982 Catalan, 5,186 Basque, and 2,609 Galician.
75
 
76
+ Frequent relations include `rdf:type`, BNE identifiers and labels, bibliographic work and manifestation links, SKOS semantic relations, and 1,353,732 `owl:sameAs` authority links. Full counts and the thirty most frequent predicates per configuration are available in `artifacts/profile.json`.
 
 
 
77
 
78
+ ## Processing and quality
79
 
80
+ The BZip2 sources were streamed, parsed as N-Triples, and written as Zstandard-compressed Parquet. The subjects source contains 865 external BnF IRIs split immediately before the closing `>` and continued on the next physical line. Those identifiable pairs were rejoined without altering their text; the first physical line remains in `source_line`.
81
 
82
+ All 260,288,924 normalized rows passed the graph-accounting and source-line checks. No source statements remain invalid. SHA-256 hashes for every Parquet shard are provided in `artifacts/checksums.json`. Additional machine-readable information is available in:
 
 
83
 
84
+ - `artifacts/normalization.json`
85
+ - `artifacts/profile.json`
86
+ - `artifacts/provenance.json`
87
+ - `artifacts/quality.json`
88
+ - `artifacts/schema.json`
89
 
90
+ ## Intended uses and limitations
91
 
92
+ The data is suitable for graph analysis, bibliographic research, retrieval, entity linking, authority reconciliation, and recommendation research. Consumers should create task-specific and leakage-aware evaluation splits when needed.
 
 
 
 
 
93
 
94
+ The snapshot reflects the BNE catalogue as published in September 2023 and may contain cataloguing conventions, historical descriptions, or source errors. A relationship in the graph should not be interpreted as a current factual claim without checking the underlying catalogue record. The dataset contains metadata and identifiers, not digitized works or their full text.
95
 
96
+ ## Attribution
97
 
98
+ When using the data, attribute the Biblioteca Nacional de España as the original publisher and retain the CC0 and provenance information supplied with the release.